Already a NinjaOne customer? Log in to view more guides and the latest updates.

PowerShell: Remove-NinjaTag

Topic

This article explains how to use Remove-NinjaTag to remove a specified system tag from a device.

If you use the NinjaOne PowerShell Module outside of an automation script, you may need to adjust PowerShell's execution policy. For more information about execution policies, refer to Microsoft's documentation: about Execution Policies (external link).

Environment

  • NinjaOne
  • Microsoft PowerShell

Description

The Remove-NinjaTag cmdlet removes one or more specified system tags from the current device. System tags are predefined tags in the NinjaOne platform that can be used to categorize and manage devices. The cmdlet removes the specified tag(s) from the current device without affecting any other assigned tags.

This cmdlet must be executed within a Ninja automation script to modify the assigned system tags. Tag assignment changes are applied after the next successful sync with the NinjaOne platform, which typically occurs within a few minutes.

Syntax

Remove-NinjaTag [-Name] <String[]> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Examples

Example 1: Remove from Automation Script

PS C:> Remove-NinjaTag -Name "IIS"

The specified system tag "IIS" is removed from the device.

Example 2: Remove from Active Terminal

PS C:> Remove-NinjaTag -Name "IIS"
Remove-NinjaTag : Access to tags is possible only from automation script
At line:1 char:1
+ Remove-NinjaTag -Name "IIS"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : FromStdErr: (:) [Write-Error],
WriteErrorException
+ FullyQualifiedErrorId :
Microsoft.PowerShell.Commands.WriteErrorException,Remove-NinjaTag

Tags are only removable from an automation script, so an error message is returned when attempting to run the cmdlet in an active terminal session.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Force

If confirm is not specified and the cmdlet would prompt for confirmation, this parameter forces the cmdlet to run without asking for confirmation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Name

The name of the system tag(s) to remove from the device. This parameter accepts an array of strings, allowing you to specify multiple tags to remove in a single command.

Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-WhatIf

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

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Common Parameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, - Verbose, -WarningAction, and -WarningVariable.For more information about common parameters, refer to Microsoft document about_CommonParameters (external link).

Inputs

System.String[]

An array of strings representing the names of the system tags to remove from the device. This input can be provided through the pipeline or as a parameter.

Outputs

None

  • This cmdlet must be executed within a Ninja automation script to modify the tags of a
    device.
  • Tag assignment changes are applied after the next successful sync with the NinjaOne
    platform, which typically occurs within a few minutes.

Additional Resources

For more information about asset management and custom scripting, refer to the following resources:

FAQ

Next Steps