how to fix duplicate wsus clientIds with powershell

get hostname from zabbix:

from zabbix_api import ZabbixAPI
zapi = ZabbixAPI(server="http://10.1.1.1/")
zapi.login("Admin", "zabbix")
# print(zapi.hostgroup.get({"output": ["groupid", "name"]}))
host = zapi.host.get({"groupids": "28", "output": ["host"]})
hostname = []
for h in host:
    hostname.append(h['host'])
print(hostname)
print(len(hostname))

get hostname from activediretory:

$c=Get-ADComputer -Filter * -SearchBase OU='wsus,DC=chenshi,DC=net'|select -ExpandProperty Name
Invoke-Command -Credential chenshi.net\chenshi -ComputerName $c -ScriptBlock {Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chenshi.net/wsusClientIdFix.ps1'))}

ps script:

Stop-Service -Name wuauserv
#if exist AccountDomainSid
Remove-ItemProperty  -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\ -Name AccountDomainSid, SusClientId, SusClientIDValidation -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force C:\Windows\SoftwareDistribution\*
Start-Service -Name wuauserv
wuauclt /resetauthorization /detectnow
#(New-Object -ComObject "Microsoft.Update.ServiceManager").Services | Select-Object Name, IsDefaultAUService