Automation

 View Only
  • 1.  Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Jan 03, 2014 07:41 AM

    I have been doing a lot of work with the Invoke-VMScript command and most commands run fine on the target VM as long as you are doing it as a domain admin. However, today I came across a command that will not run through Invoke-VMScript. I am trying to remotely enable PowerShell Remoting using the "Enable-PSRemoting -Force" command and I keep getting an access denied.

    Does anyone know a trick to get this command to run without getting access denied? This is the first time I have come across a command I could not get to run as domain admin?



  • 2.  RE: Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Jan 03, 2014 10:23 AM

    The PowerShell Team listed a number of possible causes for this in their Enable-PSRemoting post.

    Areany of these applicable to this ?



  • 3.  RE: Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Jan 04, 2014 04:14 AM

    The target vm is connected to the domain. The user I am using invoke-vmscript with is also a domain admin and I added him to the local admin group by itself just to make sure and still nothing works. If I use the local admin with -GuestUser and -GuestPassword I get it to work. Why don't users domain admins work since they are in the local admin group?

    Also I if use my domain admin with -GuestUser and -GuestPassword, I do not get access denied but the error about needing to run the powershell command elevated.

    Any ideas?



  • 4.  RE: Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Jan 04, 2014 07:29 AM

    I have been trying to get to this work all night and all I can figure out is that domain users like the domain admins group that are added to the local admin groups do not behave the same way as a true local admin. Is that normal?



  • 5.  RE: Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Jan 05, 2014 10:08 AM

    Did you already try the function Andre has in his Remote use of VMware.View.Broker PowerCLI post ?



  • 6.  RE: Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Jan 05, 2014 08:54 PM

    I am trying to do this without disabling UAC.



  • 7.  RE: Invoke-VMScript Enable-PSRemoting Access Denied

    Posted Nov 06, 2014 04:44 PM

    Here is what I did:

    $user='saveTheForest\adminuser'

    $pwd='Plant@Tree'

    $vm='RAIN4EST002'

    $cm='command you want to test'

    Invoke-VMScript -ScriptType bat -Vm $vm -ScriptText $cm  -GuestUser "$usr"  -GuestPassword "$pwd"

    and received access denid from the command.

    Then I used PSCredential object ( -GuestCredential $cre) instead of plain username and password ( -GuestUser "$usr"  -GuestPassword "$pwd"), and all went fine:

    $secpwd=ConvertTo-SecureString $pwd -AsPlainText -Force

    $cred = New-Object System.Management.Automation.PSCredential ($user,  $secpwd)

    Invoke-VMScript -ScriptType bat -Vm $vm -ScriptText $cm -GuestCredential $cred

    Let me know it this helps.... This might have to do with how you authenticate on the domain.

    István