Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Public/OSDCloudTS/Select-OSDCloudFileWim.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ https://github.com/OSDeploy/OSD/tree/master/docs
#>
function Select-OSDCloudFileWim {
[CmdletBinding()]
param ()
param (
[switch]$ZTI
)

$i = $null
$Results = @()
Expand All @@ -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]"
}
Expand Down
7 changes: 6 additions & 1 deletion Public/OSDCloudTS/Select-OSDCloudImageIndex.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function Select-OSDCloudImageIndex {
[CmdletBinding()]
param (
[string]$ImagePath
[string]$ImagePath,
[switch]$ZTI
)

$Results = Get-WindowsImage -ImagePath $ImagePath
Expand All @@ -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]"
}
Expand Down
4 changes: 2 additions & 2 deletions Public/Start-OSDCloud.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down