- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I go to run the command:
vSphere PowerCLI> Get-VICommand
The term 'Get-VICommand' is not recognized as the name of a cmdlet, function, script file, or operable program.....
I am on a system that I normally am not on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
You need to use the "get-command" cmdlets to get the commands.
If you want to use very specific commands use like get-command -verb <set>.
Not sure about the get-VIcommand, but I have gone through somewhere. But it never worked in Powercli 4.1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can confirm that get-vicommand does work in powercli 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, scbaca-
This "command" is a function that is defined in the environment initialization script that comes with PowerCLI. The current default location for that script is "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1".
The function Get-VICommand uses the standard PowerShell Get-Command cmdlet and adds the (deprecated) -PSSnapin parameter to return just commands from the VMware PSSnapins that are added to the current PowerShell session. (Microsoft has replaced -PSSnapin with -Module, it seems, but -PSSnapin still works).
So, you could either run that environment initialization script to get the function defined so that you can use Get-VICommand, or you could just use:
## get all commands from VMware.* PSSnapins in current PowerShell session
Get-Command -Module VMware.*
## get all commands from VMware.* PSSnapins in current PowerShell session with a noun matching VMHost*
Get-Command -Module VMware.* -Noun VMHost*
You can use the other standard params for Get-Command, like -Name, -Noun, and -Verb, to narrow your results. Enjoy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That will usually occur when the Snapin hasn't been initialized.
Try running this:
Add-PSsnapin VMware.VimAutomation.Core
Then run the get-vicommand cmdlet.
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Zsoldier,
When we install Powercli, the snapin VMware.VimAutomation.Core will be added default. right?
After installing Powercli -I have modified only Executionpolicy, I never added snapin in Powercli.
If I am wrong, correct me. Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you sure you're running Powercli and not just windows powershell from the powercli directory?
To be sure you're running Powershell with the vmware cli snap in enter this in your start>run box:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -psc "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\"
Thats for the 32bit version. Or try running it from the powerCLI desktop icon. You should see the vmware text load when the powershell window opens. Then try running get-vicommand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Get-command is working, but I have used "on another system" Get-VICommand" no problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please run the following commands:
get-command | ?{$_.ModuleName -like "*vmware*"}
Does this return anything? If so, how many commands?
get-powercliversion
What does this return?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After installing powercli, when you run the powerCLI shortcut, it calls a ps1 script that adds the snapin. Running powershell.exe alone does not initialize the snapin by default, unless you've added it to your powershell profile.
The reason the get-vicommand is not working is likely these couple of things:
- Execution Policy not set to remotesigned (Set-ExecutionPolicy -RemoteSigned)
- The Snap-In was not initialized (Add-PSsnapin VMware.VimAutomation.Core)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
# Set-ExecutionPolicy Unrestricted
and I tried running the command: # Add-Snapin....
and it said that the snap-in was already added.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I counted 236 lines
and Get-PowerCLIVersion returns 4.1 build 264274
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Funny thing I restarted the window and it worked right after setting the ExecutionPolicy