Script to Change vSwitch Security Settings

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?

The script does not make sense this way. Import-Csv can take pipeline input but only for the parameter -Path or -LiteralPath. What would you like to accomplish with it?

[quote quote=155049]The script does not make sense this way. Import-Csv can take pipeline input but only for the parameter -Path or -LiteralPath. What would you like to accomplish with it?

[/quote]
Thanks for your reply, but I have fixed the issue. Actually I was trying to set Forged Transmits to Reject. I already set manually to Reject on few hosts so I can test my script to reset Accept and then I can use this script to set Reject for all hosts.