VMware Cloud Community
NYSDHCR
Enthusiast
Enthusiast
Jump to solution

Script will no longer run

I have a script created by VIRTU-AL: vCheck5.ps1

I have created a .bat file run fas a scheduled task. If I issue each command seperately, the script runs. But If I run the script together, it never gets by the first line:

powershell.exe
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
C:\PSscript\vCheck5.ps1 vi_server

I had no problem runniing this script from a Windows XP workstation. Now I have a Windows 7 (64-bit) workstation.

Any advice would be appreciated.

Note* 

This was my previous script on a Windows XP workstation:

%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "&{C:\PSscript\vCheck5.ps1 VI_Server}"

Here is the error message it returns:

Failed to load Windows PowerShell console file “C:\Program Files\VMware\Infrastr
ucture\vSphere PowerCLI\vim.psc1″. WIN 32 error: The system cannot find the path
specified.

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

On a Windows 7 64-bit PC, PowerCLI is installed in the "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI" folder. So you should change the command into:

%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "&{C:\PSscript\vCheck5.ps1 VI_Server}"

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
6 Replies
Troy_Clavell
Immortal
Immortal
Jump to solution

maybe try below instead of using the %SystemRoot% and just add to the Run:  line of a scheduled task.  This is how I have it setup, albeit from a W2K3 Server.

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile  "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1"  -command "&{C:\PSscript\vCheck5.ps1}"

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

On a Windows 7 64-bit PC, PowerCLI is installed in the "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI" folder. So you should change the command into:

%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command "&{C:\PSscript\vCheck5.ps1 VI_Server}"

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
bulletprooffool
Champion
Champion
Jump to solution

Confirm that C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1 actually exists.

If you have installe don a 64 bit OS, the Program files path changes to Proagram files (x86) for 32 bit apps.

Also, if it is a new machine, make sure that you have the vSphere PowerCli installed.

One day I will virtualise myself . . .
0 Kudos
NYSDHCR
Enthusiast
Enthusiast
Jump to solution

I tried that. Her'e the error:

Failed to load Windows PowerShell console file "C:\Program Files\VMware\Infrastr
ucture\vSphere PowerCLI\vim.psc1". WIN 32 error: The system cannot find the path
specified.

0 Kudos
Troy_Clavell
Immortal
Immortal
Jump to solution

I missed the 64bit part... Roberts's solution should work for you.

NYSDHCR
Enthusiast
Enthusiast
Jump to solution

That worked! Thanks, Robert! ( Points awarded to you and Troy! )

0 Kudos