Create automatic user in nav when logging in the server

soetie
Member Posts: 62
Hi all,
i was wondering if it is possible to do an automatic user creation by powershell, when a users loggs in for the first time.
Im having a demo environment which i refresh regular.
So can i when a user loggs in for the first time create a schedule script that makes the user "super"in nav automatically. So i dont have to add the user by hand?
It looks like MS does is also on its azure machines.
I have tried a bit with this:
--
Import-Module "${env:ProgramFiles}\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1"
# Add User
New-NavServerUser -WindowsAccount 'domain\user' -ServerInstance InstanceName
# Add Permission to the user
New-NavServerUserPermissionSet -WindowsAccount 'domain\user' -ServerInstance InstanceName -PermissionSetId SUPER
or maybe something like this,
# Add a NavUserPassword User who is SUPER
$user = Get-NAVServerUser $serverInstance | % { if ($_.UserName -eq $NavAdminUser) { $_ } }
if (!$user) {
New-NAVServerUser $serverInstance -UserName $NavAdminUser -Password (ConvertTo-SecureString -String $NavAdminPassword -AsPlainText -Force) -ChangePasswordAtNextLogOn:$false -LicenseType Full
New-NAVServerUserPermissionSet $serverInstance -UserName $NavAdminUser -PermissionSetId "SUPER"
But username, instance and also Computer name is constantly changing.
im running to several errors.Maybe someone could help?
i was wondering if it is possible to do an automatic user creation by powershell, when a users loggs in for the first time.
Im having a demo environment which i refresh regular.
So can i when a user loggs in for the first time create a schedule script that makes the user "super"in nav automatically. So i dont have to add the user by hand?
It looks like MS does is also on its azure machines.
I have tried a bit with this:
--
Import-Module "${env:ProgramFiles}\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1"
# Add User
New-NavServerUser -WindowsAccount 'domain\user' -ServerInstance InstanceName
# Add Permission to the user
New-NavServerUserPermissionSet -WindowsAccount 'domain\user' -ServerInstance InstanceName -PermissionSetId SUPER
or maybe something like this,
# Add a NavUserPassword User who is SUPER
$user = Get-NAVServerUser $serverInstance | % { if ($_.UserName -eq $NavAdminUser) { $_ } }
if (!$user) {
New-NAVServerUser $serverInstance -UserName $NavAdminUser -Password (ConvertTo-SecureString -String $NavAdminPassword -AsPlainText -Force) -ChangePasswordAtNextLogOn:$false -LicenseType Full
New-NAVServerUserPermissionSet $serverInstance -UserName $NavAdminUser -PermissionSetId "SUPER"
But username, instance and also Computer name is constantly changing.
im running to several errors.Maybe someone could help?
0
Comments
-
I am using PS script which create users based on the selected OU in domain. You can schedule it or something to "refresh" the users in NAV based on users in your AD...
Import-Module 'C:\Program Files\Microsoft Dynamics NAV\90\Service\Microsoft.Dynamics.Nav.Management.dll' $OUs= "ou=MyOU,ou=Users,ou=Company,dc=mydomain,dc=local", "ou=MyOU2,ou=Users,ou=Company,dc=mydomain,dc=local" foreach ($OU in $OUs) { $Users=Get-ADUser -Filter * -SearchBase $OU foreach ($User in $Users) { New-NAVServerUser -ServerInstance $serverInstance -WindowsAccount $User.UserPrincipalName New-NAVServerUserPermissionSet -ServerInstance $serverInstance -WindowsAccount $User.UserPrincipalName -PermissionSetId SUPER } }
1 -
Hi
thanks, im gonna try it!
oh no, i havent installed nav in a domain so im having only a local user.
Maybe the best i will delete all users and wont add them in nav.0 -
Than I am sure that you can read all local users through powershell too... :-) http://powershell.com/cs/media/p/2327.aspx0
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