Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 189307

Re: PowerCLI script to change the MAC address

$
0
0

You can adjust Luc's code a bit so that it exports the original info along with the MAC address.

It would be something like:

 

## save the imported info $colVMInfoFromCSV = Import-Csv $importfile

 

## add a NoteProperty to the info (later to be a "column" at Export-Csv time) $colVMInfoFromCSV | Add-Member -MemberType NoteProperty macaddress -value $null $colVMInfoFromCSV | %{    $vname = $($_.Hostname)    New-VM -name $vname -VMhost $vmhost -ResourcePool $pool -DiskMB $disksize -MemoryMB $memsize -NumCpu $cpu -DiskStorageFormat thin -Datastore $datastore -GuestID $os -NetworkName $nic0 -Location $location      $macnic1 = Get-NetworkAdapter -vm $vname | where {$_.type -match "e1000"} | select-object MacAddress

 

## put the MAC address in this "row" of the collection of info (this object in the array of objects)    $_.macaddress = $macnic1      New-NetworkAdapter -VM $vname -NetworkName $nic1 -StartConnected -Type vmxnet3    New-NetworkAdapter -VM $vname -NetworkName $nic2 -StartConnected -Type vmxnet3 }

Regards,
Milton


Viewing all articles
Browse latest Browse all 189307

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>