Set Intel Wi-Fi preferred band via Script

Had a strange issue at a site I support this week in that due to both 2.4Ghz and 5Ghz bands transmit power settings both being set on auto meaning they were both similar db Windows 20/04 was defaulting to the 2.4Ghz band resulting in slower access speeds for Clients.
This was easily overcome by setting the preferred band on the devices.
Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Control\Class -Recurse -ErrorAction silentlyContinue | Get-ItemProperty | ForEach-Object {if ($_.RoamingPreferredBandType -ge 0) { $path = $_.pspath Set-ItemProperty $path -name "RoamingPreferredBandType" -Value "2" write-output $_.pspath } }