VMware Cloud Community
PeterHS
Contributor
Contributor
Jump to solution

Not able to start VI-toolkit from powershell

Hi,

As a newbe I'm running into the fact that I cannot start the VI-toolkit for Windows from powershell. Starting the VI-toolkit directly works fine but starting a cmdlet with

Add-PSSnapin VMware.VimAutomation.Core

Initialize-VIToolkitEnvironment.ps1

followed by any VI-toolkit command (for example Get-VICommand) gives the notification : The term 'Get-VICommand' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again.

As far as I know I needs this to be able to schedule cmdlets.

I'm running VI-toolkit with 113525 (SP1) + VC 2.5.0 (built 119598) + ESX 3.5.0

Any help woul be appreciated! :smileygrin:

Thanks Peter.

0 Kudos
1 Solution

Accepted Solutions
ewannema
Enthusiast
Enthusiast
Jump to solution

Get-VICommand is a function that is set in the environment script. You can see if it was created by doing dir function:Get-VICommand.

My guess is that this script is not being loaded properly. You may want to try "sourcing" the file, especially if you are using it in your profile.ps1 startup script.

This is what my profile.ps1 contains regarding VMware (note the space after the . in the second line):

Add-PSSnapin VMware.VimAutomation.Core

. "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1"

http://wannemacher.us

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Are you sure the Initialize-VIToolkitEnvironment.ps1 script is executed ?

Check if the aliases are there

Get-Alias Get-VIServer
Get-Alias Get-VC
Get-Alias Get-ESX

And note that there is no cmdlet Get-VICommand in the VITK.

Try something else like for example

Get-VIToolkitVersion


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

ewannema
Enthusiast
Enthusiast
Jump to solution

Get-VICommand is a function that is set in the environment script. You can see if it was created by doing dir function:Get-VICommand.

My guess is that this script is not being loaded properly. You may want to try "sourcing" the file, especially if you are using it in your profile.ps1 startup script.

This is what my profile.ps1 contains regarding VMware (note the space after the . in the second line):

Add-PSSnapin VMware.VimAutomation.Core

. "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1"

http://wannemacher.us
0 Kudos
PeterHS
Contributor
Contributor
Jump to solution

Thank you for your input LUCD and ewannema!

When I tried again this morning with something simple like GET-VIToolkitVersion it worked!

When I added

. "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1"

the GET-VICommand also worked.

Thanks Guys!

0 Kudos