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

ImperatorMing
Member Posts: 13
Hey there,
I am creating a new local Windows User with a full name this way:
Works fine. Now I want to create a new NavUser and use the full name of that windows Account. Hardcoded it looks like:
But how to get the fullname into a variable so i can write this command:
To fill the Variable i tried for example this:
Does not work for me, after entering
Can someone help?
Thanks!
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.$FullName
Can someone help?
Thanks!
0
Best Answer
-
Hello @ImperatorMing,
Have you tried this commanda alone to see the users:get-WmiObject -Class Win32_UserAccount
Because I think that you are missing the domain name in the filter for the Caption value.$FullName = (get-WmiObject -Class Win32_UserAccount | Where-Object -FilterScript {$_.Caption -eq "Domain\User03"}).FullName
Or you can use the like comparation instead the equal one.$FullName = (get-WmiObject -Class Win32_UserAccount | Where-Object -FilterScript {$_.Caption -like "User03"}).FullName
Regards.5
Answers
-
Hello @ImperatorMing,
Have you tried this commanda alone to see the users:get-WmiObject -Class Win32_UserAccount
Because I think that you are missing the domain name in the filter for the Caption value.$FullName = (get-WmiObject -Class Win32_UserAccount | Where-Object -FilterScript {$_.Caption -eq "Domain\User03"}).FullName
Or you can use the like comparation instead the equal one.$FullName = (get-WmiObject -Class Win32_UserAccount | Where-Object -FilterScript {$_.Caption -like "User03"}).FullName
Regards.5 -
You are right, it is domain specific. Thanks!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions