Uninstall-SCOMAgent

Uninstall-SCOMAgent

Uninstalls agents from agent-managed computers.

Syntax

Parameter Set: Empty
Uninstall-SCOMAgent -Agent <AgentManagedComputer[]> [-ActionAccount <PSCredential> ] [-PassThru] [ <CommonParameters>]

Detailed Description

The Uninstall-SCOMAgent cmdlet uninstalls agents from agent-managed computers. Before you uninstall an agent, you must remove the Active Directory Domain Services (AD DS) agent assignments from the management group. You can use the Remove-SCOMADAgentAssignment cmdet to remove AD DS agent assignments from the management group.

Parameters

-ActionAccount<PSCredential>

Specifies a PSCredential object. This parameter specifies the credentials that Operations Manager uses to run the deployment task. If you do not specify this parameter or you specify a null value, Operations Manager uses the default action account of the management server for the agent.

To obtain a PSCredential object, use the Get-Credential cmdlet. For more information, type Get-Help Get-Credential.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Agent<AgentManagedComputer[]>

Specifies an array of AgentManagedComputer objects. This parameter specifies the Operations Manager agents to uninstall. To obtain an AgentManagedComputer object, use the Get-SCOMADAgent cmdlet.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-PassThru

Indicates that the cmdlet creates or modifies an object that a command can use in the pipeline. By default, this cmdlet does not generate any output.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.EnterpriseManagement.Administration.AgentManagedComputer

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.EnterpriseManagement.Administration.AgentTaskResult

Examples

Example 1: Uninstall an agent

The first command gets the Operations Manager agent object named server01.contoso.com and passes it to the Uninstall-SCOMAgent cmdlet by using the pipeline operator. The second command uninstalls the agent named server01.contoso.com.

PS C:\> Get-SCOMAgent -DNSHostName "server01.contoso.com" | Uninstall-SCOMAgent

Example 2: Uninstall an agent by using an object variable

This example uninstalls the Operations Manager agent on an agent-managed computer.

The first command gets the agent-managed computer object named server01.contoso.com and stores the object in the $Agent variable.

The second command uninstalls the agent stored in $Agent.

PS C:\> $Agent = Get-SCOMAgent -DNSHostName "server01.contoso.com"
PS C:\> Uninstall-SCOMAgent -Agent $Agent

Example 3: Uninstall an agent by using an action account

This example uninstalls the Operations Manager agent on an agent-managed computer after the user enters the credentials that Operations Manager requires to uninstall the agent.

The first command gets the agent object named server01.contoso.com and stores the object in the $Agent variable.

The second command prompts the user to enter the credentials that Operations Manager uses to uninstall an agent. The command then uninstalls the agent stored in $Agent.

PS C:\> $Agent = Get-SCOMAgent -DNSHostName "server01.contoso.com"
PS C:\> Uninstall-SCOMAgent -Agent $Agent -ActionAccount (Get-Credential)

Get-SCOMAgent

Install-SCOMAgent

Get-SCOMRunAsAccount

Get-SCOMManagementServer

Repair-SCOMAgent