1. Find and disable computers that have not logged in for 90 days.

This script is useful to keep the AD clean and secure

$daysINACTIVE = 90 $time = (Get-Date).AddDays(-$daysInactive) Get-ADComputer -Filter {LastLogonDate -lt $time} -Properties LastLogonDate | Where-Object { $_.Enabled -eq $true } | Set-ADComputer -Enabled $false

2.This script collects a list of installed software from every computer on the domain. This is great for auditing and compliance tracking for enterprise networks.

Ensure proper indentation when copying and pasting script

$computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name foreach ($computer in $computers) { Invoke-Command -ComputerName $computer -ScriptBlock { Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion } -ErrorAction SilentlyContinue }

Check for pending reboot. Detects if a reboot is pending based on registry keys.

$pending = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ErrorAction SilentlyContinue) if ($pending) { "Reboot required." } else { "No reboot required." }

Test network latency. Measures ping response time to key servers or IPs.

"8.8.8.8","1.1.1.1","google.com" | ForEach-Object { Test-Connection $_ -Count 2 | Select-Object Address, ResponseTime }

Get logged-in users on a remote machine.

quser /server:ComputerName

Register-ObjectEvent, webhook intergration, dynamic parameters, graceful exit. Real-time Event-Log Monitor teams / Slack

<# .SYNOPSIS Subscribes to specified Windows Event Logs and posts critical events to Microsoft Teams or Slack via an incoming-webhook URL. .EXAMPLE .\Watch-EventLog.ps1 -LogName 'System','Application' -Level Error -Webhook $env:TEAMS_URL #> param( [Parameter(Mandatory)][string[]]$LogName, [ValidateSet('Information','Warning','Error','Critical')] [string]$Level = 'Error', [Parameter(Mandatory)][string]$Webhook ) # Convert level string to numeric value $levelMap = @{Information=4; Warning=3; Error=2; Critical=1} $filter = @{LogName=$LogName; Level=$levelMap[$Level]} Register-ObjectEvent -InputObject (Get-WinEvent -FilterHashtable $filter -MaxEvents 0 -ErrorAction Stop) ` -EventName RecordWritten -Action { $event = $Event.SourceEventArgs.Record $msg = @{ title = "⚠️ $($event.LevelDisplayName) in $($event.LogName)" text = "**$($event.Id)**: $($event.Message)" } | ConvertTo-Json -Depth 3 Invoke-RestMethod -Uri $Webhook -Method Post -Body $msg -ContentType 'application/json' } | Out-Null Write-Host "Monitoring $($LogName -join ', ') for $Level events. Press Ctrl+C to stop." while ($true) { Start-Sleep -Seconds 1 } # keep job alive