Prevent remote users from running commands on the local computer.
Syntax
Disable-PSRemoting [-Force] [-Confirm] [-WhatIf] [CommonParameters]
Key:
-Force
Suppress all user prompts. By default, you are prompted to confirm each operation.
-confirm
Prompt for confirmation before executing the command.
-whatIf
Describe the command without actually executing it.
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
-OutBuffer -OutVariable.
Enable-PSRemoting prevents users on other computers from running commands on the local computer.
To run this cmdlet, start PowerShell with the "Run as administrator" option.
To enable remote access to selected session configurations, use Set-PSSessionConfiguration -AccessMode
You can also use Enable-PSSessionConfiguration and Disable-PSSessionConfiguration to enable and disable session configurations for all users.
On systems that have both PowerShell 3.0 and the PowerShell 2.0 engine, do not use PowerShell 2.0 to run the Enable-PSRemoting or Disable-PSRemoting cmdlets.
Example
Configure the local computer to prevents remote access to all session configurations on the computer:
PS C:\> Disable-PSRemoting
Prevent remote access to all session configurations on the computer & suppress user prompts:
PS C:\> Disable-PSRemoting -Force
Display the session configurations on the computer:
PS C:\> Get-PSSessionConfiguration | Format-Table -Property Name, Permission -Auto
“Everyone has a strategy until they get punched in the face” ~ Mike Tyson
Related PowerShell Cmdlets:
Enable-PSRemoting - Allow the computer to receive remote commands.
Invoke-Command - Run commands on local and remote computers.