Take a look at How to set scheduled task by powercli? This thread will probably answer your question.
Thansk RvdNieuwendijk !
that helped me..
but the command is running when i paste it in Vmware PowerCli windows..
When i paste it in "Run" .. its doesnt work !! I mean a command windows comes and closes immediately..
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
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
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