Topic
This article explains how to use Set-NinjaUser to assign a specified user to a device.
Environment
- NinjaOne
- Microsoft PowerShell
Description
The Set-NinjaUser cmdlet assigns a specified user to a device. The user is identified by their email address and can be an end user, technician, or contact. If an account or contact is limited to an organization, NinjaOne will only match devices that belong to the same organization as the user. Technicians must have permission to access the device.
This cmdlet must be executed within a Ninja automation script to modify the assigned user.
Updates to the assigned user will be displayed in the NinjaOne webui upon a successful sync which usually occurs within a few minutes.
Syntax
Set-NinjaUser [-EmailAddress] <String> [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Examples
Example 1: Assign a User - Automation Script
PS C:> Set-NinjaUser -EmailAddress "[email protected]"
Request successfully sent to agent. See device activity feed to confirm the
user was assigned.The user with the email address "[email protected]" is assigned to the specified device.
Example 2: Assign a User - Active Terminal
PS C:> Set-NinjaUser -EmailAddress "[email protected]"
Set-NinjaUser : Access to set user is possible only from automation script
At line:1 char:1
+ Set-NinjaUser -EmailAddress "[email protected]"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : FromStdErr: (:) [Write-Error],
WriteErrorException
+ FullyQualifiedErrorId :
Microsoft.PowerShell.Commands.WriteErrorException,Set-NinjaUserYou can only assign a user from an automation script, so an error message is returned when attempting to run the cmdlet in an active terminal session.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False-EmailAddress
Specify the email address of the user to assign to the device. The user must already exist inNinjaOne as an end user, technician, or contact.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False-Force
If the Confirm parameter is not specified, the Force parameter will override ShouldProcess and allow the cmdlet to continue processing.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseCommon Parameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.For more information about common parameters, refer to Microsoft document about_CommonParameters (external link).
Inputs
System.String
This cmdlet accepts a string representing the email address of the user to assign to the device.
Outputs
None
- The user must already exist in NinjaOne as an end user, technician, or contact.
- NinjaOne will display the new unmanaged device upon a successful sync, which usually 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
- NinjaOne IT Asset Management (ITAM)
- NinjaOne ITAM: Create an Unmanaged Device via Command Line Interface (CLI)
- 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