I'm new here and first of all I just wanna say hello - my name is Serkan and I'm a system engineer. so far so good.
I have written a PS1 script (in combination with a bat-file) which is able to shutdown a vm.
The script works as I opened it with the BackAdmin user in CMD but as a post-job script it ends up with a "time out".
Maybe some of you could help?!
The scripts:
stop_bvm02.bat:
Code: Select all
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\" $true; . \"C:\Scripts\stop_bvm02.ps1\""
exit /b 0
Code: Select all
$vCenter = "XXXXXX"
$User = "XXXXXXXX"
$Password = "XXXXXXX"
$VM = "bvm02"
Write-Output "Connect vCenter..."
Connect-VIServer -Server $vCenter -Protocol https -User $User -Password $Password
Write-Output "stop bvm02"
stop-vm -vm $VM -Confirm:$false
Write-Output "Disconnect vCenter..."
Disconnect-VIServer -Server $vCenter -Confirm:$false
exit
Is this possible? Or have some of you any other ideas?
Thank you in advance!
Best reguards,
Serkan