Get monitor make and serial number command line

The following powershell command will return make and serial number of a monitor connected to the computer.

gwmi WmiMonitorID -Namespace root\wmi | ForEach-Object {($_.UserFriendlyName -ne 0 | foreach {[char]$_}) -join ""; ($_.SerialNumberID -ne 0 | foreach {[char]$_}) -join ""}

Reference: WmiMonitorID class – Win32 apps | Microsoft Docs

Get and Install Windows Updates via PowerShell

Using the following package PSWindowsUpdate you can Get-WindowsUpdate and Install-WindowsUpdate.

install-module pswindowsupdate
DESCRIPTION
Use Get-WindowsUpdate (aka Get-WUList) cmdlet to get list of available or installed updates meeting specific
criteria.

Use Download-WindowsUpdate alias to get list of updates and download it. Equivalent Get-WindowsUpdate -Download.

Use Install-WindowsUpdate (aka Get-WUInstall) alias to get list of updates and install it. Equivalent
Get-WindowsUpdate -Install.

Use Hide-WindowsUpdate alias to get list of updates and hide it. Equivalent Get-WindowsUpdate -Hide.

Use Show-WindowsUpdate (aka UnHide-WindowsUpdate) alias to get list of updates and unhide it. Equivalent
Get-WindowsUpdate -Hide:$false.

There are two types of filtering update: Pre search criteria, Post search criteria.

- Pre search works on server side, like example: (IsInstalled = 0 and IsHidden = 0 and CategoryIds contains
'0fa1201d-4330-4fa8-8ae9-b877473b6441' )

- Post search work on client side after get the pre-filtered list of updates, like example $KBArticleID -match
$Update.KBArticleIDs

Status info list:\r\n[A|R]DIMHUB\r\nA-IsAccetped\r\nR-IsRejected\r\n D-IsDownloaded\r\n F-DownloadFailed\r\n
?-IsInvoked\r\n I-IsInstalled\r\n F-InstallFailed\r\n ?-IsInvoked\r\n R-RebootRequired\r\n M-IsMandatory\r\n
H-IsHidden\r\n U-IsUninstallable\r\n B-IsBeta

Join a Computer or Server to a Domain

Using the following command, a computer can be joined to an existing Active Directory Domain.

netdom join %computername% /domaind:DOMAIN /userd:username /passwordd:password

PowerShell it can be accomplished with the following.

add-computer -domainname domainname -credential domainname\username -restart

Enable All Windows Events Logs Archiving

This PowerShell script will enable retention for all Windows event logs. This will create an archive log file and start a new log file when it reaches the maximum configured log size (usually 20MB).

# Get all event log names
$logs = wevtutil el

# Loop through each log and enable archiving
foreach ($log in $logs) {
# Enable archiving for the current log
wevtutil sl $log /ab:true /rt:true
Write-Output "Archive enabled for log: $log"
}

Cleanup All User Chrome Cache

This script will clean all Chrome cache for all users on a Windows 7 or newer system.

# Define the base directory for user profiles
$usersPath = "C:\Users"
$totalBeforeCleanup = 0
$totalAfterCleanup = 0

# Loop through each user folder in the Users directory
Get-ChildItem -Path $usersPath -Directory | ForEach-Object {
$chromeCachePath = Join-Path -Path $_.FullName -ChildPath "AppData\Local\Google\Chrome\User Data\Default\Cache"
$userBeforeSize = 0
$userAfterSize = 0

# Check if the Chrome Cache folder exists
if (Test-Path -Path $chromeCachePath) {
# Calculate size before cleanup
$userBeforeSize = (Get-ChildItem -Path $chromeCachePath -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1MB
$totalBeforeCleanup += $userBeforeSize

# Remove all files in the Chrome Cache folder
Get-ChildItem -Path $chromeCachePath -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue

# Calculate size after cleanup (to check if any files were in use and not deleted)
$userAfterSize = (Get-ChildItem -Path $chromeCachePath -Recurse -Force -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum / 1MB
$totalAfterCleanup += $userAfterSize

# Output results for each user
Write-Output ("User: {0}`nCache size before cleanup: {1:N2} MB`nCache size after cleanup: {2:N2} MB`nFreed up: {3:N2} MB" -f $_.Name, $userBeforeSize, $userAfterSize, ($userBeforeSize - $userAfterSize))
} else {
Write-Output "No Chrome cache folder found for user: $($_.Name)"
}
}

# Output total cleanup summary
$totalCleanedUp = $totalBeforeCleanup - $totalAfterCleanup
Write-Output ("`nTotal Chrome cache size before cleanup: {0:N2} MB" -f $totalBeforeCleanup)
Write-Output ("Total Chrome cache size after cleanup: {0:N2} MB" -f $totalAfterCleanup)
Write-Output ("Total freed up: {0:N2} MB" -f $totalCleanedUp)