Scope Variable usage

I have this script that places a variable to adjust for PS 2.0 but as my DCs are all higher, wanted to try it with a Remote Variable ($Using:<VariableName>)

I read this: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_variables?view=powershell-7.1

…but not seeing how to adapt for my particular script.

Current script:

$DCs = [DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() |
    Select-Object -ExpandProperty Sites |
        Select-Object -ExpandProperty Servers |
            Select-Object -ExpandProperty Name

Invoke-Command -ComputerName $DCs {
    $Patches = 'KB4586793', 'KB4580422', 'KB4587735' #Server 2016
    Get-HotFix -Id $Patches
}		 -ErrorAction SilentlyContinue -ErrorVariable Problem
foreach ($p in $Problem) {
    if ($p.origininfo.pscomputername) {
        Write-Warning -Message "Patch not found on $($p.origininfo.pscomputername)"
    }
    elseif ($p.targetobject) {
        Write-Warning -Message "Unable to connect to $($p.targetobject)"
    }
}

How would I adapt this:

$ps = "*PowerShell*"
Invoke-Command -ComputerName S1 -ScriptBlock {
  Get-WinEvent -LogName $Using:ps
}

…into my code, pulling the "$Patches = " line out of the Invoke-Command?

Would it be:
$Patches = “‘KB4586793’, ‘KB4580422’, ‘KB4587735’”

then, under Invoke-Command:

Get-HotFix -Id $Using:Patches

Yes, if it is not contained in the scriptblock, then you need to use the Using keyword to reference the variable outside of the scriptblock.

Very cool…running…thank you for confirming usage here.

Hasn’t finished but will let it go for awhile against those 3 Patches.