-
Notifications
You must be signed in to change notification settings - Fork 90
/
SetupNavUsers.ps1
23 lines (22 loc) · 1.15 KB
/
SetupNavUsers.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# INPUT
# $auth
# $username (optional)
# $securePassword (optional)
#
# OUTPUT
#
if ($auth -eq "Windows") {
if ($username -ne "") {
if (!(Get-NAVServerUser -ServerInstance $ServerInstance @tenantParam -ErrorAction Ignore | Where-Object { $_.UserName.EndsWith("\$username", [System.StringComparison]::InvariantCultureIgnoreCase) -or $_.UserName -eq $username })) {
Write-Host "Creating SUPER user"
New-NavServerUser -ServerInstance $ServerInstance @tenantParam -WindowsAccount $username
New-NavServerUserPermissionSet -ServerInstance $ServerInstance @tenantParam -WindowsAccount $username -PermissionSetId SUPER
}
}
} else {
if (!(Get-NAVServerUser -ServerInstance $ServerInstance @tenantParam -ErrorAction Ignore | Where-Object { $_.UserName -eq $username })) {
Write-Host "Creating SUPER user"
New-NavServerUser -ServerInstance $ServerInstance @tenantParam -Username $username -Password $securePassword -AuthenticationEMail $authenticationEMail
New-NavServerUserPermissionSet -ServerInstance $ServerInstance @tenantParam -username $username -PermissionSetId SUPER
}
}