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

PowerShell: Ninja Property Get

Topic

This article explains how to use Ninja-Property-Get to retrieve the value of a specified device custom field.

Ninja-Property-Get is a legacy cmdlet. While it may still work, we recommend using Get-NinjaProperty instead.
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 Ninja-Property-Get cmdlet retrieves the value of a specified device custom field. You can specify the name of the custom field using the -Name parameter. The cmdlet returns the current value of the specified custom field for the device. Only fields with automation read permissions can be retrieved using this cmdlet.

Syntax

Ninja-Property-Get [[-Name] <Object>] [<CommonParameters>]

Examples

Example 1: Apps and Services Dropdown Custom Field

PS C:> Ninja-Property-Get -Name "exampleAppsAndServicesDropdown"
{"entityId":5,"type":"CLIENT_DOCUMENT"}

When retrieving the value of an Apps and Services Dropdown custom field, the cmdlet returns a JSON string containing the entityId and type of the selected item.

Example 2: Apps and Services Multiselect Custom Field

PS C:> Ninja-Property-Get -Name "exampleAppsAndServicesMultiselect"
{"entityIds":[6,5,4],"type":"CLIENT_DOCUMENT"}

When retrieving the value of an Apps and Services Multiselect custom field, the cmdlet returns a JSON string containing an array of entityIds representing the selected items and the type of the selected items.

