I'm looking for a script that will take a list of existing VM's up to 1000 and repoint their existing NICS to a different DVS and port group.
Thanks,
Pete
You could do something along these lines
Import-Csv -Path .\vms.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
$pg = Get-VDSwitch -Name $row.TargetVDS | Get-VDPortgroup -Name $row.TargetPortgroup
Get-VM -Name $row.Name | Get-NetworkAdapter |
Set-NetworkAdapter -Portgroup $pg -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is basically doing, in a loop, a Get-NetworkAdapter and Set-NetworkAdapter , with the Portgroup parameter, for each vNIC of all the VMs.
You didn't say how you get these VMs.
Is that from a CSV file or through a Get-VM from a specific location?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yeah. I'm just going to export a list of the VMs. Possibly from RVTOOLS with their port group. Then possibly have three columns in the csv. Name, Target DSV, Target PortGroup. Then then let it reconfigure the VM's.
You could do something along these lines
Import-Csv -Path .\vms.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
$pg = Get-VDSwitch -Name $row.TargetVDS | Get-VDPortgroup -Name $row.TargetPortgroup
Get-VM -Name $row.Name | Get-NetworkAdapter |
Set-NetworkAdapter -Portgroup $pg -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference