Topic
This article explains how to use Ninja-Property-Docs-Set-Single-Piped to set the value of a specified custom field in a single document using the PowerShell pipeline.
Environment
- NinjaOne
- Microsoft PowerShell
Description
This cmdlet sets the value of a specified custom field in a single document using the PowerShell pipeline. You can specify the field name using the -AttributeName parameter and the document template using the TemplateName parameter. The value can be provided via the pipeline or using the -Value parameter. The cmdlet updates the value of the specified custom field in the single document associated with the specified template with the provided value.
Only fields with automation write permissions can be updated using this cmdlet. The device executing this cmdlet must be assigned as a documentation delegate for the document containing the custom field to be updated. The specified custom field in the document is updated after the next successful sync with the NinjaOne platform, which typically occurs within a few minutes.
Syntax
Ninja-Property-Docs-Set-Single-Piped [[-TemplateName] <Object>] [[- AttributeName] <Object>] [[-Value] <Object>] [<CommonParameters>]
Example
Setting a Custom Field with 199,999 Characters
$alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890"
$DesiredValue = New-Object System.Collections.Generic.List
for($i = 0; $i -lt 199999; $i++){
$DesiredValue.Add("$($alphabet[(Get-Random -Maximum
$alphabet.Length)])")
}
$CustomFieldValue = "$($DesiredValue -join '')"
PS C:> $CustomFieldValue | Ninja-Property-Docs-Set-Single-Piped -
TemplateName "My Example Document" -AttributeName "exampleWYSIWYG"Piped commands can be used to set the value of a custom field to a long string such as 199,999 characters, which is the maximum length for a WYSIWYG custom field. In this example, a random string of 199,999 characters is generated and set as the value of the exampleWYSIWYG custom field in "My Example Document".
Parameters
-AttributeName
Specify the name of the custom field for which you want to set a value.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False-TemplateName
Provide the document template name for the document in which you want to set the value of
the specified custom field.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False-Value
Define the value to set for the specified custom field.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseInputs
System.String
The cmdlet accepts string input from the pipeline, which is used as the value to set for the specified custom field. The -TemplateName and -AttributeName parameters accept string values representing the name of the document template and the name of the custom field, respectively, for which you want to set a value.
Outputs
None
- The device executing this cmdlet must be assigned as a documentation delegate for the document containing the custom field to be updated.
- Only fields with automation write permissions can be updated using this cmdlet. For information about permissions for custom fields refer to NinjaOne Custom Fields: Getting Started.
- The specified custom field in the document is updated after the next successful sync withthe NinjaOne platform, which typically occurs within a few minutes.
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