Example 3: Attachment Custom Field

 PS C:> Ninja-Property-Get -Name "deploymentChecklist"
{"contentId":"RgOJqWzVlAxkwBTBSLeb","extension":"docx","mimeType":"applicati
on/vnd.openxmlformatsofficedocument.
wordprocessingml.document","name":"Deployment
Checklist","size":27771}

When retrieving the value of an Attachment custom field, the cmdlet returns a JSON string containing details about the attachment, including contentId , extension , mimeType , name , and size .

Example 4: Checkbox Custom Field

 PS C:> Ninja-Property-Get -Name "deployed"
1

When retrieving the value of a Checkbox custom field, the cmdlet returns 1 if the checkbox is selected (true) and 0 if it is not selected (false). If no value is selected the cmdlet does not return any output.

Example 5: Date Custom Field

 PS C:> Ninja-Property-Get -Name "deploymentDay"
1769976000

When retrieving the value of a Date custom field, the cmdlet returns the date value as a Unix timestamp representing the number of seconds that have elapsed since January 1, 1970 (UTC).

Example 6: DateTime Custom Field

 PS C:> Ninja-Property-Get -Name "lastSeen"
1770904800

When retrieving the value of a DateTime custom field, the cmdlet returns the date and time value as a Unix timestamp representing the number of seconds that have elapsed since January 1, 1970 (UTC).

Example 7: Decimal Custom Field

PS C:> Ninja-Property-Get -Name "pi"
3.14

When retrieving the value of a Decimal custom field, the cmdlet returns the decimal value as a string.

Example 8: Device Dropdown Custom Field

PS C:> Ninja-Property-Get -Name "exampleDeviceDropdown"
{"entityId":1226,"type":"NODE"}

When retrieving the value of a Device Dropdown custom field, the cmdlet returns a JSON string containing the entityId and type of the selected device.

Example 9: Device MultiSelect Custom Field

PS C:> Ninja-Property-Get -Name "exampleDeviceMultiselect"
{"entityIds":[1226,1131],"type":"NODE"}

When retrieving the value of a Device MultiSelect custom field, the cmdlet returns a JSON string containing an array of entityIds representing the selected devices and the type of the selected devices.

Example 10: Dropdown Custom Field

PS C:> Ninja-Property-Get -Name "favoriteBand"
2a100199-4067-4332-8f4d-451e14b94a76

When retrieving the value of a Dropdown custom field, the cmdlet returns the unique identifier (ID) of the selected option as a string. You can use Ninja-Property-Options to retrieve the valid options for the dropdown field and their corresponding IDs.

Example 11: Email Custom Field

PS C:> Ninja-Property-Get -Name "supportEmail"
[email protected]

When retrieving the value of an Email custom field, the cmdlet returns the email address as a string.

Example 12: Integer Custom Field

 PS C:> Ninja-Property-Get -Name "favoriteNumber"
42

When retrieving the value of an Integer custom field, the cmdlet returns the integer value as a string.

Example 13: IP Address Custom Field

PS C:> Ninja-Property-Get -Name "primaryDNS"
1.1.1.1

When retrieving the value of an IP Address custom field, the cmdlet returns the IP address as a string.

Example 14: Multiline Custom Field

PS C:> Ninja-Property-Get -Name "exampleMultiline"
Line 1
Line 3

When retrieving the value of a Multiline custom field, the cmdlet returns the multiple lines of text as an array of strings, where each string in the array corresponds to a line of text in the multiline field. If only one line of text is present, the cmdlet returns a single string.

Example 15: MultiSelect Custom Field

PS C:> Ninja-Property-Get -Name "exampleMultiselect"
834d0865-1c70-492b-ac11-73854fd0294d, 154d90cf-3d4a-4e43-8b79-232ccd5b74a6

When retrieving the value of a MultiSelect custom field, the cmdlet returns a commaseparated string of the unique identifiers (IDs) of the selected options. You can use Ninja -Property-Options to retrieve the valid options for the multi-select field and their corresponding IDs.

Example 16: Organization Dropdown Custom Field

PS C:> Ninja-Property-Get -Name "exampleOrganizationDropdown"
{"entityId":8,"type":"CLIENT"}

When retrieving the value of an Organization Dropdown custom field, the cmdlet returns a JSON string containing the entityId and type of the selected organization.

Example 17: Organization Location Dropdown Custom Field

PS C:> Ninja-Property-Get -Name "exampleOrganizationLocationDropdown"
{"entityId":8,"type":"CLIENT_LOCATION"}

When retrieving the value of an Organization Location Dropdown custom field, the cmdlet returns a JSON string containing the entityId and type of the selected organization location.

Example 18: Organization MultiSelect Custom Field

PS C:> Ninja-Property-Get -Name "exampleOrganizationMultiSelect"
{"entityIds":[8,13],"type":"CLIENT"}

When retrieving the value of an Organization MultiSelect custom field, the cmdlet returns a JSON string containing an array of entityIds representing the selected organizations and the type of the selected organizations.

Example 19: Organization Location MultiSelect Custom Field

PS C:> Ninja-Property-Get -Name "exampleOrganizationLocationMultiSelect"
{"entityIds":[8,1],"type":"CLIENT_LOCATION"} 

When retrieving the value of an Organization Location MultiSelect custom field, the cmdlet returns a JSON string containing an array of entityIds representing the selectedorganization locations and the type of the selected organization locations.

Example 20: Phone Custom Field

PS C:> Ninja-Property-Get -Name "supportNumber"
+18008675309

When retrieving the value of a Phone custom field, the cmdlet returns the phone number as a string.

Example 21: Secure Custom Field

PS C:> Ninja-Property-Get -Name "superSecretPassword"
Hunter42

When retrieving the value of a Secure custom field, the cmdlet returns the secure value as a string.

Example 22: Text Custom Field

PS C:> Ninja-Property-Get -Name "exampleText"
My Text

When retrieving the value of a Text custom field, the cmdlet returns the text value as a string.

Example 23: Time Custom Field

 PS C:> Ninja-Property-Get -Name "updateTime"
 79200

When retrieving the value of a Time custom field, the cmdlet returns the number of seconds since midnight UTC (for the current day).

Example 24: URL Custom Field

PS C:> Ninja-Property-Get -Name "exampleUrl"
https://www.google.com

When retrieving the value of a URL custom field, the cmdlet returns the URL as a string.

Example 25: WYSIWYG Custom Field

PS C:> Ninja-Property-Get -Name "systemPerformance"
{"html":"<div> <div class='card flex-grow-1'>n <div class='card-titlebox'>
n <div class='card-title'><i class='fa-solid fa-gauge-high'>
</i>&nbsp;&nbsp;System Performance Metrics</div>..."} 

When retrieving the value of a WYSIWYG custom field, the cmdlet returns a JSON string containing the HTML content of the field.

Parameters

-Name

Specify the name of the device custom field for which you want to retrieve the value.

Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Inputs

System.String

The cmdlet does not accept input from the pipeline. The -Name parameter accepts a string value representing the name of the device custom field for which you want to retrieve the value.

Outputs

System.String[]

The cmdlet returns the value of the specified device custom field as a string. For Multiline custom fields, the cmdlet returns an array of strings, where each string in the array corresponds to a line of text in the multiline field.

  • All time and date related fields are returned in the UTC timezone but are displayed in the Web UI in the local timezone of the browser viewing the field.
  • The device executing this cmdlet must have permission to view the specified custom field in order to retrieve its value. For information about permissions for custom fields refer to NinjaOne Custom Fields: Getting Started.

Additional Resources

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

FAQ

Next Steps