diff --git a/Hyper-V/createVM.ps1 b/Hyper-V/createVM.ps1 index 248375c..fcd532d 100644 --- a/Hyper-V/createVM.ps1 +++ b/Hyper-V/createVM.ps1 @@ -84,8 +84,8 @@ log "Temporarily setting VM name to $VMName" log "Copying the $version disk from $templates..." try { - Copy-Item -Path "$($tempaltes)\GM-$($version).vhdx" -Destination "$($virtualHardDisks)\$($VMName).vhdx" -Force | Out-Null - log "Disk coppied to $virtualHardDisks" + Copy-Item -Path "$($templates)\GM-$($version).vhdx" -Destination "$($virtualHardDisks)\$($VMName).vhdx" -Force | Out-Null + log "Disk copied to $virtualHardDisks" } catch { @@ -123,7 +123,7 @@ log "New VM Name will be $newName" try { - Renamve-VM -Name $VMName -NewName $newVMName + Rename-VM -Name $VMName -NewName $newVMName log "VM renamed to $newVMName" } catch diff --git a/checkforOOBE.ps1 b/checkforOOBE.ps1 new file mode 100644 index 0000000..6b1af6d --- /dev/null +++ b/checkforOOBE.ps1 @@ -0,0 +1,27 @@ +[string]$AutoPilotSettingsKey = 'HKLM:\SOFTWARE\Microsoft\Provisioning\AutopilotSettings' +[string]$DevicePrepName = 'DevicePreparationCategory.Status' +[string]$DeviceSetupName = 'DeviceSetupCategory.Status' +[bool]$DevicePrepNotRunning = $false +[bool]$DeviceSetupNotRunning = $false + +$DevicePrepDetails = (Get-ItemProperty -Path $AutoPilotSettingsKey -Name $DevicePrepName -ErrorAction 'Ignore').$DevicePrepName +$DeviceSetupDetails = (Get-ItemProperty -Path $AutoPilotSettingsKey -Name $DeviceSetupName -ErrorAction 'Ignore').$DeviceSetupName + +if (-not [string]::IsNullOrEmpty($DevicePrepDetails)) { + $DeviceSetupDetails = $DeviceSetupDetails | ConvertFrom-Json +} +else { + Write-Output "No_Autopilot_Config" + Exit +} + + +if ($DeviceSetupDetails.categoryState -eq "inProgress") { + Write-Output "ESP_Running" + Exit +} +else { + Write-Output "ESP_NotRunning" + Exit +} +