This repository was archived by the owner on Jul 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAdd-LabUsers.ps1
More file actions
41 lines (30 loc) · 1.49 KB
/
Add-LabUsers.ps1
File metadata and controls
41 lines (30 loc) · 1.49 KB
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
39
40
41
[CmdletBinding()]
param(
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string] $CsvConfigFile,
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string] $CsvOutputFile,
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[switch] $force,
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[int] $ThrottleLimit = 10
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Make sure the input file does exist
if (-not (Test-Path -Path $CsvConfigFile)) {
Write-Error "Input CSV File must exist, please choose a valid file location..."
}
# Make sure the output file doesn't exist
if ((Test-Path -Path $CsvOutputFile) -and (-not $force.IsPresent)) {
Write-Error "Output File cannot already exist, please choose a location to create a new output file..."
}
Import-Module ../Az.LabServices.BulkOperations.psm1 -Force
$scriptstartTime = Get-Date
Write-Host "Executing Lab Creation Script, starting at $scriptstartTime" -ForegroundColor Green
$labs = $CsvConfigFile | Import-LabsCsv | Add-AzLabsUsersBulk -ThrottleLimit $ThrottleLimit
$labs | Export-LabsCsv -CsvConfigFile $CsvOutputFile -Force:$force.IsPresent
Write-Host "Completed running Bulk Lab Creation script, total duration $([math]::Round(((Get-Date) - $scriptstartTime).TotalMinutes, 1)) minutes" -ForegroundColor Green