< Back
Get-SudoStatus
Post
NAME Get-SudoStatus
SYNOPSIS
Determines if the specified user has sudo privileges on a Remote Host, and if so, whether or not they are prompted
for a
sudo password when running 'sudo pwsh'.
Returns a pscustomobject with bool properties 'HasSudoPrivileges' and 'PasswordPrompt'.
SYNTAX
Get-SudoStatus -RemoteHostNameOrIP <String> -LocalUserName <String> [-LocalPasswordSS <SecureString>]
[-KeyFilePath <String>] [<CommonParameters>]
Get-SudoStatus -RemoteHostNameOrIP <String> -DomainUserName <String> [-DomainPasswordSS <SecureString>]
[-KeyFilePath <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
<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...
$GetSudoStatusSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Get-SudoStatus @GetSudoStatusSplatParams
-------------------------- EXAMPLE 2 --------------------------
PS C:\\># Using a local account on the Remote Host...
$GetSudoStatusSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
LocalPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Get-SudoStatus @GetSudoStatusSplatParams
-------------------------- EXAMPLE 3 --------------------------
PS C:\\># Using an ssh Key File instead of a password...
$GetSudoStatusSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
KeyFilePath = $HOME/.ssh/my_ssh_key
}
Get-SudoStatus @GetSudoStatusSplatParams
RELATED LINKS
SYNOPSIS
Determines if the specified user has sudo privileges on a Remote Host, and if so, whether or not they are prompted
for a
sudo password when running 'sudo pwsh'.
Returns a pscustomobject with bool properties 'HasSudoPrivileges' and 'PasswordPrompt'.
SYNTAX
Get-SudoStatus -RemoteHostNameOrIP <String> -LocalUserName <String> [-LocalPasswordSS <SecureString>]
[-KeyFilePath <String>] [<CommonParameters>]
Get-SudoStatus -RemoteHostNameOrIP <String> -DomainUserName <String> [-DomainPasswordSS <SecureString>]
[-KeyFilePath <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
<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...
$GetSudoStatusSplatParams = @{
RemoteHostNameOrIP = "zerowin16sshb"
DomainUserNameSS = "zero\\zeroadmin"
DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Get-SudoStatus @GetSudoStatusSplatParams
-------------------------- EXAMPLE 2 --------------------------
PS C:\\># Using a local account on the Remote Host...
$GetSudoStatusSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
LocalPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)
}
Get-SudoStatus @GetSudoStatusSplatParams
-------------------------- EXAMPLE 3 --------------------------
PS C:\\># Using an ssh Key File instead of a password...
$GetSudoStatusSplatParams = @{
RemoteHostNameOrIP = "centos7nodomain"
LocalUserNameSS = "centos7nodomain\\vagrant"
KeyFilePath = $HOME/.ssh/my_ssh_key
}
Get-SudoStatus @GetSudoStatusSplatParams
RELATED LINKS