Lauch a VMware powercli script from 'local command 1'

BatchPatch Forums Home Forums BatchPatch Support Forum Lauch a VMware powercli script from 'local command 1'

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8663
    Nico Reyserhove
    Participant

    Hi,

    I’m busy testing the software and this looks great. This will really simplify the monthly patch process. But running into an issue which I’m stuck for the moment.

    The idea is to launch a script to take a snapshot of the server (VMware) prior to installing the patches. I’m running into a problem here.

    The syntax in the local command section is:

    c:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command C:ToolsBatchPatchCreateSnapVM.ps1 $computer

    The “CreateSnapVM.ps1” contains:

    Param($VMname)

    import-module “C:Program FilesVMwareInfrastructurevSphere PowerCLIScriptsInitialize-PowerCLIEnvironment.ps1”

    $server=”vcenterserver.something.local”

    write-host “Connecting to vSphere server ” $server ” …” -foregroundcolor Green

    connect-viserver -server $server

    Get-VM $VMname | New-Snapshot -Memory -Quiesce -Name PrePatch_NRE


    Running the script manually from my local machine, all is working as planned. Running this from withing BatchPatch as a ‘Local Command 1’ it stops. It seems to stop when connecting to the vcenter server.

    Tried providing user/passw but stops.

    Any idea ?

    #9775
    doug
    Moderator

    Hi Nico – This is a bit strange because I’m not able to reproduce your problem. The way that I successfully execute powershell scripts using the Local Command 1 is like this:

    powershell.exe c:scriptsmyPowershellScript.ps1 $computer

    However, I also just tried the same syntax that you are using, and it works just fine for me too:

    c:WindowsSystem32WindowsPowerShellv1.0powershell.exe -command c:scriptsmyPowershellScript.ps1 $computer


    I wonder if the issue you are running into has something to do with permissions or execution policy or signing? It doesn’t *seem* like an issue with BatchPatch since I can’t reproduce it, but it’s hard to say. When you say the script “stops” what does that mean? Does it throw an error? I assume that you see powershell.exe in task manager for some period of time, but then what happens after that? Do you have any luck when you run BatchPatch as administrator (right-click on BatchPatch.exe and choose to run it as administrator)? Is there something going on with execution policies where somehow it’s not getting executed due to a powershell setting? Maybe try setting the execution policy to “Bypass” to see if that’s where the problem is? (http://technet.microsoft.com/en-us/library/hh849812.aspx)

    #9782
    Nico Reyserhove
    Participant

    Thank you for the prompt response. Issue was indeed NOT batchpatch related but related to the powercli commands I used to connect to several vcenter serves. Script has been changed and all seems to be working.

    Txs !

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.