When running a PSU script as a job. The scripts environment is powershell 7 and PS version is 7.5.1
An error occurs when running
$allGPOs = Get-GPO -All
$unlinkedGPOs = @()
$allGPOs | Foreach-Object -Parallel {$GUID = $.Id; $Report = Get-GPOReport -GUID $GUID.GUID -ReportType XML | Select-String -NotMatch “”; If ($Null -NE $Report){ $unlinkedGPOs += $}} -ThrottleLimit 5
The server does not support the requested critical extension. (Exception from HRESULT: 0x8007202C)
Does PSU not support the parallel flag and only running scripts as jobs?
@Philpsu check this doc: https://docs.powershelluniversal.com/platform/variables#foreach-object-parallel
I’ve not personally done it, just it says you have to use the $using:
keyword.
Google provided the following AI response:
$objects | ForEach-Object -Parallel {
$internalVariable = $using:externalVariable
# Perform operations on $_ in parallel
} -ThrottleLimit 16
I did try that out and looking at the documentation it appears that is based off using secrets. I got an error of “The value of the using variable ‘$using:externalVariable’ cannot be retrieved because it has not been set in the local session.”, which would make sense as no such thing exist and the variable in the code would be $_. Thank you for the suggestion but I am still stuck.