Archive for the ‘PowerShell’ Category

VMware vSphere Hypervisor (ESXi 4.1) Test Lab Configuration Notes

Wednesday, June 20th, 2012

2012-06-20 Updated

2010-12-22 Initial Post

I've never had a chance to work with any version of VMware at work. My last company was so far behind in its IT strategy that even in late 2009 it had absolutely no virtualization strategy at all. I did manage to set up one Hyper-V server for them so that one department could use it for software testing. Where I work now, they do use VMware, but they don't use them on any of the messaging servers that I support. So once again, I have no chance to work with VMware. (more...)

New-MailboxExportRequest – How To Export Multiple Well-Known Folder Names

Monday, December 5th, 2011

2011-12-05 Initial Post

A few weeks ago I was trying to get a command together to export only the Calendar and Contacts folders from all mailboxes on an Exchange Server 2010 SP1 mailbox database. (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 http://technet.microsoft.com/en-us/library/bb232199.aspx. Under the Enter Outlook Web App Web Parts manually section of that article, the URL example it gives is https://email.fourthcoffee.com/owa/tsmith@fourthcoffee.com/?cmd=contents&f=calendar&view=weekly. (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 SysAdmin-E.com, 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 <SysAdmin-E.com@SysAdmin-E.com>"
#Change e-mail recipient(s) below.
$strSmtpRecipient = "someone@SysAdmin-E.com"
$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)
Exit