< Back
Invoke-BAShSudoCommand
Post
NAME Invoke-BAShSudoCommand
SYNOPSIS
Runs a Bourne Again Shell sudo command on a remote computer.
SYNTAX
Invoke-BAShSudoCommand [-Name] <String> [[-Port] <Int32>] [-Command] <String> [-Credential] <PSCredential>
[[-Timeout] <Int16>] [<CommonParameters>]
DESCRIPTION
The Invoke-SudoCommand function runs sudo commands via secure shell on a remote computer and returns any
output.
PARAMETERS
-Name <String>
Specifies the computer on which the sudo command runs. Use an IP address or a DNS name of the remote computer.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-Port <Int32>
Specifies the network port on the remote computer that is used for a secure shell session. To connect to a
remote computer, it must be listening on the port that the connection uses. The default port is 22.
Required? false
Position? 2
Default value 22
Accept pipeline input? false
Accept wildcard characters? false
-Command <String>
Specifies the command to run with sudo on the remote computer. Type in the command as you would do normally.
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Credential <PSCredential>
Specifies a user account credential for the secure shell session connection, and has sudo permissions on the
remote computer. Either pass a PSCredential object or respond to the prompt.
Required? true
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Timeout <Int16>
Specifies the timeout period for the sudo command to complete on the remote computer. The default is five
seconds.
Required? false
Position? 5
Default value 5
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
System.String, System.Int16, System.Int32, pscredential
OUTPUTS
System.String
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Invoke-SudoCommand -Name LinuxServer -Port 22 -Command "sudo whoami" -Credential (Get-Credential)
Description
-----------
This runs the command "whoami" with sudo on the computer 'LinuxServer' via secure shell on port 22.
RELATED LINKS
SYNOPSIS
Runs a Bourne Again Shell sudo command on a remote computer.
SYNTAX
Invoke-BAShSudoCommand [-Name] <String> [[-Port] <Int32>] [-Command] <String> [-Credential] <PSCredential>
[[-Timeout] <Int16>] [<CommonParameters>]
DESCRIPTION
The Invoke-SudoCommand function runs sudo commands via secure shell on a remote computer and returns any
output.
PARAMETERS
-Name <String>
Specifies the computer on which the sudo command runs. Use an IP address or a DNS name of the remote computer.
Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false
-Port <Int32>
Specifies the network port on the remote computer that is used for a secure shell session. To connect to a
remote computer, it must be listening on the port that the connection uses. The default port is 22.
Required? false
Position? 2
Default value 22
Accept pipeline input? false
Accept wildcard characters? false
-Command <String>
Specifies the command to run with sudo on the remote computer. Type in the command as you would do normally.
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Credential <PSCredential>
Specifies a user account credential for the secure shell session connection, and has sudo permissions on the
remote computer. Either pass a PSCredential object or respond to the prompt.
Required? true
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Timeout <Int16>
Specifies the timeout period for the sudo command to complete on the remote computer. The default is five
seconds.
Required? false
Position? 5
Default value 5
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
System.String, System.Int16, System.Int32, pscredential
OUTPUTS
System.String
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Invoke-SudoCommand -Name LinuxServer -Port 22 -Command "sudo whoami" -Credential (Get-Credential)
Description
-----------
This runs the command "whoami" with sudo on the computer 'LinuxServer' via secure shell on port 22.
RELATED LINKS