forked from petehauge/DTL-VM-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet-AccessControl.ps1
38 lines (28 loc) · 968 Bytes
/
Set-AccessControl.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param
(
[Parameter(Mandatory=$false, HelpMessage="Configuration File, see example in directory")]
[string] $ConfigFile = "config.csv",
[Parameter(Mandatory=$false, HelpMessage="Custom Role to use")]
[string] $CustomRole = "No VM Creation User"
)
$ErrorActionPreference = "Stop"
. "./Utils.ps1"
$config = Import-Csv $ConfigFile
ForEach ($lab in $config) {
$LabOwners = $lab.LabOwners
$LabUsers = $lab.LabUsers
# Split if multiple emails
if($LabOwners) {
$ownAr = $LabOwners.Split(",").Trim()
} else {
$ownAr = @()
}
if($LabUsers) {
$userAr = $LabUsers.Split(",").Trim()
} else {
$userAr = @()
}
Set-LabAccessControl -DevTestLabName $lab.DevTestLabName -ResourceGroupName $lab.ResourceGroupName -customRole $customRole -ownAr $ownAr -userAr $userAr -ErrorAction Continue
Write-Host "Access control set for $DevTestLabName"
}
Write-Output "Access control set correctly"