VMware Cloud Community
Bunty11
Hot Shot
Hot Shot

PowerCli Script -Scheduled Task

How can i run powercli script in sceduled task in windows xp ?

Tags (1)
Reply
0 Kudos
5 Replies
RvdNieuwendijk
Leadership
Leadership

Take a look at How to set scheduled task by powercli? This thread will probably answer your question.

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


Thansk    RvdNieuwendijk !

that helped me..

but the command is running when i paste it in Vmware PowerCli windows.. Smiley Happy

When i paste it in "Run" .. its doesnt work !! I mean a command windows comes and closes immediately.. Smiley Sad

Reply
0 Kudos
LucD
Leadership
Leadership

To keep the window open,add the NoExit parameter, like this

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -NoExit -PSConsoleFile “C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1″ ” &  “C:\Scripts\MyScript.ps1″


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

Bunty11
Hot Shot
Hot Shot

I Get following error :

Missing expression after unary operator '-'.

At line:1 char:2

+ - <<<< PSConsoleFile 'C:\Program Files\VMware\Infrastructure\vSphere PowerCLI

\vim.psc1' &  'D:\Documents and Settings\xxxx\Desktop\****-PowerCli\Get-

VmwareSnapshots-itlab.ps1'

    + CategoryInfo          : ParserError: (-:String) [], ParentContainsErrorR

   ecordException

    + FullyQualifiedErrorId : MissingExpressionAfterOperator

Reply
0 Kudos
LucD
Leadership
Leadership

Are you by any chance running this on a 64-bit system ?

Then try this variation

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -psconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noexit -command c:\myscript.ps1

If you're on a 32-bit system, try this

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -psconsolefile "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noexit -command c:\myscript.ps1


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

Reply
0 Kudos