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

Add '-UseSSL' Parameter #23

Closed adilio closed 5 years ago

adilio commented 5 years ago

In our Production environment, we have set winrm quickconfig -transport:https, in order to only enable the HTTPS WSMan listener (cert-based transport).

As such, when running, Invoke-Command, we must specify the -UseSSL parameter.

It would be awesome if we could also use a similar -UseSSL parameter in Invoke-CommandAs, as well.

Currently, we can do the following:

$Sess = New-PSSession -ComputerName FQDN.ubc.ca  -UseSSL
Invoke-CommandAs -Session $Sess -ScriptBlock { Get-Process } -AsSystem

This would just mean one less step on instantiating the PSSession.

Merci beaucoup!

mkellerman commented 5 years ago

I've just pushed the changes to master. Can you pull a copy from GitHub and test? I'm now replicating ALL parameters from Invoke-Command.

adilio commented 5 years ago

It works!

Tested on:

Side-note: I did get the error:

Invoke-CommandAs : A parameter cannot be found that matches parameter name 'RunElevated'.

Works fine when I remove that parameter. Is -RunElevated now deprecated, or just not needed with -AsSystem?

mkellerman commented 5 years ago

Yeah, Im running all commands as elevated. :/

No sure if that parameter is ever NOT going to be used.

What are your thoughts?

adilio commented 5 years ago

Makes sense to me, running as elevated is kinda the whole point of the module.

LGTM!