Topic
This article explains how to use Ninja-Property-Options to retrieve valid values for a dropdown or multi-select custom field for a device.
Environment
- NinjaOne
- Microsoft PowerShell
Description
The Ninja-Property-Options cmdlet retrieves valid values for a dropdown or multi-select custom field for a device. You can specify the name of the custom field using the -Name parameter. The cmdlet returns a list of valid options in the format <guid>=<name> , where <guid> is the unique identifier for the option and <name> is the display name of the option. Only fields with automation read permissions can have their options retrieved using this cmdlet.
Syntax
Ninja-Property-Options [[-Name] <Object>] [<CommonParameters>]
Examples
Example 1: A Dropdown Custom Field
PS C:> Ninja-Property-Options -Name "exampleDropdown"
2a100199-4067-4332-8f4d-451e14b94a76=Mötley Crüe
9eccdedf-aefb-4d4b-92c3-e0fe03c305e2=Value 1
cd7ec878-766d-4794-baa2-4328af9f06ce=101010101When a dropdown custom field is specified, the cmdlet returns the valid options for the dropdown field in the format <guid>=<name>, where <guid> is the unique identifier for the option and <name> is the display name of the option.
Example 2: A Multi-Select Custom Field
PS C:> Ninja-Property-Options -Name "exampleMultiSelect"
154d90cf-3d4a-4e43-8b79-232ccd5b74a6=Value 3
21aa863a-ddf1-4f5c-8811-4e98c45da96b=Mötley Crüe
834d0865-1c70-492b-ac11-73854fd0294d=Option 1When a multi-select custom field is specified, the cmdlet returns the valid options for the multi-select field in the format <guid>=<name> , where <guid> is the unique identifier for the option and <name> is the display name of the option.
Example 3: A Custom Field with No Options
PS C:> Ninja-Property-Options -Name "exampleTextField"When a custom field that does not have options such as a text field is specified, the cmdlet returns no output.
Parameters
-Name
Specify the name of the custom field for which you want to retrieve valid options.
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 custom field for which you want to retrieve valid options.
Outputs
System.String[]
The cmdlet returns the valid options for the specified custom field in the format <guid>= <name> as a string or an array of strings if more than one option is available.
- This cmdlet is only applicable for dropdown and multi-select custom fields. If a different type of custom field is specified, no output will be returned.
- Only fields with automation read permissions can have their options retrieved using this cmdlet. 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: