McKenning
Contributor
Contributor

Permissions to invoke script remotely

I've written a script that will copy a .ps1 file to a VM and then invoke that script. I can run this script successfully if I am logged on locally to the vCenter server and remotely to vCenter servers that I build and am Administrator on. However, there is a vCenter we use for hosted customers that I am not Administrator on and the script fails if I run it remotely (from any server that is not the vCenter server). My question is, what permissions do I lack in vCenter to invoke a script from a remote server? I would like to request these permissions from the internal group responsible for this vCenter server.

Code snippet:

# Copy configuration files and execute the configuration

Get-Item ("$pathRoot" + "$vmname\*.*") | Copy-VMGuestFile -Destination "C:\localfolder\" -VM $vmname -LocalToGuest -GuestUser "$vmname\$vmAdmin" -GuestPassword $vmAdminPassword -Force:$true

Copy-VMGuestFile -Source ("$pathRoot" + "config" + $os + ".ps1") -Destination "C:\localfolder\" -VM $vmname -LocalToGuest -GuestUser "$vmname\$vmAdmin" -GuestPassword $vmAdminPassword -Force:$true

$cmd1 = ('Powershell.exe ' + 'C:\localfolder\' + 'config' + $os + '.ps1')

Invoke-VMScript -VM $vmname -GuestUser $vmAdmin -GuestPassword $vmAdminPassword -ScriptText $cmd1 -ScriptType PowerShell

Error returned on Copy:

Copy-VMGuestFile : 10/5/2015 11:21:57 AMCopy-VMGuestFileUnable to connect to the remote server

At S:\scripts\HNSDeployment\customizeVMs.ps1:190 char:43

+Get-Item ("$pathRoot" + "$vmname\*.*") | Copy-VMGuestFile -Destination "C:\loca ...
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo  : NotSpecified: (:) [Copy-VMGuestFile], ViError
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_UploadFileToGuest_UploadError,VMware.VimAutomation.ViCore.Cm

   dlets.Commands.CopyVMGuestFile

Error returned on InvokeScript:

Invoke-VMScript : 10/5/2015 11:33:07 AMInvoke-VMScript   The guest operations agent could not be contacted.

At S:\scripts\customizeVMs.ps1:194 char:2

+Invoke-VMScript -VM $vmname -GuestUser $vmAdmin -GuestPassword $vmPassword -Scr ...
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo     : NotSpecified: (:) [Invoke-VMScript], GuestOperationsUnavailable
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_GetProcessOutputInGuest_ViError,VMware.VimAutomation.ViCore.

   Cmdlets.Commands.InvokeVmScript

This behavior is consistent across OS platforms and PowerCLI versions from 5.0U1 to 6.0U2

McKenning VCP5-DCV
Tags (1)
0 Kudos
2 Replies
LucD
Leadership
Leadership

I suspect you need at least the privileges listed here

Get-VIPrivilege -Id VirtualMachine.GuestOperations*


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

0 Kudos
McKenning
Contributor
Contributor

Thanks, Luc. I've submitted that list to the powers that be. I'll reply if that works.

McKenning VCP5-DCV
0 Kudos