windows-powershell-ise-icon

Update Windows Server with powershell

This is for 2016 server. But it will work for other versions of Windows [Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12 Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted Install-Module PSWindowsUpdate -Confirm:$false Set-PSRepository -Name "PSGallery" -InstallationPolicy Untrusted Get-WindowsUpdate -AcceptAll -Install -AutoReboot Happy Patching :)

September 20, 2022 · 1 min · thomasf

Use TOR proxy with any linux command

There is an easy way to use the The Onion Router for any command under linux First install TOR and proxychains4 $ sudo apt install tor proxychains4 You can configure proxychains.conf but the default config is good :) $ sudo nano /etc/proxychains.conf Then start the tor service $ sudo systemctl start tor And check your ip: $ proxychains4 curl ifconfig.me You can use any command you want. So if you want your firefox browser over tor: ...

September 18, 2022 · 1 min · thomasf

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
image-6

Cowsay all animals and images

I write a simple loop to get all the ACSII images from cowsay :) Here you can download the TXT file: cowsay Download Happy cowsay!

April 24, 2022 · 1 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
windows-powershell-ise-icon

Add Powershell 7 to your Powershell ISE

I find this code snippet somewhere on the internet and I like it :) Just open ISE and paste these code and you are ready to rock! $ErrorActionPreference= 'silentlycontinue' $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear() $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to PowerShell 7", { function New-OutOfProcRunspace { param($ProcessId) $ConnInfo = New-Object -TypeName System.Management.Automation.Runspaces.NamedPipeConnectionInfo -ArgumentList @($ProcessId) $DefaultType = [System.Management.Automation.Runspaces.TypeTable]::LoadDefaultTypeFiles() $Runspace = [System.Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace($ConnInfo, $Host, $Default) $Runspace.Open() $Runspace } $PowerShell = Start-Process PWSH -ArgumentList @("-NoExit") -PassThru -WindowStyle Hidden $Runspace = New-OutOfProcRunspace -ProcessId $PowerShell.Id $Host.PushRunspace($Runspace) }, "ALT+F5") | Out-Null $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Switch to PowerShell 5", { $Host.PopRunspace() $ChildProc = Get-CimInstance -ClassName win32_process | where {$_.ParentProcessId -eq $Pid} $ChildProc | ForEach-Object { Stop-Process -Id $_.ProcessId } }, "ALT+F6") | Out-Null Happy coding!

April 2, 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
signal-2022-02-11-091338_001

Corrupt SD Card Recovery

A friend of mine came back from vacation where he had taken a lot of pictures. When he got back home a large part of his Micro SD card (exFAT partition) was no longer accessible so he missed a couple of weeks of his photos and videos. His Windows Operating System froze completely when it hit a rotten cluster during a file copy action. So we had to find another solution to get his files back. ...

February 11, 2022 · 2 min · thomasf

Powershell run *.exe files

There are 2 ways to run an executable within powershell without any errors $exe = 'C:\scripts\Everything.exe' $param1 = '-reindex' & $exe $param1 Or with a –% attribute C:\windows\system32\sc.exe --% qc bits

January 1, 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 ;) Windows What you have to do to enable GIT FTP (on Windows) ...

December 1, 2021 · 2 min · thomasf