BatchPatch Forums Home › Forums › BatchPatch Support Forum › Lauch a VMware powercli script from 'local command 1'
- This topic has 2 replies, 2 voices, and was last updated 10 years, 9 months ago by Nico Reyserhove.
-
AuthorPosts
-
February 28, 2014 at 1:22 pm #8663Nico ReyserhoveParticipant
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 ?
February 28, 2014 at 5:29 pm #9775dougModeratorHi 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)
March 11, 2014 at 10:26 am #9782Nico ReyserhoveParticipantThank 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 !
-
AuthorPosts
- You must be logged in to reply to this topic.