Automation

 View Only
  • 1.  Script will no longer run

    Posted Feb 03, 2011 02:27 PM

    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.



  • 2.  RE: Script will no longer run

    Posted Feb 03, 2011 02:41 PM

    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}"



  • 3.  RE: Script will no longer run

    Posted Feb 03, 2011 03:15 PM

    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.



  • 4.  RE: Script will no longer run

    Posted Feb 03, 2011 03:15 PM

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



  • 5.  RE: Script will no longer run
    Best Answer

    Posted Feb 03, 2011 02:55 PM

    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



  • 6.  RE: Script will no longer run

    Posted Feb 03, 2011 03:20 PM

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



  • 7.  RE: Script will no longer run

    Posted Feb 03, 2011 03:02 PM

    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.