VMware Cloud Community
GovindaG
Contributor
Contributor

invoke-script permission error

Hi, while i am trying to use the invoke script, getting permission errors.

Error:

====

Invoke-VMScript : 9/23/2011 1:01:39 PM    Invoke-VMScript        Permission to perform this operation was denied.   
At C:\Documents and Settings\gajulg\Local Settings\Temp\f37b4ac0-779c-4c24-a8db-328d1136ec70.ps1:14 char:22
+ $vm | Invoke-VMScript <<<<  -HostCredential $hc -GuestCredential $gc $ifconfig
    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], NoPermission
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Invoke-VMScript : 9/23/2011 1:01:41 PM    Invoke-VMScript        Permission to perform this operation was denied.   
At C:\Documents and Settings\gajulg\Local Settings\Temp\f37b4ac0-779c-4c24-a8db-328d1136ec70.ps1:15 char:22
+ $vm | Invoke-VMScript <<<<  -HostCredential $hc -GuestCredential $gc $route
    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], NoPermission
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Scrip:

$hc = Get-Credential
$gc = Get-Credential
foreach ($a in $ips){
$netmask = "255.255.255.0"
$ip1= $a.Ip1
$gw1=$a.gw1
$vmname = $a.Vmname
$vm = Get-VM $vmname
$ifconfig = "ifconfig eth0 $ip1 netmask 255.255.255.0"
$route = "route add default gw $gw1"
Write-Host $vm
$vm | Invoke-VMScript -HostCredential $hc -GuestCredential $gc $ifconfig
$vm | Invoke-VMScript -HostCredential $hc -GuestCredential $gc $route
}

Reply
0 Kudos
34 Replies
LucD
Leadership
Leadership

Which PowerCLI version are you using ?

Get-PowerCLIVersion

Are all the requirements listed under Invoke-VMScript  fullfilled ?

With the latest PowerCLI version you normally don't need the HostCredential anymore.


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

Reply
0 Kudos
GovindaG
Contributor
Contributor


PowerCLI Version
----------------
   VMware vSphere PowerCLI 5.0 build 435427
---------------
Snapin Versions
---------------
   VMWare AutoDeploy PowerCLI 5.0 build 575
   VMWare ImageBuilder PowerCLI 5.0 build 575
   VMware License PowerCLI 5.0 build 395016
   VMWare vSphere PowerCLI 5.0 build 435427

Yes, all the requirements are fulfilled

Reply
0 Kudos
GovindaG
Contributor
Contributor

Just tried without host credentials. still the same issue.

Invoke-VMScript : 9/23/2011 2:00:15 PM    Invoke-VMScript        Permission to perform this operation was denied.   
At C:\Documents and Settings\gajulg\Local Settings\Temp\f37b4ac0-779c-4c24-a8db-328d1136ec70.ps1:14 char:22
+ $vm | Invoke-VMScript <<<<  -GuestCredential $gc $ifconfig
    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], NoPermission
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Invoke-VMScript : 9/23/2011 2:00:18 PM    Invoke-VMScript        Permission to perform this operation was denied.   
At C:\Documents and Settings\gajulg\Local Settings\Temp\f37b4ac0-779c-4c24-a8db-328d1136ec70.ps1:15 char:22
+ $vm | Invoke-VMScript <<<<  -GuestCredential $gc $route
    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], NoPermission
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Reply
0 Kudos
GovindaG
Contributor
Contributor

thought of trying with the simple command, even that fails too.

the script :


$gc = Get-Credential
get-vm intmsgprf04 | Invoke-VMScript -ScriptText "ls -lrt" -GuestCredential $gc

Errors :

Invoke-VMScript : 9/23/2011 2:09:11 PM    Invoke-VMScript        Permission to perform this operation was denied.   
At C:\Documents and Settings\gajulg\Local Settings\Temp\fea83e66-65b8-4787-8134-96f8af09f0ce.ps1:3 char:37
+ get-vm intmsgprf04 | Invoke-VMScript <<<<  -ScriptText "ls -lrt" -GuestCredential $gc
    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], NoPermission
    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.InvokeVmScript

Reply
0 Kudos
LucD
Leadership
Leadership

Which Linux distribution are you running inside the guest ?

And is it a 32-bit version ?


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

Redhat 5.6 - its a 64 bit OS

Reply
0 Kudos
LucD
Leadership
Leadership

Do you run the script from the 32-bit version of PowerCLI ?

On 64-bit Windows systems you will see 2 PowerCLI entries (32- and 64-bit) in the Start folder.


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

Thanks for the reply, I have only one PowerCLI  entry under VMware Folder in start Menu,

this  used to work with PowerCLI 4.1, i recently upgraded to latest version of Powercli, and this is where I am.

is it that i am running 32 bit Powercli ? how can i check that?

Reply
0 Kudos
LucD
Leadership
Leadership

If you only see 1 entry, you're most probably running the script from a 32-bit Windows version.


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

Right, I am having Winxp 32 -bit os from where this script is being run,

is it that this will not work from 32-bit OS ?

Reply
0 Kudos
LucD
Leadership
Leadership

No, in fact Invoke-VMScript will only work from a 32-bit PowerShell engine.

Hence my question.


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

Thanks Luc,

to  let you know, i tried the same on differect VC, it works fine, but on this VC it does not work.

Thanks,

Reply
0 Kudos
LucD
Leadership
Leadership

That seems to indicate that the permissions are not correct on that specific VC.


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

The Difference is this is hosted on VSphere 5 hosts , where the one which works has vsphere 4.1 esx hosts. 

Reply
0 Kudos
GovindaG
Contributor
Contributor

The Access permissions are same on both the VC's and the port 902 is open on these ESXs.

what am i missing 😞

Reply
0 Kudos
LucD
Leadership
Leadership

I have the impression you might have stumbled upon a "feature".

Perhaps someone from the PowerCLI Dev Team could comment ?


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

Lookd like I am not even able to do the Get-VMGuestNetworkInterface

Get-VMGuestNetworkInterface : 9/23/2011 2:46:23 PM Get-VMGuestNetworkInterface Permission to perform this operation was denied.

At C:\Documents and Settings\gajulg\Local Settings\Temp\7ffebf34-827a-4f11-8407-e91481857069.ps1:3 char:36

+ $nic1 = Get-VMGuestNetworkInterface <<<< -VM intcacprf04 -GuestCredential $GuestCred |where{$_.Name -eq "eth0"}

+ CategoryInfo : NotSpecified: (Smiley Happy , NoPermission

+ FullyQualifiedErrorId : Client20_VmGuestServiceImpl_RunScriptInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVmGuestNetworkInterface

Reply
0 Kudos
LucD
Leadership
Leadership

I think that this is normai, since all these cmdlets use the same VIX interface.

You could check the VIX version on your XP station.

I normally check the File Version property of the VixCOM.dll file.

You should see version 1.10.0.12331


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

Reply
0 Kudos
GovindaG
Contributor
Contributor

any more inputs on this issue?

Reply
0 Kudos