xerkia
Contributor
Contributor

Get-VirtualSwitch is not recognized as the name of a cmdlet, function, script file,

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.

0 Kudos
3 Replies
Jalapeno420
Enthusiast
Enthusiast

does your script import the PowerCLI module?

#Import the PowerCLI module

Add-PSSnapin VMware.VimAutomation.Core

0 Kudos
xerkia
Contributor
Contributor

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.

0 Kudos
LucD
Leadership
Leadership

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 Smiley Wink


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos