Hello,
I'm running a script which getting the info for vswitch network security policy, however i am getting below error in powershell v2 and powercli 5.1.
The term 'Get-VirtualSwitch -Standard -Name' is not recognized as the name of a cmdlet, function, s
cript file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At C:\temp\ESXiCheckv4_ddc.ps1:39 char:63
+ $forgedtransmits = $vmhost | Get-VirtualSwitch -Standard -Name vSwitch0 | Select @{N="Forg
edTransmits";E={if ($_.ExtensionData.Spec.Policy.Security.ForgedTransmits) { "Accept" } Else { "Rej
ect"} }}
+ CategoryInfo : ObjectNotFound: (Get-VirtualSwitch -Standard -Name:String) [], Comma
ndNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Would really appreciate anyone can share an idea and advise to resolve the error, thanks in advance.
does your script import the PowerCLI module?
#Import the PowerCLI module
Add-PSSnapin VMware.VimAutomation.Core
yes vmware modules are loaded at thr beginning of the script, among all other powercli cmdlet i use in the script only this lline get-virtualswitch return with errors, but if i run the command manually with a complete option iit is fine.
Which PowerCLI version are you using ?
Do a Get-PowerCLIVersion.
PS: if the scriptname is an indication, you seem to be using an older vCheck version
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference