VMware Cloud Community
stuartgmilton
Enthusiast
Enthusiast

Does Invoke-VMScript work with Centos???

Hi Guys,

I'm running PowerCLI 5.5R2 and am having an issue running Invoke-VMScript.  I've tried LucD script from here but I'm not sure if its outdated now?

When I run the function on a VM with Guest OS Centos6.5, the SupportedOS flag returns false.  The exact OSType returned is other26xLinux64Guest


Before I was running this test script, I was running;

Invoke-VMScript  -VM $vm -HostCredential $HC -GuestCredential $GC -ScriptType Bash -ScriptText $text


And this returned;


Invoke-VMScript : 02/07/2014 09:13:26    Invoke-VMScript        While performing operation 'Connect to host service 'https://[FQDN]/sdk' at port 902' the following error occured: 'Insufficient permissions in the host operating system'

At C:\mcafee.ps1:36 char:17

+     Invoke-VMScript <<<<   -VM $vm -HostCredential $HC -GuestCredential $GC -ScriptType Bash -ScriptText $text

    + CategoryInfo          : OperationStopped: (:) [Invoke-VMScript], VimException

    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_VixWaitForJob_VixErr   or,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Any help would be appreciated.

Stuart

0 Kudos
8 Replies
LucD
Leadership
Leadership

I suspect you might be missing the VirtualMachine.GuestOperations.Modify and/or VirtualMachine.GuestOperations.Execute privileges.


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

0 Kudos
stuartgmilton
Enthusiast
Enthusiast

Where would I confirm this LucD?

0 Kudos
LucD
Leadership
Leadership

Check the permissions on the target VM, and find the Principal under which your permission is defined.

When you have that, find the Role, and then check the privileges assigned to that role.

The following will return $true if you have the required rights on the VM

$vm = Get-VM MyVM

$authMgr = Get-View AuthorizationManager
$role = $authMgr.RoleList | where {$vm.ExtensionData.EffectiveRole -eq $_.RoleId}
$privilegesAssigned = $role.Privilege -contains "VirtualMachine.GuestOperations.Modify" -and
 
$role.Privilege -contains "VirtualMachine.GuestOperations.Execute"
$privilegesAssigned


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

0 Kudos
stuartgmilton
Enthusiast
Enthusiast

Yep, so it returns false.

I was told I had Administrator rights, so I'd like to know where I can add these I guess...

Thanks again by the way, very helpful!

0 Kudos
LucD
Leadership
Leadership

Doesn't look like it, I'm afraid :smileycry:

You can use the Set-VIPermission cmdlet to assign permissions, through the Role parameter, to a specific Principal.

But are you sure you have the required privileges to change permissions ?

You can do this through the Permissions tab in the vSphere client as well of course.


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

0 Kudos
stuartgmilton
Enthusiast
Enthusiast

I'm guessing not then.

Set-VIPermission : Cannot bind parameter 'Permission'. Cannot convert the "VirtualMachine.GuestOperations.Execute" value of type "System.String" to type "VMware.VimAutomation.ViCore.Types.V1.PermissionManagement.Permission".

0 Kudos
LucD
Leadership
Leadership

I'm afraid it doesn't work like that.

You assign a role for a principal to an entity.

For example (provided you already have a permission on the entity):

Get-VIPermission -Entity (Get-VM -Name MyVM) -Principal "youraccount" |

Set-VIPermission  -Role (Get-VIRole -Name Administrator)

If there is no permission yet, you will have to use the New-ViPermission cmdlet.

But watch out, you can have a permission higher up in the tree structure.

Perhaps you should talk to your vSphere admin first


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

0 Kudos
stuartgmilton
Enthusiast
Enthusiast

Hi LucD,

Sorry busy day, I have been into vSphere looking at the Administrator role, which I belong to.  It looks like it has everything?

I went to Home > Administration > Roles > [Our Server]

RIght clicked Administrator and Edit - All boxes are checked.

Now I am confused!

Stuart

0 Kudos