From d68aa38e5d1b041dea7b258ea9130c89a30b38ff Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:25:26 +0200 Subject: [PATCH 01/10] Update Start-OSDCloud.ps1 The ImageFileItem parameter has been added, which updates the ImageFileItem property in the $global:StartOSDCloud variable. If ImageFileItem is provided, the existence of the specified file is checked. If the file does not exist, the user will be prompted to manually select an ImageFileItem as usual. The integer value for OSImageIndex is also validated based on the provided ImageFileItem. If the specified index does not exist, the user will be prompted to manually select an item, as per the usual process. In Summary: It is now possible to perform a zero-touch deployment for offline images. Example: Start-OSDCloud -ImageFileItem "\windows 11 - 24H2 - NLD\install.wim" -OSImageIndex 3 --- Public/Start-OSDCloud.ps1 | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/Public/Start-OSDCloud.ps1 b/Public/Start-OSDCloud.ps1 index 443a4a607..bd4e82991 100644 --- a/Public/Start-OSDCloud.ps1 +++ b/Public/Start-OSDCloud.ps1 @@ -1,4 +1,4 @@ -function Start-OSDCloud { +function Start-OSDCloud { <# .SYNOPSIS Starts the OSDCloud Windows 10 or 11 Build Process from the OSD Module or a GitHub Repository @@ -110,6 +110,11 @@ [System.Management.Automation.SwitchParameter] $FindImageFile, + #Uses a specified WIM/ESD file + [Parameter(ParameterSetName = 'CustomImage')] + [System.String] + $ImageFileItem, + #Downloads a WIM file specified by the URK [Parameter(ParameterSetName = 'CustomImage')] [System.String] @@ -139,7 +144,7 @@ GetDiskFixed = $null GetFeatureUpdate = $null ImageFileFullName = $null - ImageFileItem = $null + ImageFileItem = $ImageFileItem #changed ImageFileName = $null ImageFileSource = $null ImageFileDestination = $null @@ -184,6 +189,7 @@ TimeStart = Get-Date ZTI = $ZTI } + #================================================= # Update Defaults #================================================= @@ -286,11 +292,42 @@ Write-Host -ForegroundColor DarkGray "ImageFileUrl: $($Global:StartOSDCloud.ImageFileUrl)" Write-Host -ForegroundColor DarkGray "OSImageIndex: $($Global:StartOSDCloud.OSImageIndex)" } - if ($PSBoundParameters.ContainsKey('FindImageFile')) { - $Global:StartOSDCloud.ImageFileItem = Select-OSDCloudFileWim + if ($PSBoundParameters.ContainsKey('FindImageFile') -or $PSBoundParameters.ContainsKey('ImageFileItem')) { + + if ($Global:StartOSDCloud.ImageFileItem){ + + $OsdCloudFileWimCheck = Test-OSDCloudFileWim -ImageFileItem $Global:StartOSDCloud.ImageFileItem + + If ($OsdCloudFileWimCheck){ + + $Global:StartOSDCloud.ImageFileItem = $OsdCloudFileWimCheck + + }else { + Write-Warning "ImageFileItem $($Global:StartOSDCloud.ImageFileItem) does not exists or is not a valid WIM, ESD or install.swm file, please select one from the list below.." + $Global:StartOSDCloud.ImageFileItem = Select-OSDCloudFileWim + } + + }else{ + $Global:StartOSDCloud.ImageFileItem = Select-OSDCloudFileWim + } if ($Global:StartOSDCloud.ImageFileItem) { - $Global:StartOSDCloud.OSImageIndex = Select-OSDCloudImageIndex -ImagePath $Global:StartOSDCloud.ImageFileItem.FullName + if ($Global:StartOSDCloud.OSImageIndex){ + + $OSImageIndexCheck = Test-OSDCloudImageIndex -ImagePath $Global:StartOSDCloud.ImageFileItem.FullName -Index $Global:StartOSDCloud.OSImageIndex + + If ($OSImageIndexCheck){ + + $Global:StartOSDCloud.OSImageIndex = $OSImageIndexCheck + + }else { + Write-Warning "OSImageIndex $($Global:StartOSDCloud.OSImageIndex) does not exists, please select one from the list below.." + $Global:StartOSDCloud.OSImageIndex = Select-OSDCloudImageIndex -ImagePath $Global:StartOSDCloud.ImageFileItem.FullName + } + + }else{ + $Global:StartOSDCloud.OSImageIndex = Select-OSDCloudImageIndex -ImagePath $Global:StartOSDCloud.ImageFileItem.FullName + } Write-Host -ForegroundColor DarkGray "ImageFileItem: $($Global:StartOSDCloud.ImageFileItem.FullName)" Write-Host -ForegroundColor DarkGray "OSImageIndex: $($Global:StartOSDCloud.OSImageIndex)" @@ -305,6 +342,7 @@ } } } + #================================================= # ParameterSet Default #================================================= From 086e505fc73bf7638f3e0457657f9576308ee1ac Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:27:17 +0200 Subject: [PATCH 02/10] Create Test-OSDCloudFileWim.ps1 --- Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 diff --git a/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 b/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 new file mode 100644 index 000000000..727fc3471 --- /dev/null +++ b/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 @@ -0,0 +1,41 @@ +<# +.SYNOPSIS +Test if WIM file exists + +.DESCRIPTION +Test if WIM file exists + +.LINK +https://github.com/OSDeploy/OSD/tree/master/Docs +#> +function Test-OSDCloudFileWim { + [CmdletBinding()] + param ( + + $ImageFileItem + + ) + + $Name = Split-Path $ImageFileItem -Leaf + $Path = Split-Path $ImageFileItem + + + $Result = Get-PSDrive -PSProvider FileSystem | ForEach-Object { + # Exclude C:\ and X:\ drives + if ($_.Name -notin @('C', 'X')) { + $item = Get-Item "$($_.Name):$("\OSDCloud\OS\$($Path)\$($Name)")" -Filter "*.wim,*.esd,*.install.swm" -Force -ErrorAction SilentlyContinue + + # If we have found an item, return it + if ($item) { + return $item + } + } + } + + If ($Result){ + + Return Get-Item (Join-Path $Result.Directory $Result.Name) + + } + +} From 6dc70f4ef9ff9a674ed6432afed165100e1bf237 Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:27:46 +0200 Subject: [PATCH 03/10] Create Test-OSDCloudImageIndex.ps1 --- Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 diff --git a/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 b/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 new file mode 100644 index 000000000..4b82cca60 --- /dev/null +++ b/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 @@ -0,0 +1,27 @@ +<# +.SYNOPSIS +Test if Image Index exists + +.DESCRIPTION +Test if Image Index exists + +.LINK +https://github.com/OSDeploy/OSD/tree/master/Docs +#> + +function Test-OSDCloudImageIndex { + [CmdletBinding()] + param ( + [string]$ImagePath, + [int]$Index + ) + + $Image = Get-WindowsImage -ImagePath $ImagePath -Index $Index -ErrorAction Ignore + + If ($Image){ + + Return $Image.ImageIndex + + } + +} From 107803ee2a04df66a443e59a736ccb61e0befb5e Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:35:32 +0200 Subject: [PATCH 04/10] Create Test-OSDCloudImageIndex.md --- Docs/Test-OSDCloudImageIndex.md | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Docs/Test-OSDCloudImageIndex.md diff --git a/Docs/Test-OSDCloudImageIndex.md b/Docs/Test-OSDCloudImageIndex.md new file mode 100644 index 000000000..db7dd91fe --- /dev/null +++ b/Docs/Test-OSDCloudImageIndex.md @@ -0,0 +1,59 @@ +--- +external help file: OSD-help.xml +Module Name: OSD +online version: https://github.com/OSDeploy/OSD/tree/master/Docs +schema: 2.0.0 +--- + +# Test-OSDCloudImageIndex + +## SYNOPSIS +Tests if a specific Image Index exists within a provided image file. + +## SYNTAX + +``` +Test-OSDCloudImageIndex [[-ImagePath] ] [[-Index] ] [] +``` + +## DESCRIPTION +This function checks whether a given Image Index exists within the specified image file. It uses the Get-WindowsImage cmdlet to query the image file and validate if the specified index is available. If the index exists, it returns the ImageIndex value; otherwise, it will return nothing. + +## EXAMPLES + +### Example 1 - Check if an image index exists +```powershell +PS C:\> Test-OSDCloudImageIndex -ImagePath "install.wim" -Index 3 +``` +This command will check if the image index 3 exists in the image file located at \OSDCloud\OS\install.wim. If it exists, the function will return the ImageIndex value. + +## PARAMETERS + +### -ImagePath +The path to the image file (e.g., D:\OSCloud\OS\install.wim or D:\OSCloud\OS\images\image.esd). + +```yaml +Type: String +Required: true +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` +### -Index +The index of the image within the image file to check. +```yaml +Type: Int +Required: true +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). +## INPUTS +## OUTPUTS +## NOTES +## RELATED LINKS +[https://github.com/OSDeploy/OSD/tree/master/Docs](https://github.com/OSDeploy/OSD/tree/master/Docs) From 4a04ce09e793dff230913a31ba33ee3b17e59e64 Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:37:19 +0200 Subject: [PATCH 05/10] Create Test-OSDCloudFileWim.md --- Docs/Test-OSDCloudFileWim.md | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Docs/Test-OSDCloudFileWim.md diff --git a/Docs/Test-OSDCloudFileWim.md b/Docs/Test-OSDCloudFileWim.md new file mode 100644 index 000000000..61f853c7b --- /dev/null +++ b/Docs/Test-OSDCloudFileWim.md @@ -0,0 +1,49 @@ +--- +external help file: OSD-help.xml +Module Name: OSD +online version: https://github.com/OSDeploy/OSD/tree/master/Docs +schema: 2.0.0 +--- + +# Test-OSDCloudFileWim + +## SYNOPSIS +Tests if a .wim, .esd, or .install.swm file exists in the specified directory. + +## SYNTAX + +``` +Test-OSDCloudImageIndex [[-ImagePath] ] [[-Index] ] [] +``` + +## DESCRIPTION +This function checks whether a .wim, .esd, or .install.swm file exists at the given path. It uses the Get-PSDrive cmdlet to search through available file system drives (excluding C:\ and X:\), and then it attempts to find a matching file. If a matching file is found, the function returns the file object. If no such file exists, the function returns nothing. +## EXAMPLES + +### Example 1 - Check if a WIM file exists +```powershell +PS C:\> Test-OSDCloudFileWim -ImageFileItem "D:\images\install.wim" +``` +This command will search for install.wim in the D:\images\ directory. If it exists, it returns the file object. + +## PARAMETERS + +### -ImageFileItem +The path to the image file or directory (e.g., D:\images\install.wim). The function will check for .wim, .esd, or .install.swm files in the specified path. + +```yaml +Type: String +Required: true +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). +## INPUTS +## OUTPUTS +## NOTES +## RELATED LINKS +[https://github.com/OSDeploy/OSD/tree/master/Docs](https://github.com/OSDeploy/OSD/tree/master/Docs) From 5fe270883cc80267a13526191093cfc068a3a06b Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:39:09 +0200 Subject: [PATCH 06/10] Update Test-OSDCloudImageIndex.ps1 --- Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 b/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 index 4b82cca60..06d63b740 100644 --- a/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 +++ b/Public/OSDCloudTS/Test-OSDCloudImageIndex.ps1 @@ -12,7 +12,10 @@ https://github.com/OSDeploy/OSD/tree/master/Docs function Test-OSDCloudImageIndex { [CmdletBinding()] param ( + [Parameter(Mandatory = $true)] [string]$ImagePath, + + [Parameter(Mandatory = $true)] [int]$Index ) From 1c091fdd12ba3b34298da88edd9392fe48ddc748 Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:39:23 +0200 Subject: [PATCH 07/10] Update Test-OSDCloudFileWim.ps1 --- Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 b/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 index 727fc3471..41777a06c 100644 --- a/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 +++ b/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 @@ -12,6 +12,7 @@ function Test-OSDCloudFileWim { [CmdletBinding()] param ( + [Parameter(Mandatory = $true)] $ImageFileItem ) From ab6ff0558f707cdbac29563dca321adc7c47a95c Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:39:33 +0200 Subject: [PATCH 08/10] Update Test-OSDCloudFileWim.ps1 --- Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 b/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 index 41777a06c..967548e09 100644 --- a/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 +++ b/Public/OSDCloudTS/Test-OSDCloudFileWim.ps1 @@ -13,7 +13,7 @@ function Test-OSDCloudFileWim { param ( [Parameter(Mandatory = $true)] - $ImageFileItem + [string]$ImageFileItem ) From 723c813f6512b801d0a55057a4efca58846c6d18 Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:43:38 +0200 Subject: [PATCH 09/10] Update Test-OSDCloudFileWim.md --- Docs/Test-OSDCloudFileWim.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Test-OSDCloudFileWim.md b/Docs/Test-OSDCloudFileWim.md index 61f853c7b..d50573c59 100644 --- a/Docs/Test-OSDCloudFileWim.md +++ b/Docs/Test-OSDCloudFileWim.md @@ -13,7 +13,7 @@ Tests if a .wim, .esd, or .install.swm file exists in the specified directory. ## SYNTAX ``` -Test-OSDCloudImageIndex [[-ImagePath] ] [[-Index] ] [] +Test-OSDCloudFileWim [-ImageFileItem] [] ``` ## DESCRIPTION From cc2333631cc7ef068b51b81ddf2d49b8f7b6031c Mon Sep 17 00:00:00 2001 From: ricoroodenburg <79546116+ricoroodenburg@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:44:08 +0200 Subject: [PATCH 10/10] Update Test-OSDCloudImageIndex.md --- Docs/Test-OSDCloudImageIndex.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Test-OSDCloudImageIndex.md b/Docs/Test-OSDCloudImageIndex.md index db7dd91fe..310d8955e 100644 --- a/Docs/Test-OSDCloudImageIndex.md +++ b/Docs/Test-OSDCloudImageIndex.md @@ -13,7 +13,7 @@ Tests if a specific Image Index exists within a provided image file. ## SYNTAX ``` -Test-OSDCloudImageIndex [[-ImagePath] ] [[-Index] ] [] +Test-OSDCloudImageIndex [-ImagePath] [-Index] [] ``` ## DESCRIPTION