VMware Cloud Community
snowmizer
Enthusiast
Enthusiast
Jump to solution

Loading VI Toolkit (for Windows) in script

I have written a Powershell script that implements cmdlets from the VI Toolkit for Windows. When I wrote the script I used PowerGUI and was able to load the libraries so all VI Toolkit cmdlets were available. Now I'm trying to run my script outside of PowerGUI since I'd like to schedule this script to run.

When I open a Powershell window and run ./scriptname.ps1 I get a message that Get-VIServer is not a cmdlet,.... I know that this is because the VI Toolkit library isn't loaded. How do I fix this problem?

Thanks.

0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

I have written a Powershell script that implements cmdlets from the VI Toolkit for Windows. When I wrote the script I used PowerGUI and was able to load the libraries so all VI Toolkit cmdlets were available. Now I'm trying to run my script outside of PowerGUI since I'd like to schedule this script to run.

When I open a Powershell window and run ./scriptname.ps1 I get a message that Get-VIServer is not a cmdlet,.... I know that this is because the VI Toolkit library isn't loaded. How do I fix this problem?

Thanks.

You'll need to put

add-pssnapin VMware.VimAutomation.Core

in your script.

Additionally, you can find out what snapins are installed using

get-pssnapin

And what snapins are available using

get-pssnapin -registered

View solution in original post

0 Kudos
3 Replies
admin
Immortal
Immortal
Jump to solution

I have written a Powershell script that implements cmdlets from the VI Toolkit for Windows. When I wrote the script I used PowerGUI and was able to load the libraries so all VI Toolkit cmdlets were available. Now I'm trying to run my script outside of PowerGUI since I'd like to schedule this script to run.

When I open a Powershell window and run ./scriptname.ps1 I get a message that Get-VIServer is not a cmdlet,.... I know that this is because the VI Toolkit library isn't loaded. How do I fix this problem?

Thanks.

You'll need to put

add-pssnapin VMware.VimAutomation.Core

in your script.

Additionally, you can find out what snapins are installed using

get-pssnapin

And what snapins are available using

get-pssnapin -registered

0 Kudos
snowmizer
Enthusiast
Enthusiast
Jump to solution

Thanks for the reply. Since I'm a newbie with this I've had to learn a lot. When I try that though I'm getting this message:

Add-PSSnapin : Cannot load Windows PowerShell snap-in VMWare.VimAutomation.Core because of the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Loader Exceptions: Could not load file or assembly "VMWare.VimAutomation.Types, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" or one of its dependencies. The system cannot find the file specified.

Thanks.

0 Kudos
snowmizer
Enthusiast
Enthusiast
Jump to solution

Disregard my previous email. When I added the "add-snapin..." statement to my Powershell script, reopened my Powershell window and tried my script it ran fine.

Thanks for your help.

0 Kudos