Archive for the ‘Scripting / Batch File / Automation’ Category

Internet Explorer – Disable Images, Video, and Adobe Flash

Friday, July 29th, 2011

2011-07-29 Initial Post

Have you ever wanted to browse a Web site and read its content without seeing annoying pictures and Flash animations? Well, you can do so by temporary disabling those annoyances via the use of registry update files. This is useful for office cubicle dwellers who might want to view some personal Web sites like Facebook without the images being displayed for coworkers passing by to see. (more…)

Exchange 2010 Outlook Web App Calendar URL – Incorrect URL in MS Article 232199 / Permission Error

Thursday, May 26th, 2011

2011-05-26 Initial Post

Exchange Server 2010 Enterprise SP1 RU3

The other day we needed to give all users reviewer permission to our conference room mailboxes and allow the users to access the rooms’ calendars via a direct OWA URL on a SharePoint site. I used the example in the article “Using Outlook Web App Web Parts” at Under the Enter Outlook Web App Web Parts manually section of that article, the URL example it gives is (more…)

Get Logical Disk Size and Percentage of Free Disk Space with PowerShell

Saturday, May 21st, 2011

2011-05-21 Initial Post

Tested with PS v2 on Windows 7 and Server 2008 R2

I've found a few commands for getting disk size and free space but I wanted percentage of free space also. I modified one of the commands that I found by adding additional commands to show the percentage of free space. Note that DriveType=3 means local disk.

Get-WMIObject Win32_LogicalDisk -Filter "DriveType=3" -Computer . | Select SystemName, DeviceID, VolumeName, @{Name="Total Size (GB)"; Expression={"{0:N1}" -F ($_.Size/1GB)}}, @{Name="Free Space (GB)"; Expression={"{0:N1}" -F ($_.Freespace/1GB)}}, @{Name="Free Space %"; Expression={"{0:N1}" -F (($_.Freespace/$_.Size)*100)}} | FT -AutoSize

The output is below, but it doesn't line up properly in Outlook when I use the output string in an e-mail. I haven't had a chance to play around with the formatting.

SystemName     DeviceID VolumeName  Total Size (GB) Free Space (GB) Free Space %
----------     -------- ---------- --------------- --------------- ------------
Server001          C:        C-System    116.5             79.8              68.5
Server001          X:        X-Util      116.4             102.8             88.3

Exchange 2010 Mailbox Move Status Script

Saturday, May 14th, 2011

2011-05-14 Updated

2011-05-04 Initial Post

This is my first real PowerShell script. I'm starting to do a lot more with PowerShell now and eventually I'd like to get good enough to write some functions.

I wanted more information such as mailbox size and move duration so I searched and found the cmdlet Get-MoveRequestStatistics. That gave me what I needed so I rewrote my original script.

#Last modified by, 2011-05-09
$strScriptVersion = "Script version: getMailboxMoveStat-v1.2.ps1, updated 2011-05-09`n--End of Script--"
Gets mailbox move request statistics and e-mails it out. Also copies to CSV file in D:\MailboxMoveStatistics\ on the server running the script.
NOTE: This script looks for mailbox move requests. If you clear all the move requests, this script will not find anything. Clear the move requests only before and after running this script to get the most accurate count.
To schedule, use this command (adjust path and version number first): powershell -command "& 'C:\_AdminScripts\getMailboxMoveStat-vX.X.ps1'"
I kept getting this error: Task Scheduler failed to start "\getMailboxMoveStat" task for user "AD-DOMAIN\USERNAME". Additional Data: Error Value: 2147750687.
 I had to go to the task's Settings tab and select either "Run a new instance in parallel" or "Stop the existing instance."
Tested with PS v2 with Exchange Server 2010 SP1 on Windows Server 2008 R2 SP1.
Use a Hub server for the SMTP host. A MB or CAS server does not have an SMTP service.
NOTE: When viewing the e-mail, Outlook might remove extra line breaks (`n), by default, so deselect that option in Outlook.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
$strDateTimeLong = Get-Date -Format F
$strDateTimeShort = Get-Date -Format yyyy-MM-dd-HH-mm
#Change file path below.
$strFileOutputPath = "D:\MailboxMoveStatistics\MailboxMoveStatistics_$strDateTimeShort.csv"
#Command below is for exporting the information to CSV. Rearrange the column names to your liking.
Get-MoveRequest -ResultSize Unlimited | Get-MoveRequestStatistics | Select Status, PercentComplete, DisplayName, Alias, TotalInProgressDuration, TargetDatabase, SourceDatabase, TotalMailboxSize, TotalMailboxItemCount, BadItemsEncountered, StartTimestamp, CompletionTimestamp, MRSServerName | Sort Status -Descending | Export-Csv $strFileOutputPath -NoTypeInformation
$strStatusCount = "Completed: " + (Get-MoveRequest | Where {$_.Status -eq "Completed" }).Count + ", Total Move Requests: " + (Get-MoveRequest).Count + ".`n"
$strCmdForEmailBody = Get-MoveRequest -ResultSize Unlimited | Get-MoveRequestStatistics | Select Status, PercentComplete, DisplayName | Sort Status -Descending | FT -AutoSize | Out-String
#Change SMTP server below.
$strSmtpServer = "exchange-01"
#Change e-mail sender below.
$strSmtpSender = "Exchange 2010 Mailbox Move Statistics <>"
#Change e-mail recipient(s) below.
$strSmtpRecipient = ""
$strSmtpSubject = "Exchange 2010 Mailbox Move Statistics - $strDateTimeLong"
$strSmtpBody = $strStatusCount + "A more detailed report is in the file $strFileOutputPath on $env:computername.`n"
$strSmtpBody = $strSmtpBody + $strCmdForEmailBody + $strScriptVersion
$objSmtpClient = New-Object System.Net.Mail.SmtpClient
$objSmtpClient.Host = $strSmtpServer
$objSmtpClient.Send($strSmtpSender, $strSmtpRecipient, $strSmtpSubject, $strSmtpBody)

OCS – Find All Users With Federation Enabled via msRTCSIP-FederationEnabled Attribute

Saturday, February 12th, 2011

2011-02-12 Initial Post

Windows Server 2003 SP2

Office Communications Server 2007 (non-R2)

If you want to search for OCS users with federation enabled, use the simple LDAP query filter below. It took me some testing to figure out that "TRUE" had to be in all uppercase/all capitals. Other LDAP filters are case insenstitive, but it looks like searching for boolean values, at least in this case, requires upppercase. (more…)