Packer.Images/scripts/New-WindowsImageJob.ps1
djpbessems 02907e7c65
All checks were successful
continuous-integration/drone/push Build is passing
Delete commit history (containing proprietary code)
2021-01-23 15:59:06 +01:00

51 lines
1.2 KiB
PowerShell

#Requires -Modules 'dism'
Param(
[Parameter(Mandatory)]
[string]$ImageName,
[Parameter(Mandatory)]
[string]$SourceFolder,
[Parameter(Mandatory)]
[string]$DestinationFile
)
$StartJobSplat = @{
ArgumentList = $ImageName, $SourceFolder, $DestinationFile
ScriptBlock = {
Param(
$ImageName,
$SourceFolder,
$DestinationFile
)
$NewWindowsImageSplat = @{
Name = $ImageName
CapturePath = $SourceFolder
ImagePath = $DestinationFile
Verify = $True
}
New-WindowsImage @NewWindowsImageSplat
}
}
$Job = Start-Job @StartJobSplat
While ($Job.State -eq 'Running') {
$GetItemSplat = @{
Path = $DestinationFile
ErrorAction = 'SilentlyContinue'
}
$OutputFile = Get-Item @GetItemSplat
If ($OutputFile) {
Write-Host "Export in progress ... $($OutputFile.FullName); Size: $('{0:n2}' -f ($OutputFile.Length / 1MB))MB"
}
Else {
Write-Host "Export initiating ... "
}
$StartSleepSplat = @{
Seconds = 30
}
Start-Sleep @StartSleepSplat
}
Receive-Job $Job
Remove-Job $Job