krypted.com

Tiny Deathstars of Foulness

Here’s a little powershell script to enable mailboxes based on an OU and put their new mailbox into a given database. To customize, change OU=ORGANIZATIONALUNIT,DC=companyname,DC=com to the DN for the OU you are configuring. Also, change DATABASENAME to the name of the information store that you’d like to use for the mailboxes in that OU.

Import-module activedirectory

$OUusers = Get-ADUser -LDAPfilter ‘(name=*)’ -searchBase {OU=ORGANIZATIONALUNIT,DC=companyname,DC=com}
foreach($username in $OUusers)
{
Enable-Mailbox -Identity $username.SamAccountName -database {DATABASENAME}
}

March 21st, 2014

Posted In: Microsoft Exchange Server, Windows Server

Tags: , , , , , ,

When running mailbox exports, move requests, etc in Exchange 201x you might get an error. This is because the Management Role Assignments have changed ever so slightly. In order to provide an account the ability to do certain tasks, you can use the New-ManagementRoleAssignment powershell cmdlet to process a request. To do so, pick a user (in this case the username is kryptedadmin) using the -User option and choose roles to assign (in this case, mailbox, export and import) using the -Role option. The command then looks as follows:

New-ManagementRoleAssignment -Role "Mailbox Import Export" -User kryptedadmin

To see if your roles were properly applied:

Get-ManagementRoleAssignment -Role "Mailbox Import Export" | ft Identity

November 2nd, 2013

Posted In: Microsoft Exchange Server

Tags: , , , , , , , ,

Exchange is becoming more and more command line oriented. This includes the powershell options for managing Exchange once installed, but can also include the initial installation. To install Exchange from the command line, one must first install Exchange prerequisites, which are broken down per role that is being installed on Exchange. This can be done using the Add-WindowsFeature commandlet. To install the Windows requirements for Exchange for the Client Access, Hub Transport and Mailbox roles, use the following command:

Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy,Web-WMI -Restart

For the Edge Transport role, use:

Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Desktop-Experience -Restart

For the Unified Messaging role, use:

Add-WindowsFeature NET-Framework,RSAT-ADDS,ADLDS -Restart

After the server restarts, also configure NetTcpPortSharing:

Set-Service NetTcpPortSharing -StartupType Automatic

Once the required features are installed, you can then run the installer and extend the Active Directory schema to prepare for the new attributes required for the version of Exchange you’re installing (2010 for this article btw). To do so, use the setup.exe command. In this example command we’ll use the setup.exe located in c:ExchangeInstallers:

c:ExchangeInstallerssetup.exe /prepareschema

Once the Schema is ready, then prepare AD:

c:ExchangeInstallerssetup.exe /preparead

Then, prep the domain:

c:ExchangeInstallerssetup.exe /PrepareDomain

Note: For a full listing of what happens at the above stages of the installation, see TechNet 125224: http://technet.microsoft.com/en-us/library/bb125224(v=exchg.150).aspx

Once that’s done, I like to do a quick sync of AD from the control with my schema FSMO role:

repadmin /syncall

Then, for the easy part: install Exchange (in this case we’re installing Hub, CAS & Mailbox roles):

c:ExchangeInstallerssetup.exe /m:install /r:h,c,m

And voila, you’ve now got an Exchange Server. Since this is a Mailbox server, an empty information store is created and store.exe should be running. Use Get-Mailboxdatabase to verify:

Get-Mailboxdatabase -status

You can then move a database (e.g. to your SAN), since the default will be nested in the mdb folders in the Exchsrvr directory by using the move-DatabasePath cmdlet. Or use the move-storagegrouppath cmdlet to move the transaction logs.

Once the information store is back online and any logs have been moved, check the connectors in Exchange. Use get-sendconnector to see any outgoing connectors and get-receiveconnector to see any incoming connector information. You can also use get-exchangecertificate to check any certs on the host and get-routinggroupconnector to see any information about routing group connectivity.

June 11th, 2013

Posted In: Mass Deployment, Microsoft Exchange Server, Windows Server

Tags: , , , , , , , , , , , , , , , , ,

Powershell gives Exchange admins a lot of nice little tricks to use. Exchange 2010 has a new feature in tool tips. You can use Powershell, to run a basic for loop, looping through a quick Get-Mailbox. Based on the output of the Get-Mailbox, you can get a list of all valid mailboxes for an organization. You can then execute a command, allowing you to run any mailbox command against every mailbox of an organization. In the following example, we’ll use the Set-MailBox to make a basic mail tip for all users:

foreach ($mailbox in (Get-Mailbox)) { Set-MailBox -Identity $mailbox -MailTip “Please send only legitimate emails” }

April 15th, 2011

Posted In: Microsoft Exchange Server, Windows Server

Tags: , , , , , ,