Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand



Downloads of v 1.2.1-alpha11:


Last Update:

12 Apr 2022

Package Maintainer(s):

Software Author(s):

  • Gerardo Grignoli


sudo for windows run elevated user command runas powershell wsl

gsudo - a sudo for windows

This is a prerelease version of gsudo - a sudo for windows.

  • 1
  • 2
  • 3

1.2.1-alpha11 | Updated: 12 Apr 2022



Downloads of v 1.2.1-alpha11:



Software Author(s):

  • Gerardo Grignoli

gsudo - a sudo for windows 1.2.1-alpha11

This is a prerelease version of gsudo - a sudo for windows.

  • 1
  • 2
  • 3

Some Checks Have Failed or Are Not Yet Complete

Not All Tests Have Passed

Validation Testing Passed

Verification Testing Passed


Scan Testing Resulted in Flagged as a Note:

At least one file within this package has greater than 0 detections, but less than 5

Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install gsudo - a sudo for windows, run the following command from the command line or from PowerShell:


To upgrade gsudo - a sudo for windows, run the following command from the command line or from PowerShell:


To uninstall gsudo - a sudo for windows, run the following command from the command line or from PowerShell:


Deployment Method:


This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)

2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade gsudo -y --source="'INTERNAL REPO URL'" --version="'1.2.1-alpha11'" --prerelease [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:

choco upgrade gsudo -y --source="'INTERNAL REPO URL'" --version="'1.2.1-alpha11'" --prerelease

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0

Exit $exitCode

- name: Install gsudo
    name: gsudo
    version: '1.2.1-alpha11'
    state: present
    allow_prerelease: yes

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.

chocolatey_package 'gsudo' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '1.2.1-alpha11'
  options  '--prerelease'

See docs at https://docs.chef.io/resource_chocolatey_package.html.

cChocoPackageInstaller gsudo
    Name        = "gsudo"
    Version     = "1.2.1-alpha11"
    Source      = "INTERNAL REPO URL"
    chocoParams = "--prerelease"

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.

package { 'gsudo':
  ensure          => '1.2.1-alpha11',
  install_options => ['--prerelease'],
  provider        => 'chocolatey',
  source          => 'INTERNAL REPO URL',

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.

4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved as a trusted package on 13 Apr 2022.


gsudo allows to run commands with elevated permissions within the current console.
It is a sudo equivalent for Windows, with a similar user-experience as the original *nix sudo.

Elevated commands are shown in the caller (non-elevated) console, no switching to another console required.



gsudo [command] [arguments]
Executes the specified command, elevated, and returns.


gsudo notepad c:\Windows\System32\drivers\etc\hosts
gsudo cmd

md5: 1BAD7FA956379198597DEFEDFE9FA13A | sha1: 15758C89B20253CEA56D7D0B6CA44D12BDFDE552 | sha256: 30FB06A29969B2CEC53FBA7D4BEBE0F58CA887CD30F11AE1B2FD1B4F9988AB66 | sha512: 96826D7D6DE437348C90627872379571AB3B2515B77FEEF2B4EBF0EC0FCDBA24DCB8AF80E59BC29AEDA3A82D5CFC4B2ECBE62A1F17C72F6DBE6E59C80FBC31A9
# Module manifest for module 'gsudoModule'
# Generated by: Gerardo Grignoli
# Generated on: 2/1/2022


# Script module or binary module file associated with this manifest.
RootModule = 'gsudoModule.psm1'

# Version number of this module.
ModuleVersion = "1.2.1"

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'c50a89c0-75c0-4b08-8dac-473404b73379'

# Author of this module
Author = 'Gerardo Grignoli'

# Company or vendor of this module
CompanyName = 'gsudo'

# Copyright statement for this module
Copyright = '(c) Gerardo Grignoli. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''

# Minimum version of the PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = 'gsudo', 'invoke-gsudo'

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()

# Variables to export from this module
VariablesToExport = 'gsudoVerbose', 'gsudoLoadProfile'

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = @()

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

    PSData = @{

        # Tags applied to this module. These help with module discovery in online galleries.
        # Tags = @()

        # A URL to the license for this module.
        # LicenseUri = ''

        # A URL to the main website for this project.
        # ProjectUri = ''

        # A URL to an icon representing this module.
        # IconUri = ''

        # ReleaseNotes of this module
        # ReleaseNotes = ''

        # Prerelease string of this module
        # Prerelease = ''

        # Flag to indicate whether the module requires explicit user acceptance for install/update/save
        # RequireLicenseAcceptance = $false

        # External dependent modules of this module
        # ExternalModuleDependencies = @()

    } # End of PSData hashtable

} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''


$c = @("function Invoke-Gsudo {")
$c += (Get-Content "$PSScriptRoot\Invoke-Gsudo.ps1")
$c += "}"
iex ($c -join "`n" | Out-String)

function gsudo {
	$invocationLine = $MyInvocation.Line -replace "^$($MyInvocation.InvocationName)\s+" # -replace '"','""'

	if ($invocationLine -match "(^| )!!( |$)")
		$i = 0;
		do {
			$c = (Get-History | Select-Object -last 1 -skip $i).CommandLine
		} while ($c -eq $MyInvocation.Line -and $c)
		if ($c) { 
			if ($gsudoVerbose) { Write-verbose "Elevating Command: '$c'" -Verbose}
			gsudo.exe $c 
		else {
			throw "Failed to find last invoked command in Powershell history."
	elseif($myinvocation.expectingInput) {
		$input | & gsudo.exe @args 
	else { 
		& gsudo.exe @args 


# On your $PROFILE set $gsudoLoadProfile=$true to make invoke-gsudo load your profile. 
# Warning: If you do, then do not write to console/Out on your $profile or else that lines will appear in your Invoke-gsudo result.

Export-ModuleMember -function Invoke-Gsudo, gsudo -Variable gsudoVerbose, gsudoLoadProfile
Executes a ScriptBlock in a new elevated instance of powershell, using `gsudo`.

Serializes a scriptblock and executes it in an elevated powershell. 
The ScriptBlock runs in a different process, so it can´t read/write variables from the invoking scope.
If you reference a variable in a scriptblock using the `$using:variableName` it will be replaced with it´s serialized value.
The elevated command can accept input from the pipeline with $Input. It will be serialized, so size matters.
The script result is serialized, sent back to the non-elevated instance, and returned.
Optionally you can check for "$LastExitCode -eq 999" to find out if gsudo failed to elevate (UAC popup cancelled) 

.PARAMETER ScriptBlock
Specifies a ScriptBlock that will be run in an elevated PowerShell instance. '
e.g. { Get-Process Notepad }

.PARAMETER ArgumentList
An list of elements that will be accesible inside the script as: $args

A test mode where the command is executed out-of-scope but without real elevation: The serialization/marshalling is still done.

You can pipe any object to Invoke-Gsudo. It will be serialized and available in the userScript as $Input.

Whatever the scriptblock returns. Use explicit "return" in your scriptblock. 

PS> Get-Process notepad | Invoke-gsudo { Stop-Process }

PS> Invoke-gsudo { return Get-Content 'C:\My Secret Folder\My Secret.txt'}

PS> $a=1; $b = Invoke-gsudo { $using:a+10 }; Write-Host "Sum returned: $b";
Sum returned: 11


[CmdletBinding(DefaultParameterSetName = 'None')]
    # The script block to execute in an elevated context.
    [Parameter(Mandatory = $true, Position = 0)]

    # Optional argument list for the program or the script block.
    [Parameter(Mandatory = $false, Position = 1)]


	$LoadProfile = $false,
	#test mode
	$NoElevate = $false

# Replaces $using:variableName with the serialized value of $variableName.
# Credit: https://stackoverflow.com/a/60583163/97471
Function Serialize-Scriptblock
    $rxp = '(?<!`)\$using:(?<var>\w+)'
    $ssb = $Scriptblock.ToString()
    $cb = {
        $v = (Get-Variable -Name $args[0].Groups['var'] -ValueOnly)
		if ($v -eq $null)
		{ '$null' }
			"`$([System.Management.Automation.PSSerializer]::Deserialize([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('{0}'))))" -f [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes([System.Management.Automation.PSSerializer]::Serialize($v)))
    $sb = [RegEx]::Replace($ssb, $rxp, $cb, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase);
	return $sb;

Function Deserialize-Scriptblock

$expectingInput = $myInvocation.expectingInput;
$debug = if ($PSBoundParameters['Debug']) {$true} else {$false};
$userScriptBlock = Serialize-Scriptblock $ScriptBlock
$InputArray = $Input
$location = (Get-Location).Path;

if($PSBoundParameters["ErrorAction"]) {
	#Write-Verbose -verbose "Received ErrorAction $($PSBoundParameters["ErrorAction"])"
	$errorAction = $PSBoundParameters["ErrorAction"] | Out-String
} else {
	#Write-Verbose -verbose "ErrorActionPreference is $ErrorActionPreference"
	$errorAction = $ErrorActionPreference | Out-String

$remoteCmd = Serialize-Scriptblock {
	$InputObject = $using:InputArray;
	$argumentList = $using:ArgumentList;
	$expectingInput = $using:expectingInput;
	$sb = [Scriptblock]::Create($using:userScriptBlock);
	Set-Location $using:location;

	if ($expectingInput) { 
		try { 
			($InputObject | Invoke-Command $sb -ArgumentList $argumentList)
		} catch {throw $_} 
	} else { 
			(Invoke-Command $sb -ArgumentList $argumentList)
		} catch {throw $_} 

if ($Debug) {
	Write-Debug "User ScriptBlock : $userScriptBlock"
	Write-Debug "Full Script to run on the isolated instance: { $remoteCmd }" 

if($NoElevate) { 
	# We could invoke using Invoke-Command:
	#		$result = $InputObject | Invoke-Command (Deserialize-Scriptblock $remoteCmd) -ArgumentList $ArgumentList
	# Or run in a Job to ensure same variable isolation:

	$job = Start-Job -ScriptBlock (Deserialize-Scriptblock $remoteCmd) -errorAction $errorAction | Wait-Job; 
	$result = Receive-Job $job -errorAction $errorAction
} else {
	$pwsh = ("""$([System.Diagnostics.Process]::GetCurrentProcess().MainModule.FileName)""") # Get same running powershell EXE.
	if ($host.Name -notmatch 'consolehost') { # Workaround for PowerShell ISE, or PS hosted inside other process
		if ($PSVersionTable.PSVersion.Major -le 5) 
			{ $pwsh = "powershell.exe" } 
			{ $pwsh = "pwsh.exe" }
	$windowTitle = $host.ui.RawUI.WindowTitle;

	$dbg = if ($debug) {"--debug "} else {" "}
	$NoProfile = if ($gsudoLoadProfile -or $LoadProfile) {""} else {"-NoProfile "}
	$arguments = "-d $dbg--LogLevel Error $pwsh -nologo $NoProfile-NonInteractive -OutputFormat Xml -InputFormat Text -encodedCommand IAAoACQAaQBuAHAAdQB0ACAAfAAgAE8AdQB0AC0AUwB0AHIAaQBuAGcAKQAgAHwAIABpAGUAeAAgAA==".Split(" ")

	# Must Read: https://stackoverflow.com/questions/68136128/how-do-i-call-the-powershell-cli-robustly-with-respect-to-character-encoding-i?noredirect=1&lq=1
	$result = $remoteCmd | & gsudo.exe $arguments *>&1
	$host.ui.RawUI.WindowTitle = $windowTitle;

ForEach ($item in $result)
	if (
	$item.Exception.SerializedRemoteException.WasThrownFromThrowStatement -or
		throw $item
	if ($item -is [System.Management.Automation.ErrorRecord])
		Write-Error $item
		Write-Output $item; 
$ErrorActionPreference = 'Ignore'

if (Get-Process gsudo 2> $null) {	
	if (Get-Command gsudo.exe 2> $null) {
		# Stop any gsudo open cache sessions, if any. 
		gsudo.exe -k 2> $null
		Start-Sleep -Milliseconds 500

$ToolsLocation = Get-ToolsLocation 
if ([System.Environment]::CurrentDirectory -like "$ToolsLocation*") {
	Write-Output -Verbose "Changing directory to $ToolsLocation to ensure successfull install/upgrade."
	Set-Location $ToolsLocation

$ErrorActionPreference = 'Continue'
function Test-IsSymLink([string]$path) {
  $file = Get-Item $path -Force -ea SilentlyContinue
  return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)

Import-Module (Join-Path (Split-Path -parent $MyInvocation.MyCommand.Definition) "Uninstall-ChocolateyPath.psm1")

$ErrorActionPreference = 'Continue'
$ToolsLocation = Get-ToolsLocation 

$bin = "$env:ChocolateyInstall\lib\gsudo\bin\"

############ Clean-up previous versions
if (Test-Path "$bin\sudo.exe")
	Remove-Item "$bin\sudo.exe" 

# Remove from User Path on previous versions ( <= 0.7.1 )
Uninstall-ChocolateyPath $bin 'User'

# Remove from Path on previous versions ( <= 1.0.2 )
Uninstall-ChocolateyPath $bin 'Machine'

if ([System.Environment]::CurrentDirectory -like "$ToolsLocation*") {
	Write-Output -Verbose "Changing directory to $ToolsLocation to ensure successfull install/upgrade."
	Set-Location $ToolsLocation

$TargetDir = ("$ToolsLocation\gsudo\v" + ((Get-Item "$bin\gsudo.exe").VersionInfo.ProductVersion -split "\+" )[0])
$SymLinkDir = "$ToolsLocation\gsudo\Current"

# Add to System Path
mkdir $TargetDir -ErrorAction Ignore
copy "$bin\*" $TargetDir -Exclude *.ignore -Force
Install-ChocolateyPath -PathToInstall $SymLinkDir -PathType 'Machine'

cmd /c mklink "$TargetDir\sudo.exe" "$TargetDir\gsudo.exe" 2>$null

$OldCurrentDir = Get-Item $SymLinkDir -ErrorAction ignore
if ($OldCurrentDir) 

cmd /c mklink /d "$SymLinkDir" "$TargetDir\"

# gsudo powershell module banner.

Write-Output "gsudo successfully installed. Please restart your consoles to use gsudo."

if (Get-Module gsudoModule) {
	"Please restart PowerShell to update PowerShell gsudo Module."
} else {
	& { 
	"PowerShell users: To use enhanced gsudo and Invoke-Gsudo cmdlet, add the following line to your `$PROFILE"
	"  Import-Module '$SymLinkDir\gsudoModule.psd1'"
	"Or run: "
	"  Write-Output `"``nImport-Module '$SymLinkDir\gsudoModule.psd1'`" | Add-Content `$PROFILE"

Import-Module (Join-Path (Split-Path -parent $MyInvocation.MyCommand.Definition) "Uninstall-ChocolateyPath.psm1")

function MarkFileDelete {
	[string] $path

# the code below has been used from
#    https://blogs.technet.com/b/heyscriptingguy/archive/2013/10/19/weekend-scripter-use-powershell-and-pinvoke-to-remove-stubborn-files.aspx
# with inspiration from
#    http://www.leeholmes.com/blog/2009/02/17/moving-and-deleting-really-locked-files-in-powershell/
# and error handling from
#    https://blogs.technet.com/b/heyscriptingguy/archive/2013/06/25/use-powershell-to-interact-with-the-windows-api-part-1.aspx

Add-Type @'
    using System;
    using System.Text;
    using System.Runtime.InteropServices;
    public class Posh
        public enum MoveFileFlags
            MOVEFILE_DELAY_UNTIL_REBOOT         = 0x00000004
        [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
        public static bool MarkFileDelete (string sourcefile)
            return MoveFileEx(sourcefile, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);         
	$deleteResult = [Posh]::MarkFileDelete($path)
    if ($deleteResult) {
        write-Warning "(Delete of $path failed: Will be deleted at next boot.)"
    } else {
		write-Warning "(Error marking $path for deletion at next boot.)"

$installPath = "$(Get-ToolsLocation)\gsudo"
Uninstall-ChocolateyPath "$installPath\Current" 'Machine'


# Delete symlinks in Pwsh 5.
Get-ChildItem $installPath -Recurse |? LinkType -eq 'SymbolicLink'|%{$_.Delete()}
# Delete the rest.
Remove-Item $installPath -Recurse -Force -ErrorAction Ignore
Remove-Item $installPath -Recurse -Force -ErrorAction Ignore

if (Test-Path $installPath) {
	# Files are in use so delete failed.
	# Rename used files and directories. 

    Get-ChildItem $installPath -Recurse -Exclude "*.deleteMe" | Sort-Object -Descending {(++$script:i)} | % { Rename-Item -Path $_.FullName -NewName ($_.Name + ".deleteMe")  ; } *> $NULL
	# Mark remaining for delete after restart.
	Get-ChildItem $installPath -Recurse | % { MarkFileDelete ( $_.FullName) }
	MarkFileDelete ( $installPath );

$ErrorActionPreference = 'Continue'
From: https://opensource.org/licenses/MIT


Copyright 2019 Gerardo Grignoli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

function Uninstall-ChocolateyPath {
**NOTE:** Administrative Access Required when `-PathType 'Machine'.`

This puts a directory to the PATH environment variable.

Looks at both PATH environment variables to ensure a path variable
does not show up on the right PATH.

This command will assert UAC/Admin privileges on the machine if
`-PathType 'Machine'`.

This is used when the application/tool is not being linked by Chocolatey
(not in the lib folder).



.PARAMETER PathToUninstall
The full path to a location to remove / ensure is not in the PATH.

Which PATH to remove from it. If specifying `Machine`, this requires admin
privileges to run correctly.

.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.

Uninstall-ChocolateyPath -PathToUninstall "$($env:SystemDrive)\tools\gittfs"

Uninstall-ChocolateyPath "$($env:SystemDrive)\Program Files\MySQL\MySQL Server 5.5\bin" -PathType 'Machine'






  [parameter(Mandatory=$true, Position=0)][string] $pathToUninstall,
  [parameter(Mandatory=$false, Position=1)][System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User,
  [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments

  Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters
  ## Called from chocolateysetup.psm1 - wrap any Write-Host in try/catch

  $originalPathToUninstall = $pathToUninstall

  $statementTerminator = ";"

  # if the last digit is ;, then we are removing it
  if ($pathToUninstall.EndsWith($statementTerminator)) {
    $pathToUninstall = $pathToUninstall.Substring(0, $pathToUninstall.LastIndexOf($statementTerminator))

  #get the PATH variable
  $envPath = $env:PATH
  if ($envPath.ToLower().Contains($pathToUninstall.ToLower()))
    try {
      Write-Host "PATH environment variable has $pathToUninstall in it. Removing..."
    } catch {
      Write-Verbose "PATH environment variable has $pathToUninstall in it. Removing..."

    $actualPath = Get-EnvironmentVariable -Name 'Path' -Scope $pathType -PreserveVariables

    $actualPath = $actualPath.Replace($pathToUninstall, "")

    while ($actualPath.Contains($statementTerminator + $statementTerminator)) {
      $actualPath = $actualPath.Replace($statementTerminator + $statementTerminator, $statementTerminator)

    if ($pathType -eq [System.EnvironmentVariableTarget]::Machine) {
      if (Test-ProcessAdminRights) {
        Set-EnvironmentVariable -Name 'Path' -Value $actualPath -Scope $pathType
      } else {
        $psArgs = "Uninstall-ChocolateyPath -pathToUninstall `'$originalPathToUninstall`' -pathType `'$pathType`'"
        Start-ChocolateyProcessAsAdmin "$psArgs"
    } else {
      Set-EnvironmentVariable -Name 'Path' -Value $actualPath -Scope $pathType

    #removing it from the local path as well
    $envPSPath = $env:PATH
    $envPSPath = $envPSPath.Replace($pathToUninstall, "")
    while($envPSPath.Contains($statementTerminator + $statementTerminator)) {
      $envPSPath = $envPSPath.Replace($statementTerminator + $statementTerminator, $statementTerminator)
    $env:Path = $envPSPath
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.

1. The embedded files are also available as a release in GitHub.

Please go to releases page

Download same version as this choco package (example for v0.4)

unzip and get hashes
powershell -command Get-FileHash *

2. Get hashes from this choco package. Run:

powershell -command Get-FileHash bin\*

3. The checksums should match the following:
Version Hashes for v1.2.1-alpha11 

Algorithm       Hash                                                                   Path                                                                                                             
---------       ----                                                                   ----                                                                                                             
SHA256          30FB06A29969B2CEC53FBA7D4BEBE0F58CA887CD30F11AE1B2FD1B4F9988AB66       C:\git\gsudo\build\Chocolatey\gsudo\bin\gsudo.exe                                                                
SHA256          E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855       C:\git\gsudo\build\Chocolatey\gsudo\bin\gsudo.exe.ignore                                                         
SHA256          AAC4F3BA327A6D9E8169445932A6A800998C5250E335D515A2D4E9B6F617D966       C:\git\gsudo\build\Chocolatey\gsudo\bin\gsudoModule.psd1                                                         
SHA256          8F560141ED44DCB63C5B7FEF6DC5234F9E6BA9C69007FD2A85EB7E183619F6D6       C:\git\gsudo\build\Chocolatey\gsudo\bin\gsudoModule.psm1                                                         
SHA256          9AF22CB40B5EA60659BC3435507C0E3610BCCFA6EF8D7CC639232E8423D2229D       C:\git\gsudo\build\Chocolatey\gsudo\bin\Invoke-gsudo.ps1                                                         
SHA256          E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855       C:\git\gsudo\build\Chocolatey\gsudo\bin\sudo.exe.ignore                                                          


Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
gsudo - a sudo for windows 2.4.3 22 Tuesday, February 20, 2024 Approved
gsudo - a sudo for windows 2.4.2 21483 Monday, December 18, 2023 Approved
gsudo - a sudo for windows 2.4.1-fixnoninteractive 139 Sunday, October 1, 2023 Approved
gsudo - a sudo for windows 2.4.0 33607 Sunday, August 27, 2023 Approved
gsudo - a sudo for windows 2.3.1-beta 127 Tuesday, August 22, 2023 Approved
gsudo - a sudo for windows 2.3.0 19905 Monday, July 17, 2023 Approved
gsudo - a sudo for windows 2.2.0 1116 Monday, July 17, 2023 Approved
gsudo - a sudo for windows 2.1.0 5224 Sunday, July 9, 2023 Approved
gsudo - a sudo for windows 2.0.10 16508 Sunday, June 4, 2023 Approved
gsudo - a sudo for windows 2.0.9 12147 Tuesday, May 2, 2023 Approved
gsudo - a sudo for windows 2.0.8 2012 Sunday, April 30, 2023 Approved
gsudo - a sudo for windows 2.0.7 1330 Friday, April 28, 2023 Approved
gsudo - a sudo for windows 2.0.6 16094 Friday, March 24, 2023 Approved
gsudo - a sudo for windows 2.0.4 39086 Monday, November 21, 2022 Approved
gsudo - a sudo for windows 2.0.3 1913 Friday, November 18, 2022 Approved
gsudo - a sudo for windows 2.0.2 4843 Thursday, November 10, 2022 Approved
gsudo - a sudo for windows 2.0.1 1616 Tuesday, November 8, 2022 Approved
gsudo - a sudo for windows 2.0.0 2091 Sunday, November 6, 2022 Approved
gsudo - a sudo for windows 2.0.0-preview 159 Sunday, October 23, 2022 Approved
gsudo - a sudo for windows 1.7.1 9251 Sunday, October 16, 2022 Approved
gsudo - a sudo for windows 1.7.0 7667 Wednesday, September 28, 2022 Approved
gsudo - a sudo for windows 1.6.0 4440 Wednesday, September 21, 2022 Approved
gsudo - a sudo for windows 1.5.1 5616 Friday, September 9, 2022 Approved
gsudo - a sudo for windows 1.4.1 2149 Tuesday, September 6, 2022 Approved
gsudo - a sudo for windows 1.4.0 1687 Sunday, September 4, 2022 Approved
gsudo - a sudo for windows 1.3.0 36488 Wednesday, April 13, 2022 Approved
gsudo - a sudo for windows 1.2.1-alpha11 56 Tuesday, April 12, 2022 Approved
gsudo - a sudo for windows 1.2.1-alpha10 58 Tuesday, April 12, 2022 Approved
gsudo - a sudo for windows 1.2.0 6395 Friday, March 25, 2022 Approved
gsudo - a sudo for windows 1.1.1 5006 Saturday, March 12, 2022 Approved
gsudo - a sudo for windows 1.1.0 4558 Sunday, February 27, 2022 Approved
gsudo - a sudo for windows 1.0.2 37276 Wednesday, August 18, 2021 Approved
gsudo - a sudo for windows 1.0.1 4220 Saturday, August 7, 2021 Approved
gsudo - a sudo for windows 0.7.3 14966 Sunday, December 20, 2020 Approved
gsudo - a sudo for windows 0.7.2 6017 Sunday, August 9, 2020 Approved

This package has no dependencies.

Discussion for the gsudo - a sudo for windows Package

Ground Rules:

  • This discussion is only about gsudo - a sudo for windows and the gsudo - a sudo for windows package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or gsudo - a sudo for windows, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus