PSWindowsUpdate
PSWindowsUpdate copied to clipboard
Invoke-WUJob with splat throws error.
$WUJobSplat = @{
TaskName = "PSWindowsUpdate"
Confirm = $False
Verbose = $True
Script = 'Import-Module PSWindowsUpdate; Install-WindowsUpdate -AcceptAll -NotCategory "Drivers" -IgnoreReboot'
}
If ($TriggerDate -eq "Now") {
$WUJobSplat.Add("RunNow", "1")
} Else {
$WUJobSplat.Add("TriggerDate", $TriggerDate)
$WuJobSplat.Add("EndBoundary", $($TriggerDate).AddHours(5))
}
Invoke-WUJob @WUJobSplat
A positional parameter cannot be found that accepts argument '$null'. + CategoryInfo : InvalidArgument: (:) [Invoke-WUJob], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,PSWindowsUpdate.InvokeWUJob + PSComputerName : REDACTED