Hello,
I need some help to script with PowerCli to remove standard switch for several ESXi 6.7 server of a cluster. I use a list of esxi hostname with a cloumn name.
regards,
David
And which VSS?
All of them or are the names in the CSV?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello,
yes VSS
yes names in CSV file
regards,
David
Could you provide the layout of that CSV file?
Is there a row for each VSS on each ESXi node?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello,
In the CSV file it's compose with a unique column:
Name
esxi1
esx2
esx3
etc...
It's the same VSS name on each ESX.
regards
Try something like this
$vssName = 'vss'
Import-Csv -Path .\names.csv -UseCulture -PipelineVariable row |
ForEach-Object -Process {
Get-VMHost -Name $row.Name |
Get-VirtualSwitch -Name $vssName |
Remove-VirtualSwitch -Confirm:$false
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Can I use this type of script?
$StandardSwitch = Get-VirtualSwitch -Name $stdswitch
$listesxi = ".\$CSV"
$ESXi = Import-CSV $listesxi
foreach ($hostname in $ESXi) {
Get-VMHost -Name $hostname.Name | Get-VirtualSwitch -Name $StandardSwitch | Remove-VirtualSwitch -Confirm:$false
}
regards
Sure, you can do whatever you want.
But I'm wondering, what is wrong with the snippet I gave earlier?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello,
Nothing. All is OK.
Thanks for your help.
regards,