Configure WSUS client with Powershell and Regedit

My use case for a customer was to configure WSUS for a couple of DMZ servers. The DMZ servers are not domain-joined. So I create a PowerShell script to configure the registry so I can easily deploy the settings to the servers. You can use this script also for non domain-joined servers # Script for WSUS configuration on non-domain joined servers # First stop the Windows service Get-Service -name wuauserv | stop-service # Variables $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" $name1 = "TargetGroup" $value1 = "Production" $name2 = "WUServer" $value2 = "http://wsus.domain.local:8530" $name3 = "WUStatusServer" $value3 = "http://wsus.domain.local:8530" $name4 = "DoNotConnectToWindowsUpdateInternetLocations" $value4 = "1" $name5 = "TargetGroupEnabled" $value5 = "1" $registryPathAU = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" $nameAU1 = "AUOptions" $valueAU1 = "3" $nameAU2 = "UseWUServer" $valueAU2 = "1" # Inject registry IF(!(Test-Path $registryPath)) { New-Item -Path $registryPath -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name3 -Value $value3 -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name4 -Value $value4 -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name5 -Value $value5 -PropertyType DWORD -Force | Out-Null } ELSE { New-ItemProperty -Path $registryPath -Name $name1 -Value $value1 -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name2 -Value $value2 -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name3 -Value $value3 -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name4 -Value $value4 -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $registryPath -Name $name5 -Value $value5 -PropertyType DWORD -Force | Out-Null } IF(!(Test-Path $registryPathAU)) { New-Item -Path $registryPathAU -Force | Out-Null New-ItemProperty -Path $registryPathAU -Name $nameAU1 -Value $valueAU1 -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $registryPathAU -Name $nameAU2 -Value $valueAU2 -PropertyType DWORD -Force | Out-Null } ELSE { New-ItemProperty -Path $registryPathAU -Name $nameAU1 -Value $valueAU1 -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $registryPathAU -Name $nameAU2 -Value $valueAU2 -PropertyType DWORD -Force | Out-Null } # Start the Windows service Get-Service -name wuauserv | start-service # Find updates and report to the WSUS server $updateSession = new-object -com "Microsoft.Update.Session"; $updates=$updateSession.CreateupdateSearcher().Search($criteria).Updates Start-sleep -seconds 10 wuauclt /detectnow wuauclt /reportnow c:\windows\system32\UsoClient.exe startscan I save this file on the WSUS server itself at http://wsus.domain.local:8530/script.txt so I can download and run it from the DMZ environment. ...

May 10, 2022 · 2 min · thomasf

Powershell better tab autocomplete

With Powershell ISE you can use CTRL + SPACE for auto completion. But when you work in a native Powershell window you don’t have this option. And many often you cycle with tab completion trough the powershell and because you press the TAB button too soon you have to remove characters and cycle again trough all the commands. Unit now ;-) There is an easy fix you can implement so the Powershell have the same auto completion like bash. ...

April 5, 2022 · 1 min · thomasf
angif-boot-up-your-computer

Repair Debian boot after Windows update

Today I update my dual boot system and unfortunately my Debian OS wasn’t booting anymore. The root cause was that Windows decide to reclaim the EFI boot. The fix is quite easy. Type mountvol P: /S Check the EFI boot partition data And fix your boot the this command: bcdedit.exe /set {bootmgr} path \EFI\Debian\grubx64.efi As you can see in the screenshot, this also work for EndeavourOS and Ubuntu and probably for a lot other Linux EFI boot systems. ...

March 6, 2022 · 1 min · thomasf
2021-12-01 12_04_15-file transfer at DuckDuckGo

Git SFTP

I was working for an elementary website of a friend of mine. I pushed the website to GitHub so it’s was way easier to maintain the site. But I thought it must be easier than transferring all the changes every time by an FTP program. So I found git-ftp and of course FTPS didn’t work out of the box ;) What you have to do to enable GIT FTP (on Windows) ...

December 1, 2021 · 2 min · thomasf
wyse

DHCP Test Tool

I had to check my DHCP configuration for a Dell Wyse Thin Client. But when you configure specific options like 161 and 162 you don’t see that options in a Wireshark capture during a Windows DHCP request. Luckily for us CyberShadow created a great tool to test some specific DHCP settings an he even make it open source: https://github.com/CyberShadow/dhcptest This DHCP tool have 2 great features: You can do a request for specific DHCP option You can send a vendor class so in my case I can pretend to be a Wyse Thin client. This will only work when you have configured Global DHCP settings. ...

November 11, 2021 · 2 min · thomasf
140px-Wireshark_icon.svg

Windows network package capture without installing anything (on the server)

I like Wireshark. But I don’t like to install software on a server for troubleshooting purposes. Especially when you need software like PCAP to sniff some network data. But what you can do is capture data data with netsh, copy the data to your workstation, convert the data so you can read it with wireshark and do you thing. Run this command to capture the data (elevated command prompt) ...

November 5, 2021 · 1 min · thomasf
remote-desktop-rdp-mstsc-icon

Slow initial RDP connection

For me, this was a pain in the ass for a long time. When I connect to a Windows server through RDP/RDS it sometimes takes more than 2 minutes to connect to a server. Today after some waiting, and waiting and some more waiting I did a deep dive with Wireshark to figure out why it was so slow. Azure domain joined Windows 10 device (Laptop) Connection over a Cisco Anyconnect VPN Remote Desktop Manager (Devolutions) Native RDP client MremoteNG I know for sure the issue should be in my setup. Because when I connect first to a jump host (RDP) and then connect to other domain-joined servers everything was connected almost immediately after I put in my user credentials. ...

November 4, 2021 · 3 min · thomasf

Policy WSUS: "Automatically download updates and install them on the schedule specified below" don't work...!!!?!

So I configure a “configure automatic updates” policy for testing purposes but the auto-update and installation won’t work. The main cause….? Lack of patience ;-) How this Policy works (source): The Windows Update Agent periodically checks the WSUS server for updates. Updates it finds, it reports state for: Installed, Not Installed, Not Applicable. If a “Not Installed” update is approved and available, the WUA queues the installation files for download if the Configure Automatic Updates policy is set to AUOption ‘3’ or ‘4’. ...

February 4, 2020 · 3 min · thomasf
image-1

Papercut: Simple Desktop SMTP Server

Sometimes you want to test a mail application without spamming the internet with your garbage. Use can user Papercut to local test your mail application. URL: https://github.com/ChangemakerStudios/Papercut/releases

November 22, 2019 · 1 min · thomasf

Clean old MSI or MSP files from c:\Windows\Installer folder

A lot of installations don’t clean the old MSI and MSP files in the c:\Windows\Installer folder. There is a nice tool to clean that mess in 2 mouse clicks with the name patchcleaner. URL: http://www.homedev.com.au/free/patchcleaner

November 29, 2016 · 1 min · thomasf