none
invoke command elevated on remote computer RRS feed

  • Question

  • I am attempting to run the blow command on a remote server. When I do I can see the remote server’s processes and sure enough Cleanmgr launces but nothing else.  I see it running and it will simply run all day and do nothing if I do not stop it through task manager. I am guessing it is because it is not launching elevated but really I am not sure this is the case. 

    How can I launch this elevated on the remote computer?

    Thanks

    Invoke-Command -ComputerName $DC -ScriptBlock {cmd.exe /C c:\windows\system32\Cleanmgr.exe /VERYLOWDISK }


    Lishron

    Thursday, February 4, 2016 6:59 PM

Answers

  • Check the help on Invoke-Command on using the -Credential parameter to pass an account to run the commands under. 
    • Marked as answer by Lishron Friday, February 5, 2016 2:39 PM
    Thursday, February 4, 2016 8:01 PM

All replies

  • Check the help on Invoke-Command on using the -Credential parameter to pass an account to run the commands under. 
    • Marked as answer by Lishron Friday, February 5, 2016 2:39 PM
    Thursday, February 4, 2016 8:01 PM
  • many commands cannot be run remotely.  They require local activation.

    \_(ツ)_/

    • Proposed as answer by jrv Friday, February 5, 2016 1:35 PM
    Thursday, February 4, 2016 9:39 PM
  • Good call thanks.

    Still same results.

    Any other suggestions and thank you again.

    $Username = 'Labadmin'
    $Password = 'Password1'
    $pass = ConvertTo-SecureString -AsPlainText $Password -Force
    $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
    #

    #

    Invoke-Command -ComputerName $DC -credential $Cred -ScriptBlock {regedit /s C:\Windows\Temp\sageset11.reg }
    Invoke-Command -ComputerName $DC -credential $Cred -ScriptBlock {cmd.exe /C c:\windows\system32\Cleanmgr /sageset:11 }
    ##  cmd.exe /C c:\windows\system32\Cleanmgr.exe /VERYLOWDISK }


    Lishron

    Friday, February 5, 2016 1:25 PM
  • IT WORKED!!!!!!

    I just had to use the Credential parameter like you said.  

    What was throwing me i had a typo and was running sageset:11 and not sagerun:11

    Thank you!!



    Lishron

    Friday, February 5, 2016 2:42 PM