New-PSUIdentity -Role Syntax

avatar

Attempting to add a few ad-hoc users to PSU via the PSU Powershell Module and while I can create via New-PSUIdentity including the -Role parameter keeps giving me a cannot convert from System.String to PowerShellUniversal.Role"

Is there any documentation on this?

avatar

Recommended Answer

Attempting to add a few ad-hoc users to PSU via the PSU Powershell Module and while I can create via New-PSUIdentity including the -Role parameter keeps giving me a cannot convert from System.String to PowerShellUniversal.Role"

Is there any documentation on this?


@bcaydelotte

We probably should improve this behavior to provide the role lookup automatically. That said, you will have to retrieve a role object and then pass it to the identity cmdlet.

$Role = Get-PSURole -Name "Administrator"
New-PSUIdentity -Name "Adam" -Role $Role

Adam Driscoll
PowerShell Expert and Developer at Devolutions

All Comments (2)

avatar
Attempting to add a few ad-hoc users to PSU via the PSU Powershell Module and while I can create via New-PSUIdentity including the -Role parameter keeps giving me a cannot convert from System.String to PowerShellUniversal.Role"

Is there any documentation on this?


@bcaydelotte

We probably should improve this behavior to provide the role lookup automatically. That said, you will have to retrieve a role object and then pass it to the identity cmdlet.

$Role = Get-PSURole -Name "Administrator"
New-PSUIdentity -Name "Adam" -Role $Role

Adam Driscoll
PowerShell Expert and Developer at Devolutions

avatar
Attempting to add a few ad-hoc users to PSU via the PSU Powershell Module and while I can create via New-PSUIdentity including the -Role parameter keeps giving me a cannot convert from System.String to PowerShellUniversal.Role"

Is there any documentation on this?

@bcaydelotte

We probably should improve this behavior to provide the role lookup automatically. That said, you will have to retrieve a role object and then pass it to the identity cmdlet.
$Role = Get-PSURole -Name "Administrator"
New-PSUIdentity -Name "Adam" -Role $Role


@Adam Driscoll
Thanks for the quick reply. This worked.