This repository has been 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
/
Copy pathPublishAll.ps1
45 lines (35 loc) · 1.87 KB
/
PublishAll.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
39
40
41
42
43
44
45
[CmdletBinding()]
param(
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string]
$CsvConfigFile,
[parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[string]
$CsvOutputFile,
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[switch] $force,
[parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)]
[int]
$ThrottleLimit = 10
)
# 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..."
}
$outerScriptstartTime = Get-Date
Write-Host "Executing Lab Creation Script, starting at $outerScriptstartTime" -ForegroundColor Green
Import-Module ../Az.LabServices.BulkOperations.psm1 -Force
$labAccountResults = $CsvConfigFile |
Import-LabsCsv | # Import the CSV File into objects, including validation & transforms
New-AzLabPlansBulk -ThrottleLimit $ThrottleLimit | # Create all the lab accounts
New-AzLabsBulk -ThrottleLimit $ThrottleLimit | # Create all labs
Publish-AzLabsBulk -ThrottleLimit $ThrottleLimit # Publish all the labs
# Write out the results
$labAccountResults | Export-LabsCsv -CsvConfigFile $CsvOutputFile -Force:$force.IsPresent
$labAccountResults | Select-Object -Property ResourceGroupName, LabPlanName, LabName, LabPlanResult, LabResult, PublishResult | Format-Table
Write-Host "Completed running Bulk Lab Creation script, total duration $(((Get-Date) - $outerScriptstartTime).TotalMinutes) minutes" -ForegroundColor Green