<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Karsten Palmvig's blog : Exchange</title><link>http://blogs.technet.com/kpalmvig/archive/tags/Exchange/default.aspx</link><description>Tags: Exchange</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>How To: Change mailbox quota based on current value</title><link>http://blogs.technet.com/kpalmvig/archive/2008/07/01/how-to-change-mailbox-quota-based-on-current-value.aspx</link><pubDate>Tue, 01 Jul 2008 20:14:08 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3081831</guid><dc:creator>kpalmvig</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.technet.com/kpalmvig/comments/3081831.aspx</comments><wfw:commentRss>http://blogs.technet.com/kpalmvig/commentrss.aspx?PostID=3081831</wfw:commentRss><description>&lt;p&gt;This turns out to be somewhat tricky unless you experiment quite a lot with the values and operators, therefore I'm posting the quick solution here for those of you that (like me) like to find what you search for... :o)&lt;/p&gt;  &lt;p&gt;If you use the &lt;strong&gt;Get-Mailbox&lt;/strong&gt; cmdlet without parameters you will get all mailboxes listed in a table view like this:&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="490" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="92"&gt;&lt;font face="Lucida Console"&gt;Name&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="94"&gt;&lt;font face="Lucida Console"&gt;Alias&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="132"&gt;&lt;font face="Lucida Console"&gt;ServerName&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="170"&gt;&lt;font face="Lucida Console"&gt;ProhibitSendQuota&lt;/font&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="91"&gt;&lt;font face="Lucida Console"&gt;-----&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="93"&gt;&lt;font face="Lucida Console"&gt;-----&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="132"&gt;&lt;font face="Lucida Console"&gt;----------&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="170"&gt;&lt;font face="Lucida Console"&gt;-----------------&lt;/font&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="91"&gt;&lt;font face="Lucida Console"&gt;John Doe&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="93"&gt;&lt;font face="Lucida Console"&gt;JohnDoe&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="132"&gt;&lt;font face="Lucida Console"&gt;Server01&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="170"&gt;&lt;font face="Lucida Console"&gt;50MB&lt;/font&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td valign="top" width="91"&gt;&lt;font face="Lucida Console"&gt;Jane Doe&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="93"&gt;&lt;font face="Lucida Console"&gt;JaneDoe&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="132"&gt;&lt;font face="Lucida Console"&gt;Server01&lt;/font&gt;&lt;/td&gt;        &lt;td valign="top" width="170"&gt;&lt;font face="Lucida Console"&gt;unlimited&lt;/font&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;So suppose you want to change the ProhibitSendQuota for all users that currently have a quota of 50MB to 100MB; in my mind the straight forward way to find all users with a 50MB quota would be to apply the filter: ProhibitSendQuota -eq 50MB but that will return exactly nothing...&lt;/p&gt;  &lt;p&gt;Instead you have to use sizes like Exchange do (although Get-Mailbox returns the formatted output). So bearing in mind that 50MB in Exchange terms is 50 x 1024 = 51200 the string will look like this:&lt;/p&gt;  &lt;p&gt;&lt;font face="Lucida Console"&gt;&lt;strong&gt;Get-Mailbox&lt;/strong&gt; -Filter { ProhibitSendQuota -like 51200 } | &lt;strong&gt;Set-Mailbox&lt;/strong&gt; -ProhibitSendQuota 100MB -UseDatabaseQuotaDefaults $false&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Notice that you have to use &amp;quot;-like&amp;quot; instead of &amp;quot;-eq&amp;quot; which would be the more logical operator to use in this case. When setting the new size you can use KB, MB, GB, TB as you please...&lt;/p&gt;  &lt;p&gt;The above will look like this in the GUI:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="149" alt="GUI screenshot" src="http://blogs.technet.com/blogfiles/kpalmvig/WindowsLiveWriter/HowToChangemailboxquotabasedoncurrentval_10DEA/image_3.png" width="432" border="0" /&gt; &lt;/p&gt;  &lt;p&gt;Enjoy...&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3081831" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/kpalmvig/archive/tags/How+To/default.aspx">How To</category><category domain="http://blogs.technet.com/kpalmvig/archive/tags/Exchange/default.aspx">Exchange</category></item><item><title>How To: Bulk creation of AD users and Exchange mailboxes</title><link>http://blogs.technet.com/kpalmvig/archive/2008/03/10/how-to-bulk-creation-of-ad-users-and-exchange-mailboxes.aspx</link><pubDate>Tue, 11 Mar 2008 01:28:25 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:2985365</guid><dc:creator>kpalmvig</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.technet.com/kpalmvig/comments/2985365.aspx</comments><wfw:commentRss>http://blogs.technet.com/kpalmvig/commentrss.aspx?PostID=2985365</wfw:commentRss><description>&lt;p&gt;Over the past couple of months I have worked on more than one project where the customer wanted to create a new forest for the new Exchange 2007 installation. Normally you would migrate users from the old domain(s) with ADMT or another product but in these cases brand new user accounts and mailboxes were desired.&lt;/p&gt;  &lt;p&gt;So how do you create all your new users the easiest way? Well, with Exchange Management Shell of course! :o)&lt;/p&gt;  &lt;p&gt;First you have to export existing users. Here I will use a Windows Server 2003 domain as an example source domain. I recommend using &lt;a href="http://technet2.microsoft.com/windowsserver/en/library/1050686f-3464-41af-b7e4-016ab0c4db261033.mspx?mfr=true" target="_blank"&gt;CSVDE&lt;/a&gt; for the export as it will give you a comma delimited file that is easy to manipulate in Excel. &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;The more time you spend cleaning up your data in Excel, the more time you save later by not having to re-iterate the whole process. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Example: &lt;strong&gt;csvde &lt;/strong&gt;-d &amp;quot;ou=Domain Users,dc=contoso,dc=com&amp;quot; -f DomainUsersOU.txt&lt;/p&gt;  &lt;p&gt;Make sure your output file has the &amp;quot;.txt&amp;quot; extension for Excel to be able to detect the content properly.&lt;/p&gt;  &lt;p&gt;Now you fire up Excel, open the file and let Excel do its magic after you select comma delimited format.&lt;/p&gt;  &lt;p&gt;Select the columns and rows you want to use for the import and get rid of the rest, the example below uses just the most basic fields - you may need to import more fields; e.g. if you have OCS and phone integration you would want to keep the msRTCSIP-Line and msRTCSIP-PrimaryUserAddress fields.&lt;/p&gt;  &lt;p&gt;In this example a bunch of random passwords are created and saved in a column called &amp;quot;Password&amp;quot;.&lt;/p&gt;  &lt;p&gt;Save the file as tab delimited (this will save you a headache later) and use the following script to convert the file to a proper comma delimited format (borrowed from &lt;a href="http://msgoodies.blogspot.com/2007/04/powershell-convert-tsvtocsv.html" target="_blank"&gt;msgoodies&lt;/a&gt;):&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="479" border="1"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="477"&gt;         &lt;p&gt;$v=new-object system.text.stringBuilder 1000           &lt;br /&gt;$input | % {            &lt;br /&gt; $v.length=0 # empty sb            &lt;br /&gt; $e=$_.split(&amp;quot;`t&amp;quot;)            &lt;br /&gt; $e | % {            &lt;br /&gt;&amp;#160; $null=$v.append(&amp;quot;,&amp;quot;)            &lt;br /&gt;&amp;#160; if ($_[0] -eq &amp;quot;`&amp;quot;&amp;quot; -and $_.endswith(&amp;quot;`&amp;quot;&amp;quot;)) {            &lt;br /&gt;&amp;#160;&amp;#160; # already quoted - strip them            &lt;br /&gt;&amp;#160;&amp;#160; $_=$_.substring(1,$_.length-2)            &lt;br /&gt;&amp;#160; }            &lt;br /&gt;&amp;#160; $null=$v.append('&amp;quot;'+$_.replace('&amp;quot;','&amp;quot;&amp;quot;')+'&amp;quot;')            &lt;br /&gt; }            &lt;br /&gt; $v.tostring().substring(1)            &lt;br /&gt;}&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;Save the script file as: Convert-TsvToCsv.ps1 (or really, whatever you like)&lt;/p&gt;  &lt;p&gt;Syntax for converting: &amp;quot;&lt;strong&gt;type&lt;/strong&gt; tabfile.txt | &lt;strong&gt;.\Convert-TsvToCsv.ps1&lt;/strong&gt; &amp;gt;csvfile.txt&amp;quot;&lt;/p&gt;  &lt;p&gt;Now the fun begins!&lt;/p&gt;  &lt;p&gt;Import the file into a variable by running the Import-Csv cmdlet:&lt;/p&gt;  &lt;p&gt;$users = &lt;strong&gt;Import-Csv&lt;/strong&gt; csvfile.txt&lt;/p&gt;  &lt;p&gt;This will give you a chance to verify the format of the data one last time by simply typing &amp;quot;$users&amp;quot; in the Exchange Management Shell.&lt;/p&gt;  &lt;p&gt;Now we need to parse the array of users by using a ForEach loop:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;ForEach&lt;/strong&gt; ($user in $users) { $pass = &lt;strong&gt;ConvertTo-SecureString&lt;/strong&gt; $user.Password -asPlainText -Force; &lt;strong&gt;New-Mailbox&lt;/strong&gt; -UserPrincipalName $user.userPrincipalName -Alias $user.sAMAccountName -Database $user.homeMDB -Name $user.sAMAccountName -DomainController dc01.contoso.com -OrganizationalUnit $user.ou -FirstName $user.givenName -LastName $user.sn -DisplayName $user.displayName -Password $pass -ResetPasswordOnNextLogon $true -WhatIf }&lt;/p&gt;  &lt;p&gt;The first part of the command converts the included password to a SecureString format to be able to script the input of the password. The second part creates a new AD domain account and an Exchange 2007 mailbox.&lt;/p&gt;  &lt;p&gt;Fields like &amp;quot;homeMDB&amp;quot; will of course need to be manipulated in Excel after the original export. If you use organization wide unique names for databases, you only need to specify the database name here.&lt;/p&gt;  &lt;p&gt;The &amp;quot;ou&amp;quot; will not always be populated correctly when exporting but can be derived from the &amp;quot;DN&amp;quot; field by a simple Excel macro. That is, if you want the same OU structure in the destination domain.&lt;/p&gt;  &lt;p&gt;After you have tested the script with the &amp;quot;-WhatIf&amp;quot; statement to verify success you can go ahead and remove the &amp;quot;-WhatIf&amp;quot; and create the users in your domain...&lt;/p&gt;  &lt;p&gt;Hopefully this will save you some time.... Enjoy!&lt;/p&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=2985365" width="1" height="1"&gt;</description><category domain="http://blogs.technet.com/kpalmvig/archive/tags/How+To/default.aspx">How To</category><category domain="http://blogs.technet.com/kpalmvig/archive/tags/AD/default.aspx">AD</category><category domain="http://blogs.technet.com/kpalmvig/archive/tags/Users/default.aspx">Users</category><category domain="http://blogs.technet.com/kpalmvig/archive/tags/Exchange/default.aspx">Exchange</category></item></channel></rss>