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

PowerShell: Get-NinjaTag

Topic

This article explains how to use Get-NinjaTagto retrieve the system tags currently assigned to 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 Get-NinjaTag cmdlet retrieves the system tags assigned to the current device.

This cmdlet must be executed within a Ninja automation script to access the tag information.

Syntax

Get-NinjaTag [CommonParameters]

Examples

Example 1: Retrieve from Automation Script

PS C:> Get-NinjaTag
Data Deduplication
Active Directory Domain Services
❤️

The system tags currently assigned to the device are listed in the output. The full list of possible system tags can be retrieved using the Options-NinjaTag cmdlet.

Example 2: Retrieve from Active Terminal

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

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

Parameters

CommonParameters

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

INPUTS

None

OUTPUTS

System.String[]

This cmdlet will return a string value or an array of strings, depending on the number of tags assigned.

The cmdlet must be executed within a Ninja automation script to access the tag information.

Additional Resources

Refer to the following articles for more information on

 

FAQ

Next Steps