jfierberg
Contributor
Contributor

Running a vitoolkit ps script from Scheduled task

Jump to solution

When I execute the following command, C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\vim.psc1" -command "C:\VMscripts\datastore.ps1" I get these errors:

The term 'Get-VC' is not recognized as a cmdlet, function, operable program, or

script file. Verify the term and try again.

At C:\VMscripts\datastore.ps1:9 char:7

+ Get-VC <<<< 10.8.7.17 -Port 8001 -USER

Get-Datastore : 12/5/2008 9:40:12 AM Get-Datastore You are not curren

tly connected to any servers. Please connect first using Connect-VIServer or one of its aliases.

At C:\VMscripts\datastore.ps1:10 char:14

+ Get-Datastore <<<< | Select Name,$free,$capacity |sort FreespaceGB,Name | C

onvertTo-Html -head $a -body "<H2>VM Datastore Freespace\Capacity</H2>" | Out-F

ile c:\VMreports\datastore.htm

How do I correct this so my scheduled task will run?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

The cmdlet Get-VC is an alias that is defined in %ProgramFIles%\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1.

This script is run when you start the VI Toolkit prompt via the shortcut.

You can use the cmdlet Connect-VIServer instead of Get-VC or define the alias in your profile.


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership

The cmdlet Get-VC is an alias that is defined in %ProgramFIles%\VMware\Infrastructure\VIToolkitForWindows\Scripts\Initialize-VIToolkitEnvironment.ps1.

This script is run when you start the VI Toolkit prompt via the shortcut.

You can use the cmdlet Connect-VIServer instead of Get-VC or define the alias in your profile.


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

View solution in original post

0 Kudos