Posts

CPU monitor and trigger to collect Logs

 # ============================================================================ # Trend Micro Diagnostic Auto Collection on High CPU # ============================================================================ # Configuration $CpuThreshold = 90                  # CPU % $ConsecutiveBreaches = 5            # Number of consecutive checks $CheckIntervalSeconds = 60          # Check interval $CooldownMinutes = 30               # Wait before next collection # Paths $TrendPath = "C:\Program Files\Trend Micro\Deep Security Agent" $DiagCommand = "dsa_control.cmd" $LogFolder = "C:\temp" # Create log folder if needed if (!(Test-Path $LogFolder)) {     New-Item -Path $LogFolder -ItemType Directory -Force | Out-Null } $LogFile = Join-Path $LogFolder "TrendMicro_CPU_Monitor.log" # Log Function function Write-Log {     param([string]$Mes...

TCP port usage monitoring

 PowerShell Script: # BMC TCP Port Utilization Monitor #Author: Pugazhendhi D #Team: Windows #Contact:   $Threshold = 75 $LogFile = "C:\Scripts\Logs\TCPPortUtilization.log" try {     # Get actual dynamic port range     $PortInfo = netsh int ipv4 show dynamicport tcp     $StartPort = [int](($PortInfo | Select-String "Start Port").ToString().Split(":")[1].Trim())     $PortCount = [int](($PortInfo | Select-String "Number of Ports").ToString().Split(":")[1].Trim())     # Current TCP connections     $CurrentConnections = (Get-NetTCPConnection -ErrorAction Stop).Count     # Utilization %     $Utilization = [math]::Round(($CurrentConnections / $PortCount) * 100,2)     # Logging     $TimeStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"     if (!(Test-Path (Split-Path $LogFile))) {         New-Item -ItemType Directory -Path (Split-Path $LogFile) -Force | ...

AD Security logs script

 # ============================================================================ # SecurityLogArchive.ps1 # Archives Security*.evtx files older than 30 days # Creates individual ZIP files # Deletes original EVTX files after successful archive # Deletes ZIP files older than 90 days # Logs all actions # ============================================================================ $Source = "C:\Windows\System32\winevt\Logs\" $Destination = "D:\ArchivedSecurityLogs" $RetentionDays = 30 $LogFile = Join-Path $Destination "SecurityArchive.log" # Create destination folder if it doesn't exist if (!(Test-Path $Destination)) {     New-Item -Path $Destination -ItemType Directory -Force | Out-Null } Add-Content -Path $LogFile -Value "" Add-Content -Path $LogFile -Value "=================================================================" Add-Content -Path $LogFile -Value "Archive Job Started : $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')...

Patch - Patch reverting due to profile and task scheduler issue.

CBS recorded STATUS_OBJECT_NAME_NOT_FOUND in CUserProfile::OpenProfileRootKey. The Per-User Registry Installer returned 0x80070002 - ERROR_FILE_NOT_FOUND. Because this was a fatal installer failure, CBS initiated rollback and reported 0x800F0922 Enabling Task Scheduler history and Procmon boot logging to capture startup activity

Cluster: If one of the node and cluster service is unable to bring online

 A specified authentication package is unknown reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v AllowCustomSSPsAPs 0 Blocks custom SSPs/APs from loading 1 Allows custom SSPs/APs to load  

Powershell - Check for Timezone on multiple servers and change Timezone.

 $Servers = Get-Content "C:\Temp\Servers.txt" foreach ($Server in $Servers) { try { $TimeZone = Invoke-Command -ComputerName $Server -ScriptBlock { (Get-TimeZone).DisplayName } [PSCustomObject]@{ Server = $Server TimeZone = $TimeZone } } catch { [PSCustomObject]@{ Server = $Server TimeZone = "Unable to connect" } } } --------------- Change Time Zone to Eastern Time on Multiple Servers $Servers = Get-Content "C:\Temp\Servers.txt" foreach ($Server in $Servers) { try { Invoke-Command -ComputerName $Server -ScriptBlock { Set-TimeZone -Id "Eastern Standard Time" } Write-Host "$Server - Time zone updated successfully" -ForegroundColor Green } catch { Write-Host "$Server - Failed: $_" -ForegroundColor Red } } Verify after change: $Servers = Get-Cont...
 # Windows Server Latency Diagnostic Script # Run in PowerShell with Administrator privileges Write-Host "=== CPU & Memory Usage ===" Get-Counter '\Processor(_Total)\% Processor Time' Get-Counter '\Memory\Available MBytes' Write-Host "`n=== Top Processes by CPU ===" Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 Name, CPU Write-Host "`n=== Disk I/O Performance ===" Get-Counter '\PhysicalDisk(_Total)\Avg. Disk sec/Read' Get-Counter '\PhysicalDisk(_Total)\Avg. Disk sec/Write' Get-Counter '\PhysicalDisk(_Total)\Disk Transfers/sec' Write-Host "`n=== Network Latency (Ping Test) ===" Test-Connection -ComputerName google.com -Count 4 Write-Host "`n=== TCP Settings ===" Get-NetTCPSetting | Format-Table SettingName, CongestionProvider, AutoTuningLevelLocal Write-Host "`n=== Event Viewer Errors (Last 50) ===" Get-EventLog -LogName System -EntryType Error -Newest 50 | Forma...