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.
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
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}"
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
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.
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.
I missed the 64bit part... Roberts's solution should work for you.
That worked! Thanks, Robert! ( Points awarded to you and Troy! )