diff --git a/Public/OSDCloudTS/Select-OSDCloudFileWim.ps1 b/Public/OSDCloudTS/Select-OSDCloudFileWim.ps1 index 5bca3f254..6f4f0e1ed 100644 --- a/Public/OSDCloudTS/Select-OSDCloudFileWim.ps1 +++ b/Public/OSDCloudTS/Select-OSDCloudFileWim.ps1 @@ -10,7 +10,9 @@ https://github.com/OSDeploy/OSD/tree/master/docs #> function Select-OSDCloudFileWim { [CmdletBinding()] - param () + param ( + [switch]$ZTI + ) $i = $null $Results = @() @@ -34,6 +36,13 @@ function Select-OSDCloudFileWim { $Results | Select-Object -Property Selection, Name, Directory | Format-Table | Out-Host + if ($ZTI) { + if (($Results | Measure-Object).Count -eq 1) { + Return Get-Item (Join-Path $Results.Directory $Results.Name) + } + throw "[$(Get-Date -format s)] [$($MyInvocation.MyCommand.Name)] -ZTI requires exactly one Windows Image candidate under \OSDCloud\OS\, found $(($Results | Measure-Object).Count). Remove the extras or run without -ZTI to select interactively." + } + do { $SelectReadHost = Read-Host -Prompt "Select a Windows Image to apply by Selection [Number]" } diff --git a/Public/OSDCloudTS/Select-OSDCloudImageIndex.ps1 b/Public/OSDCloudTS/Select-OSDCloudImageIndex.ps1 index dad301028..cd30783bb 100644 --- a/Public/OSDCloudTS/Select-OSDCloudImageIndex.ps1 +++ b/Public/OSDCloudTS/Select-OSDCloudImageIndex.ps1 @@ -1,7 +1,8 @@ function Select-OSDCloudImageIndex { [CmdletBinding()] param ( - [string]$ImagePath + [string]$ImagePath, + [switch]$ZTI ) $Results = Get-WindowsImage -ImagePath $ImagePath @@ -14,6 +15,10 @@ function Select-OSDCloudImageIndex { if ($Results) { $Results | Select-Object -Property ImageIndex, ImageName | Format-Table | Out-Host + if ($ZTI) { + Return $Results[0].ImageIndex + } + do { $SelectReadHost = Read-Host -Prompt "Select an Image to apply by ImageIndex [Number]" } diff --git a/Public/Start-OSDCloud.ps1 b/Public/Start-OSDCloud.ps1 index 62302ffc9..97a795528 100644 --- a/Public/Start-OSDCloud.ps1 +++ b/Public/Start-OSDCloud.ps1 @@ -386,10 +386,10 @@ function Start-OSDCloud { Write-Host -ForegroundColor DarkGray "OSImageIndex: $($Global:StartOSDCloud.OSImageIndex)" } if ($PSBoundParameters.ContainsKey('FindImageFile')) { - $Global:StartOSDCloud.ImageFileItem = Select-OSDCloudFileWim + $Global:StartOSDCloud.ImageFileItem = Select-OSDCloudFileWim -ZTI:$Global:StartOSDCloud.ZTI if ($Global:StartOSDCloud.ImageFileItem) { - $Global:StartOSDCloud.OSImageIndex = Select-OSDCloudImageIndex -ImagePath $Global:StartOSDCloud.ImageFileItem.FullName + $Global:StartOSDCloud.OSImageIndex = Select-OSDCloudImageIndex -ImagePath $Global:StartOSDCloud.ImageFileItem.FullName -ZTI:$Global:StartOSDCloud.ZTI Write-Host -ForegroundColor DarkGray "ImageFileItem: $($Global:StartOSDCloud.ImageFileItem.FullName)" Write-Host -ForegroundColor DarkGray "OSImageIndex: $($Global:StartOSDCloud.OSImageIndex)"