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.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"
1When 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"
1769976000When 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"
1770904800When 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.14When 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-451e14b94a76When 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"
42When 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.1When 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 3When 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-232ccd5b74a6When 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"
+18008675309When 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"
Hunter42When 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 TextWhen 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"
79200When 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.comWhen 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> 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: FalseInputs
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:
- NinjaOne Endpoint Management: Index of PowerShell Commands and Articles
- Command Line Interface (CLI)
- Assigning Devices as Documentation Delegates
- Reading from or Writing to Documentation: Automation, CLI, and API
- Command Line Interface (CLI): Supported Fields and Functionality
- NinjaOne Custom Fields: Getting Started