Automating WimWizard
Review the scheduled-task example for updating a DeployR install.wim with WimWizard. It expects the script path, image path and task name to be chosen for the deployment.
Source-derived reference
These notes were recovered from OneNote. Configuration, permissions and operating results have not been freshly verified. Confirm the applicable authority and environment before acting.
Automating the WimWizard install.wim updating process is as simple as creating a scheduled task. The following powershell code can be used to create and update a scheduled task.
<# Create-WimWizard-ScheduledTask
This script will create a scheduled task that runs WimWizard to automatically update a Windows install.wim file.
Simply change the following variables.
$WimWizardPath - the full path to the WimWizard.ps1 script.
$WimPath - the full path to the DeployR Windows OS content file.
If a new Windows OS version is uploaded to DeployR simply change the $WimPath variable and rerun this script.
It will update the existing scheduled task.
$TaskName - your desired name for the scheduled task.
#>
### Declare some variables
# These variables are the only ones that should be changed.
$WimWizardPath = "D:\WimWizard-main\WimWizard.ps1"
$WimPath = "D:\2Pint Software\DeployR\Content\c9a97974-97ad-4609-9cd8-4ecab974995f\1\install.wim" #This is the local path of the DeployR OS Content Item HINT: Open Content Item to get the relative path.
$TaskName = "Run-WimWizard-PatchExistingWim"
# Don't change these variables (unless you want to change the task name of course)
$Action = "pwsh.exe"
$ActionArguments = "-noprofile -executionpolicy bypass -file $WimWizardPath -PatchExistingWim $WimPath -OutputPath $WimPath -Unattended"
$STAction = New-ScheduledTaskAction -Execute $Action -Argument $ActionArguments
$STTrigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Wednesday -At 6:00AM
$STPrincipal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
$STSettings = New-ScheduledTaskSettingsSet -Compatibility Win8
# Update or Create the Scheduled task
# Check if scheduled task exists and update. If not create the scheduled task.
If (Get-ScheduledTask -TaskName $TaskName -ErrorAction Ignore) {
# Update the Scheduled Task
Set-ScheduledTask -TaskName $TaskName -Action $STAction -Trigger $STTrigger -Principal $STPrincipal -Settings $STSettings
}
Else {
# Create the Scheduled Task
Register-ScheduledTask -TaskName $TaskName -Action $STAction -Trigger $STTrigger -Principal $STPrincipal -Settings $STSettings
}