Invoke-VMScript: Permission to perform this operation was denied.

During the process of creating an automation tool for a clent, I needed to run few scripts inside the guest virtual machines. To accomplsh the task Invoke-VMscript was a perfect candidate. Invoke-VMScript cmdlet runs a script in the guest OS of each of the specified virtual machines. For more details about the cmdlet, please refer to the link:

However, once tried to run the cmdlet, it failed with the below error:

Invoke-VMScript : YYYY/MM/DD HH:MM:SS AM Invoke-VMScript Permission to perform this operation was denied. Required
privilege ‘VirtualMachine.GuestOperations.Modify’ on managed object with id ‘VirtualMachine’.
At line:2 char:1
+ Invoke-VMScript -VM “VM NAME” -ScriptText “dir” -GuestCredential $guest …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-VMScript], NoPermission
+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Invo


For the user running the cmdlet, you need to allow access to the Guest Operations priviliges in VCenter as illustrated below:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s