Powershell: Use Users full name of windows account to create NavServerUser

Hey there,

I am creating a new local Windows User with a full name this way:
New-LocalUser -Name "User03" -FullName 'testname' -Description "Description of this account." -NoPassword

Works fine. Now I want to create a new NavUser and use the full name of that windows Account. Hardcoded it looks like:
New-NavServerUser -WindowsAccount User03 -FullName 'test' -ServerInstance 'MicrosoftDynamicsNavServer$Nav'

But how to get the fullname into a variable so i can write this command:
New-NavServerUser -WindowsAccount User03 -FullName $FullName -ServerInstance 'MicrosoftDynamicsNavServer$Nav'

To fill the Variable i tried for example this:
$FullName = (get-WmiObject -Class Win32_UserAccount | Where-Object -FilterScript {$_.Caption -eq "User03"}).FullName

Does not work for me, after entering
into the console, there is no output. Also there is no error massage so i could not imagine why it does not work.

Can someone help?

Best Answer


  • Options
    ImperatorMingImperatorMing Member Posts: 13
    You are right, it is domain specific. Thanks!
Sign In or Register to comment.