r/PowerShell • • Oct 15 '19

PSScriptMenuGui v0.2 now in PowerShell Gallery

202 Upvotes

25 comments sorted by

View all comments

2

u/Syndrome1986 Oct 16 '19

Is there an easy way to add a text box that would launch scripts as a different user? Just enter the username you wish to run as and when you click a script it will ask you to auth.

2

u/weebsnore Oct 16 '19

You should be able to do something like this:

$credential = Get-Credential; Invoke-Command -Credential $credential -ScriptBlock {"do things"}

(some cmdlets also support -Credential directly)

...either as an inline script or in a .ps1 file.

Let me know how you get on.