This commit is contained in:
samvdjagt 2020-08-12 18:50:32 -04:00 коммит произвёл GitHub
Родитель e74607968a
Коммит 54545d4e19
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 0 добавлений и 33 удалений

Просмотреть файл

@ -1,33 +0,0 @@
param(
[string] [Parameter(Mandatory=$true)] $username,
[string] [Parameter(Mandatory=$true)] $password,
[string] [Parameter(Mandatory=$true)] $targetGroup,
[string] [Parameter(Mandatory=$true)] $domainName,
[string] [Parameter(Mandatory=$true)] $artifactsLocation
)
#Install-Module AzureAD -Force
#Import-Module AzureAD -Force
$url = $($artifactsLocation + "/Modules/ARM/UserCreation/Parameters/users.parameters.json")
$response = Invoke-WebRequest -Uri $url
$ConfigurationJson = $response.content
try { $UserConfig = $ConfigurationJson | ConvertFrom-Json -ErrorAction 'Stop' }
catch {
Write-Error "Configuration JSON content could not be converted to a PowerShell object" -ErrorAction 'Stop'
}
$ErrorActionPreference = 'Stop'
#$Credential = New-Object System.Management.Automation.PsCredential($username, (ConvertTo-SecureString $password -AsPlainText -Force))
#Connect-AzureAD -AzureEnvironmentName 'AzureCloud' -Credential $Credential
foreach ($config in $UserConfig.userconfig) {
$userName = $config.userName
$upn = $($userName + "@" + $domainName)
if ($config.createGroup) { New-AzADGroup -DisplayName "$targetGroup" -MailNickname "$targetGroup" }
if ($config.createUser) { New-AzADUser -UserPrincipalName $upn -Name "$userName" -MailNickname $userName -Password (convertto-securestring $config.password -AsPlainText -Force) }
if ($config.assignUsers) { Add-AzADGroupMember -MemberUserPrincipalName $upn -TargetGroupDisplayName $targetGroup }
Start-Sleep -Seconds 1
}