Topic
This article explains how to use Get-NinjaProperty to retrieve and convert the value of a custom field based on its name and type.
Environment
- NinjaOne
- Microsoft PowerShell
Description
The Get-NinjaProperty cmdlet retrieves the value of a specified custom field or documentation field. It allows you to specify the field name, the property type, and optionally the name of a document or template. The property type enables the cmdlet to process and convert the raw value into an appropriate PowerShell object based on the type of custom field being retrieved.
When a document name is provided, the cmdlet retrieves the property value from the specified single document instead of the device custom field. For fields that require additional options (such as dropdowns or multi-select fields), the cmdlet retrieves these options and returns the display names of the selected options instead of the raw value, provided that you specified the appropriate type.
Supported property types include: "Apps and Services Dropdown", "Apps and Services
Multiselect", "Attachment", "Checkbox", "Date", "DateTime", "Decimal", "Device Dropdown",
"Device MultiSelect", "Dropdown", "Email", "Integer", "IP Address", "MultiLine", "MultiSelect",
"Organization Dropdown", "Organization Location Dropdown", "Organization Location
MultiSelect", "Organization MultiSelect", "Phone", "Secure", "Text", "Time", "URL", and
"WYSIWYG".
If a property type is not specified, the cmdlet will return the raw string value of the custom field without any additional processing or conversion. See Ninja-Property-Get examples for how values are processed when a type is not specified. Only fields with automation read permissions can be retrieved using this cmdlet.
Syntax
Get-NinjaProperty [-Name] <String[]> [[-Type] <String>] [[-DocumentName] <String>] [<CommonParameters>]
Examples
Example 1: Apps and Services Dropdown Custom Field
PS C:> Get-NinjaProperty -Name "exampleAppsAndServicesDropdown" -Type"AppsAndServicesDropdown"entityId type-------- ----5 CLIENT_DOCUMENT
When an Apps and Services Dropdown custom field value is retrieved, the cmdlet returns a
custom object containing the entityId of the selected option and the type of entity the
option represents.
Example 2: Apps and Services Multiselect Custom Field
PS C:> Get-NinjaProperty -Name "exampleAppsAndServicesMultiSelect" -Type"AppsAndServicesMultiSelect"entityIds type--------- ----{6, 5, 4} CLIENT_DOCUMENT
When an Apps and Services MultiSelect custom field value is retrieved, the cmdlet returns a custom object containing an array of entityIds for the selected options and the type of entity the options represent.
Example 3: Attachment Custom Field
PS C:> Get-NinjaProperty -Name "deploymentChecklist" -Type "Attachment"contentId : RgOJqWzVlAxkwBTBSLebextension : docxmimeType : application/vnd.openxmlformatsofficedocument.wordprocessingml.documentname : Deployment Checklistsize : 27771
When an Attachment custom field value is retrieved, the cmdlet returns a custom object containing the contentId, extension, mimeType, name, and size of the attachment.
Example 4: Checkbox Custom Field
PS C:> Get-NinjaProperty -Name "deployed" -Type "Checkbox"True
When a Checkbox custom field value is retrieved, the cmdlet returns a boolean value of True or False, depending on whether the checkbox is checked or not. If the value of the checkbox custom field is null, the cmdlet does not return any output.
Example 5: Date Custom Field
PS C:> Get-NinjaProperty -Name "deploymentDay" -Type "Date"Sunday, February 1, 2026
When a Date custom field value is retrieved, the cmdlet returns a DateTime object representing the date value of the custom field. This date is displayed in the culture-specific date format and is in the device's local timezone.
Example 6: Date and Time Custom Field
PS C:> Get-NinjaProperty -Name "lastSeen" -Type "DateTime"Monday, February 2, 2026 1:00:00 PM
When a DateTime custom field value is retrieved, the cmdlet returns a DateTime object
representing the date and time value of the custom field. This date and time is displayed in
the culture specific date and time format and is in the devices local timezone.
Example 7: Decimal Custom Field
PS C:> Get-NinjaProperty -Name "pi" -Type "Decimal"3.14
When a Decimal custom field value is retrieved, the cmdlet returns a decimal type value.
Example 8: Device Dropdown Custom Field
PS C:> Get-NinjaProperty -Name "exampleDeviceDropdown" -Type"DeviceDropdown"entityIds type--------- ----{160} NODE
When a Device Dropdown custom field value is retrieved, the cmdlet returns a custom object
containing the entityId of the selected device and the type of entity.
Example 9: Device MultiSelect Custom Field
PS C:> Get-NinjaProperty -Name "exampleDeviceMultiselect" -Type"DeviceMultiSelect"entityIds type--------- ----{160, 188} NODE
When a Device MultiSelect custom field value is retrieved, the cmdlet returns a custom
object containing an array of entityIds for the selected devices and the type of entity.
Example 10: Dropdown Custom Field
PS C:> Get-NinjaProperty -Name "favoriteBand" -Type "Dropdown"Mötley Crüe
When a Dropdown custom field value is retrieved, the cmdlet returns the display name of the
selected option as a string.
Example 11: Email Custom Field
PS C:> Get-NinjaProperty -Name "supportEmail" -Type "Email" [email protected]
When an Email custom field value is retrieved, the cmdlet returns the email address as a
string.
Example 12: Integer Custom Field
PS C:> Get-NinjaProperty -Name "favoriteNumber" -Type "Integer"42When an Integer custom field value is retrieved, the cmdlet returns an integer type value.
Example 13: IP Address Custom Field
PS C:> Get-NinjaProperty -Name "primaryDNS" -Type "IPAddress"1.1.1.1
When an IP Address custom field value is retrieved, the cmdlet returns the IP address as a
string.
Example 14: Multi-line Custom Field
PS C:> Get-NinjaProperty -Name "exampleMultiline" -Type "Multiline"Line 1Line 3
When a Multi-line custom field value is retrieved, the cmdlet returns the value as a string or
an array of strings if more than one line is present.
Example 15: MultiSelect Custom Field
PS C:> Get-NinjaProperty -Name "exampleMultiselect" -Type "MultiSelect"Option 1Value 3
When a MultiSelect custom field value is retrieved, the cmdlet returns the display names of
the selected options as a string or an array of strings if more than one option is selected.
Example 16: Organization Dropdown Custom Field
PS C:> Get-NinjaProperty -Name "exampleOrganizationDropdown" -Type OrganizationDropdown"entityId type-------- ----8 CLIENT
When an Organization Dropdown custom field value is retrieved, the cmdlet returns a
custom object containing the entityId of the selected organization and the type of entity.
Example 17: Organization Location Dropdown Custom Field
PS C:> Get-NinjaProperty -Name "exampleOrganizationLocationDropdown" -Type"OrganizationLocationDropdown"entityId type-------- ----8 CLIENT_LOCATION
When an Organization Location Dropdown custom field value is retrieved, the cmdlet returns
a custom object containing the entityId of the selected organization location and the
type of entity.
Example 18: Organization MultiSelect Custom Field
PS C:> Get-NinjaProperty -Name "exampleOrganizationMultiSelect" -Type"OrganizationMultiSelect"entityIds type--------- ----{8, 13} CLIENT
When an Organization MultiSelect custom field value is retrieved, the cmdlet returns a
custom object containing an array of entityIds for the selected organizations and the
type of entity.
Example 19: Organization Location MultiSelect Custom Field
PS C:> Get-NinjaProperty -Name "exampleOrganizationLocationMultiSelect" -Type "OrganizationLocationMultiSelect"
entityIds type--------- ----{8, 1} CLIENT_LOCATION
When an Organization Location MultiSelect custom field value is retrieved, the cmdlet
returns a custom object containing an array of entityIds for the selected organization
locations and the type of entity.
Example 20: Phone Custom Field
PS C:> Get-NinjaProperty -Name "supportNumber" -Type "Phone"+18008675309
When a Phone custom field value is retrieved, the cmdlet returns the phone number as a string.
Example 21: Secure Custom Field
PS C:> Get-NinjaProperty -Name "superSecretPassword" -Type "Secure"Hunter42
When a Secure custom field value is retrieved, the cmdlet returns the value as a string.
Example 22: Text Custom Field
PS C:> Get-NinjaProperty -Name "exampleTextField" -Type "Text"My Text
When a Text custom field value is retrieved, the cmdlet returns the value as a string.
Example 23: Time Custom Field
PS C:> Get-NinjaProperty -Name "updateTime" -Type "Time"9:00:00 AM
When a Time custom field value is retrieved, the cmdlet returns a DateTime object
representing the time value of the custom field. This time is displayed in the culture specific
time format and is in the devices local timezone.
Example 24: URL Custom Field
PS C:> Get-NinjaProperty -Name "exampleUrl" -Type "Url"https://www.ninjaone.com
When a URL custom field value is retrieved, the cmdlet returns the URL as a string.
Example 25: WYSIWYG Custom Field
PS C:> Get-NinjaProperty -Name "systemPerformance" -Type "WYSIWYG"html----<div> <div class='card flex-grow-1'>...
When a WYSIWYG custom field value is retrieved, the cmdlet returns a custom object
containing the HTML string value of the custom field.
Parameters
-DocumentName
Specify the name of the document from which to retrieve the value of the specified documentation custom field.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False-Name
Specify the name of the device or documentation custom field whose value you would like to
retrieve.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False-Type
The type of custom field, which determines how the retrieved value is processed and
converted.
Supported types include: "Apps and Services Dropdown", "Apps and Services Multiselect",
"Attachment", "Checkbox", "Date", "DateTime", "Decimal", "Device Dropdown", "Device
MultiSelect", "Dropdown", "Email", "Integer", "IP Address", "MultiLine", "MultiSelect",
"Organization Dropdown", "Organization Location Dropdown", "Organization Location
MultiSelect", "Organization MultiSelect", "Phone", "Secure", "Text", "Time", "URL", and
"WYSIWYG".
Type: String Parameter Sets: (All) Aliases: Required: False Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False
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
System.String[]
You can pipe a string or an array of strings containing one or more custom field names to
this cmdlet.
OUTPUTS
System.String[]
This cmdlet typically returns a single string or an array of strings for most custom field types.
System.Int32
When an integer type is specified, this cmdlet returns an integer value.
System.Int64
When an integer type is specified, this cmdlet returns an integer value.
System.Boolean
When a checkbox type is specified, this cmdlet returns a boolean value.
System.DateTime
When a date, datetime, or time type is specified, this cmdlet returns a DateTime value.
System.Decimal
When a decimal type is specified, this cmdlet returns a decimal value.
System.Object
When a apps and services, attachment, device dropdown, device multiselect, organization,
or WYSIWYG type is specified, this cmdlet returns a custom object containing the relevant
information for the custom field value. The properties of this object vary based on the specific
type of the custom field.
Additional Resources
You can access these resources for more information about custom scripting: