Skip to content

Instantly share code, notes, and snippets.

View Warrenn's full-sized avatar

Warrenn Enslin Warrenn

  • Busyweb
  • South Africa
View GitHub Profile
@Warrenn
Warrenn / Invoke-ElevatedCommand.ps1
Created September 23, 2015 14:52 — 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