mkellerman / Invoke-CommandAs

Invoke Command As System/Interactive/GMSA/User on Local/Remote machine & returns PSObjects.
https://www.powershellgallery.com/packages/Invoke-CommandAs/
MIT License
457 stars 70 forks source link

Erro running RunElevated parameter #42

Closed vandreytrindade closed 4 years ago

vandreytrindade commented 4 years ago

Hi! I was testing your module and the parameter RunElevated doesn't work as expected (at least I think). What I've tried:

$PSsession = Enter-PSSession "COMPUTER"
$ScriptBlock = { [System.Security.Principal.Windowsidentity]::GetCurrent() }
Invoke-CommandAs -Session $PSSession -ScriptBlock { Get-Process } -AsSystem -RunElevated

It throws this error:

O conjunto de parâmetros não pode ser resolvido usando os parâmetros nomeados especificados.
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-ScheduledTask
    + PSComputerName        : EST001926

PowerShell version: 5.1.18362.145 (Windows 10 Pro latest version)

mkellerman commented 4 years ago

I believe ruining as SYSTEM is already elevated. Please try doing this manually as a scheduled task on the box itself.

vandreytrindade commented 4 years ago

Yes! You're totally right! Thanks! Maybe it will be good to correct that part of the text in this session: "Use -ComputerName/Credential or -Session to authenticate"

mkellerman commented 4 years ago

I haven’t had the opportunity to delve into the obscure powershell error messages. Lol you’re more than welcome to provide suggestion and do a PR for me to review. Anything that can make this script better is great!

vandreytrindade commented 4 years ago

There was no examples on the help file so I changed only the text. Thanks a lot! Great work!