Skip to content

Instantly share code, notes, and snippets.

View JustinBrow's full-sized avatar

Justin JustinBrow

View GitHub Profile
@JustinBrow
JustinBrow / Invoke-ElevatedCommand.ps1
Created February 3, 2019 07:34 — forked from TaoK/Invoke-ElevatedCommand.ps1
Invoke-ElevatedCommand for Administrator-level commands in a common powershell pipeline
Function Invoke-ElevatedCommand {
<#
.DESCRIPTION
Invokes the provided script block in a new elevated (Administrator) powershell process,
while retaining access to the pipeline (pipe in and out). Please note, "Write-Host" output
will be LOST - only the object pipeline and errors are handled. In general, prefer
"Write-Output" over "Write-Host" unless UI output is the only possible use of the information.
Also see Community Extensions "Invoke-Elevated"/"su"
.EXAMPLE