I have tried following script script, but getting error:
Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -PipelineVariable vm | Import-Csv "C:\HostNames.csv" -UseCulture | %{ $esx = Get-View -ViewType HostSystem -Filter @{"Name"=$_.Name} $NetworkSystem = Get-View $esx.ConfigManager.NetworkSystem foreach ($sw in $NetworkSystem.Networkconfig.Vswitch){ $swspec = $sw.spec $swspec.policy.security.ForgedTransmits=$true $NetworkSystem.UpdateVirtualSwitch($sw.name,$swspec) } }
Import-Csv : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. At C:\Users\abcd\Documents\vSwitchSeucrityConfig.ps1:2 char:1 + Import-Csv "C:\Users\abcd\Documents\HostNames.csv" -UseCulture | %{ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (VMware.Vim.VirtualMachine:PSObject) [Import-Csv], ParameterBindingException + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.PowerShell.Commands.ImportCsvCommand
Can anyone help me?