PowerShell Remove-PSSession Cmdlet

PowerShell Remove-PSSession Cmdlet

PowerShell Remove-PSSession Cmdlet

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed Connect-PSSession cmdlet in PowerShell.

https://cloudaffaire.com/powershell-Remove-PSSession-cmdlet/

In this blog post, we will discuss Remove-PSSession cmdlet in PowerShell. You can use Remove-PSSession cmdlet to close a PowerShell session (PSSession) to a local or remote computer. When you invoke Remove-PSSEssion cmdlet, PowerShell stops all the running command in the PSSession, closes the PSSession, and then releases all the resources that were utilized by the PSSession.

Remove-PSSession Cmdlet Syntax:

Remove-PSSession Cmdlet Argument List:

  • ComputerName: Specifies an array of names of computers. This cmdlet closes the PSSessions that are connected to the specified computers. Wildcard characters are permitted.
  • Confirm: Prompts you for confirmation before running the cmdlet.
  • ContainerId: Specifies an array of IDs of containers. This cmdlet removes sessions for each of the specified containers.
  • Id: Specifies an array of IDs of sessions. This cmdlet closes the PSSessions with the specified IDs.
  • InstanceId: Specifies an array of instance IDs. This cmdlet closes the PSSessions that have the specified instance IDs.
  • Name: Specifies an array of friendly names of sessions. This cmdlet closes the PSSessions that have the specified friendly names.
  • Session: Specifies the session objects of the PSSessions to close.
  • VMId: Specifies an array of ID of virtual machines. This cmdlet starts an interactive session with each of the specified virtual machines.
  • VMName: Specifies an array of names of virtual machines. This cmdlet starts an interactive session with each of the specified virtual machines.
  • WhatIf: Shows what would happen if the cmdlet runs. The cmdlet is not run.

PowerShell Remove-PSSession Cmdlet:

Hope you have enjoyed this article. In the next blog post, we will discuss Invoke-Command CmdLet in PowerShell.

To get more details on PowerShell, kindly follow below official documentation

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about?view=powershell-5.1

 

Leave a Reply

Close Menu