Uninstall-SCOMAgent
Uninstalls agents from agent-managed computers.
Syntax
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
.
Type: | PSCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | AgentManagedComputer[] |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
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.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Microsoft.EnterpriseManagement.Administration.AgentManagedComputer
Outputs
Microsoft.EnterpriseManagement.Administration.AgentTaskResult