< Back
Remove-SudoPwd
Post
NAME Remove-SudoPwd
SYNOPSIS
Edits /etc/sudoers to allow the specified user to run 'sudo pwsh' without needing to enter a sudo password.
SYNTAX
Remove-SudoPwd -RemoteHostNameOrIP <String> -LocalUserName <String> [-LocalPasswordSS <SecureString>]
[-KeyFilePath <String>] [-DomainUserForNoSudoPwd <String[]>] [-LocalUserForNoSudoPwd <String[]>]
[<CommonParameters>]
Remove-SudoPwd -RemoteHostNameOrIP <String> -DomainUserName <String> [-DomainPasswordSS <SecureString>]
[-KeyFilePath <String>] [-DomainUserForNoSudoPwd <String[]>] [-DomainGroupForNoSudoPwd <String[]>]
[<CommonParameters>]
DESCRIPTION
See SYNOPSIS
PARAMETERS
-RemoteHostNameOrIP <String>
This parameter is MANDATORY.
This parameter takes a string that represents the DNS-resolvable HostName/FQDN or IPv4 Address of the target
Remote Host
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LocalUserName <String>
This parameter is MANDATORY for the Parameter Set 'Local'.
This parameter takes a string that represents the Local User Account on the Remote Host that you are using to
ssh into
the Remote Host. This string must be in format: <RemoteHostName>\\<UserName>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainUserName <String>
This parameter is MANDATORY for the Parameter Set 'Domain'.
This parameter takes a string that represents the Domain User Account on the Remote Host that you are using to
ssh into
the Remote Host. This string must be in format: <DomainShortName>\\<UserName>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LocalPasswordSS <SecureString>
This parameter is MANDATORY for the Parameter Set 'Local'.
This parameter takes a securestring that represents the password for the -LocalUserName you are using to ssh
into the
Remote Host.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainPasswordSS <SecureString>
This parameter is MANDATORY for the Parameter Set 'Domain'.
This parameter takes a securestring that represents the password for the -DomainUserName you are using to ssh
into the
Remote Host.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-KeyFilePath <String>
This parameter is OPTIONAL.
This parameter takes a string that represents the full path to the Key File you are using to ssh into the
Remote Host.
Use this parameter instead of -LocalPasswordSS or -DomainPasswordSS.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainUserForNoSudoPwd <String[]>
This parameter is OPTIONAL.
This parameter takes a string or array of strings that represent Domain Users that you would like to allow to
use
'sudo pwsh' without a password prompt. Each user must be in format: <DomainShortName>\\<UserName>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LocalUserForNoSudoPwd <String[]>
This parameter is OPTIONAL.
This parameter takes a string or array of strings that represent Local Users on the Remote Host that you would
like to
allow to use 'sudo pwsh' without a password prompt. Each user must be in format: <RemoteHostName>\\<UserName>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainGroupForNoSudoPwd <String[]>
This parameter is OPTIONAL.
This parameter takes a string or array of strings that represent Domain Groups that you would like to allow to
use
'sudo pwsh' without a password prompt.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\># Minimal parameters...
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 2 --------------------------
PS C:\\># Remove sudo prompt requirement for multiple Domain Users
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
DomainUserForNoSudoPwd = @('zero\\zeroadmin','zero\\zeroadminbackup')
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 3 --------------------------
PS C:\\># Remove sudo prompt requirement for a Domain Group
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
DomainGroupForNoSudoPwd = @('Domain Admins')
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 4 --------------------------
PS C:\\># Using a local account on the Remote Host...
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
LocalPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 5 --------------------------
PS C:\\># Using an ssh Key File instead of a password...
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
KeyFilePath = $HOME/.ssh/my_ssh_key
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
RELATED LINKS
SYNOPSIS
Edits /etc/sudoers to allow the specified user to run 'sudo pwsh' without needing to enter a sudo password.
SYNTAX
Remove-SudoPwd -RemoteHostNameOrIP <String> -LocalUserName <String> [-LocalPasswordSS <SecureString>]
[-KeyFilePath <String>] [-DomainUserForNoSudoPwd <String[]>] [-LocalUserForNoSudoPwd <String[]>]
[<CommonParameters>]
Remove-SudoPwd -RemoteHostNameOrIP <String> -DomainUserName <String> [-DomainPasswordSS <SecureString>]
[-KeyFilePath <String>] [-DomainUserForNoSudoPwd <String[]>] [-DomainGroupForNoSudoPwd <String[]>]
[<CommonParameters>]
DESCRIPTION
See SYNOPSIS
PARAMETERS
-RemoteHostNameOrIP <String>
This parameter is MANDATORY.
This parameter takes a string that represents the DNS-resolvable HostName/FQDN or IPv4 Address of the target
Remote Host
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LocalUserName <String>
This parameter is MANDATORY for the Parameter Set 'Local'.
This parameter takes a string that represents the Local User Account on the Remote Host that you are using to
ssh into
the Remote Host. This string must be in format: <RemoteHostName>\\<UserName>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainUserName <String>
This parameter is MANDATORY for the Parameter Set 'Domain'.
This parameter takes a string that represents the Domain User Account on the Remote Host that you are using to
ssh into
the Remote Host. This string must be in format: <DomainShortName>\\<UserName>
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LocalPasswordSS <SecureString>
This parameter is MANDATORY for the Parameter Set 'Local'.
This parameter takes a securestring that represents the password for the -LocalUserName you are using to ssh
into the
Remote Host.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainPasswordSS <SecureString>
This parameter is MANDATORY for the Parameter Set 'Domain'.
This parameter takes a securestring that represents the password for the -DomainUserName you are using to ssh
into the
Remote Host.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-KeyFilePath <String>
This parameter is OPTIONAL.
This parameter takes a string that represents the full path to the Key File you are using to ssh into the
Remote Host.
Use this parameter instead of -LocalPasswordSS or -DomainPasswordSS.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainUserForNoSudoPwd <String[]>
This parameter is OPTIONAL.
This parameter takes a string or array of strings that represent Domain Users that you would like to allow to
use
'sudo pwsh' without a password prompt. Each user must be in format: <DomainShortName>\\<UserName>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-LocalUserForNoSudoPwd <String[]>
This parameter is OPTIONAL.
This parameter takes a string or array of strings that represent Local Users on the Remote Host that you would
like to
allow to use 'sudo pwsh' without a password prompt. Each user must be in format: <RemoteHostName>\\<UserName>
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-DomainGroupForNoSudoPwd <String[]>
This parameter is OPTIONAL.
This parameter takes a string or array of strings that represent Domain Groups that you would like to allow to
use
'sudo pwsh' without a password prompt.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\># Minimal parameters...
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 2 --------------------------
PS C:\\># Remove sudo prompt requirement for multiple Domain Users
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
DomainUserForNoSudoPwd = @('zero\\zeroadmin','zero\\zeroadminbackup')
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 3 --------------------------
PS C:\\># Remove sudo prompt requirement for a Domain Group
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
DomainGroupForNoSudoPwd = @('Domain Admins')
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 4 --------------------------
PS C:\\># Using a local account on the Remote Host...
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
LocalPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
-------------------------- EXAMPLE 5 --------------------------
PS C:\\># Using an ssh Key File instead of a password...
$RemoveSudoPwdSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
KeyFilePath = $HOME/.ssh/my_ssh_key
}
Remove-SudoPwd @RemoveSudoPwdSplatParams
RELATED LINKS