Skip to content

ecsousa/PSSudo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

PSSudo

Note: I will no longer enhance this module. I recommed using gsudo instead, which provide a much better solution.

PowerShell module that provides Start-Elevated function: it will execute the provided command line with elevated privileges. This module is able to handle the following argument types:

  • Application
  • Cmdlet
  • Function
  • PowerShell Script
  • Script Block
  • Alias (For Alias, PSSudo will try to resolve as one of the other types above)

This function is aliased as sudo

Note: When using Cmdlets, Functions or Scripts, PowerShell will resolve variable arguments before passing them to the Start-Elevated function. For most situations that would be OK. But there is a few exceptions. For instance, in the following command:

sudo Set-MpPreference -DisableRealtimeMonitoring $False

PowerShell would resolve $False to 'False' before executing Start-Elevated. Then, the following block would be executed in the elevated PowerShell:

Set-MpPreference -DisableRealtimeMonitoring False

This will throw an error, because PowerShell is not able to implicitly convert the 'False' string into a Boolean type.

For such cases, you could execute:

sudo Set-MpPreference -DisableRealtimeMonitoring 0 (As PowerShell converts zero into $False)

Or use a Script Block:

sudo { Set-MpPreference -DisableRealtimeMonitoring $False }

Installing

Windows 10 users:

Install-Module PSSudo -Scope CurrentUser

Otherwise, if you have PsGet installed:

Install-Module PSSudo

Or you can install it manually coping PSSudo.psm1 to your modules folder (e.g. $Env:USERPROFILE\Documents\WindowsPowerShell\Modules\PSSudo\)

About

Fancy script to execute things elevated

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •