Skip to content

Commit

Permalink
prompt for input+time counter changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromirk committed Aug 25, 2021
1 parent d810944 commit 14a006b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 8 additions & 4 deletions Scripts/2_CreateParentDisks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,15 @@ If (-not $isAdmin) {
#region finishing
WriteSuccess "Script finished at $(Get-date) and took $(((get-date) - $StartDateTime).TotalMinutes) Minutes"

WriteInfoHighlighted "Do you want to cleanup unnecessary files and folders? Deault (Y)"
WriteInfo "`t (.\Temp\ 1_Prereq.ps1 2_CreateParentDisks.ps1 and rename 3_deploy to just deploy)"
If ((Read-host "`t Please type Y or N") -like "*N"){
$options = [System.Management.Automation.Host.ChoiceDescription[]] @(
<# 0 #> New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Cleanup .\Temp\ 1_Prereq.ps1 2_CreateParentDisks.ps1 and rename 3_deploy.ps1 to just deploy.ps1"
<# 1 #> New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Keep files (in case DC was not created sucessfully)"
)
$response = $host.UI.PromptForChoice("Unnecessary files cleanup","Do you want to cleanup unnecessary files and folders?", $options, 0 <#default option#>)

If ($response -eq 1){
$renamed = $false
WriteInfo "`t You typed N, skipping cleanup"
WriteInfo "Skipping cleanup"
}else{
$renamed = $true
WriteInfo "`t `t Cleaning unnecessary items"
Expand Down
8 changes: 5 additions & 3 deletions Scripts/3_Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,9 @@ If (-not $isAdmin) {
} elseif($LabConfig.AutoStartAfterDeploy -eq "DeployedOnly") {
$startVMs = 2
}


$CheckPointTime=Get-Date

if(-not $LabConfig.ContainsKey("AutoStartAfterDeploy") -and $AllVMs.Count -gt 0) {
$options = [System.Management.Automation.Host.ChoiceDescription[]] @(
<# 0 #> New-Object System.Management.Automation.Host.ChoiceDescription "&No", "No VM will be started."
Expand Down Expand Up @@ -1610,7 +1612,7 @@ If (-not $isAdmin) {
if((Get-TelemetryLevel) -in $TelemetryEnabledLevels) {
WriteInfo "Sending telemetry info"
$metrics = @{
'script.duration' = [Math]::Round(((Get-Date) - $StartDateTime).TotalSeconds, 2)
'script.duration' = [Math]::Round(($CheckPointTime - $StartDateTime).TotalSeconds, 2)
'lab.vmsCount.active' = ($AllVMs | Measure-Object).Count # how many VMs are running
'lab.vmsCount.provisioned' = ($provisionedVMs | Measure-Object).Count # how many VMs were created by this script run
}
Expand All @@ -1626,7 +1628,7 @@ If (-not $isAdmin) {
}

#write how much it took to deploy
WriteInfo "Script finished at $(Get-Date) and took $(((Get-Date) - $StartDateTime).TotalMinutes) Minutes"
WriteInfo "Script finished at $CheckPointTime and took $(($CheckPointTime - $StartDateTime).TotalMinutes) Minutes"

Stop-Transcript

Expand Down

0 comments on commit 14a006b

Please sign in to comment.