Removing Old IIS Logs

Posted 1581 days ago | 0 Comments

Simple powershell script to remove old IIS logs (or any other file for that matter). $pathToLogs = “C:\WINDOWS\system32\LogFiles\W3SVC1″;$LogAgeTarget = 183; # Number of days of logs to keep$dteNow = Get-Date    if (Test-Path $pathToLogs){      $LastWrite = $Now.AddDays(-$LogAgeTarget)      $Files = Get-ChildItem $pathToLogs -include *.log -recurse |            Where {$_.LastWriteTime -le “$LastWrite”}       foreach [...]

Continue Reading

Exchange 2007 Logs from Client Access Machines

Posted 1752 days ago | 0 Comments

A short script to make it a little easier to retrieve logs from several client access machines. A little quicker than using the Toolbox Message Tracking Log: $strEvent = “RECEIVE”$dteStart = “31/08/2008 12:34:00″$dteEnd = “01/09/2008 16:44:00″$strMessageSubject = “Email Account Owner”Get-ExchangeServer Where {$_.ServerRole -match ‘ClientAccess’} ForEach {Get-MessageTrackingLog -Server $_.Fqdn -EventID $strEvent -MessageSubject $strMessageSubject -Start $dteStart -End [...]

Continue Reading

Add Exchange Snapin to Windows Powershell

Posted 1764 days ago | 0 Comments

Trying to run exchange-specific commands in the windows powershell returns errors so to make the windows powershell aware of the exchange commands we need to add the appropriate snap in with: Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin That line can be added at the top of any scheduled task scripts.exchange powershell scheduled tasksimport use exchange commands in windows powershelladd [...]

Continue Reading

Beginning Powershell

Posted 1785 days ago | 0 Comments

When writing my first powershell script to check free disk space on a dozen exchange servers I picked up a few useful things for future reference. Echoing output to the command lineA script can print/write output to stdout using Write-Host “Hello World” but this command is aliased too, so that echo “Hello World” will also [...]

Continue Reading