Month: May 2021

PowerShell: Export Event Logs by a Certain Date Range

# User defined variables $daysLimit=7 $startdate=(get-date).adddays(-$daysLimit) $computername=$env:computername $logName='Application' $filterTypes='Error','Warning' $logPath="c:\temp\eventlogs-from-$($startdate.tostring('yyyy-MM-dd'))-to-$((get-date).tostring('yyyy-MM-dd')).csv" # Get the event logs…

PowerShell: Backup Dynamics CRM Organization Database

# backupCrmOrgDatabase.ps1 # This script is to be invoked in the context of the Administrator…

PowerShell: Remove or Disable Windows Defender

$username='domain\serviceAccount' $password='PasswordHere' $encryptedPassword=ConvertTo-SecureString $password -AsPlainText -Force $credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName,$encryptedPassword; $computerNames=@( 'SERVER01',…

PowerShell: Windows Session Memory Usage Watcher

# windowsSessionWatcher.ps1 $serverNames=@( 'IRV-RDS01.domain1.net', 'LAX-RDS02.domain2.com ) $thresholdMemoryUsagePercent=30 $thresholdMemoryGb=20 $domainCreds=@( @{domain='domain1.ad';username='domain1\sysadmin';password=$env:pass1} @{domain='domain2.com';username='domain2\sysadmin';password=$env:pass2} ) # Email relay…

How to Fix Remote Desktop Blue Screen on Windows 2019

Problem: when an RDP session is idle for an extended period of time, that session…