Share via


Uninstall-SCOMAgent

Uninstalls agents from agent-managed computers.

Syntax

Default (Default)

Uninstall-SCOMAgent
    [-ActionAccount <PSCredential>]
    -Agent <AgentManagedComputer[]>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

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.

Examples

Example 1: Uninstall an agent

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

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.

Example 2: Uninstall an agent by using an object variable

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

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.

Example 3: Uninstall an agent by using an action account

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

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.

Parameters

-ActionAccount

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.

Parameter properties

Type:PSCredential
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Agent

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.

Parameter properties

Type:

AgentManagedComputer[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments: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.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.EnterpriseManagement.Administration.AgentManagedComputer

Outputs

Microsoft.EnterpriseManagement.Administration.AgentTaskResult