More Powershell – Admin “bacon-saving”…

So it looks like Powershell has become my new thing…it should be everyones thing! The clue is in the name really…POWER! Top Gear style…MORE POWER! (other motoring shows are available…)

I digress…

Take some of your daily admin tasks… you should find Powershell will be your friend to just get the job done, or in the case of Exchange 2010 – you just have to do some things in Powershell as the console wont let you!

Two scenarios for you – the first being: you disable all leavers AD accounts, but you have Exchange. Because you are just disabling accounts, the mailboxes are technically still active and still there (you might need to keep them for archiving etc). The but…you don’t want those leavers littering your address book and confusing your current users, or management thinking the accounts are still there.

As that meerkat says..simples (when you have Powershell).

get-mailbox -ResultSize unlimited | where{$_.UserAccountControl -eq "AccountDisabled, NormalAccount" -and $_.RecipientTypeDetails -eq "UserMailbox"} | Set-Mailbox -HiddenFromAddressListsEnabled $True

One gotcha, not running this from the “Exchange Powershell”? Then add this…

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

Save yourself some more time? Set this as a scheduled task to do the tidying up automatically… 🙂

The second bit of fun you can have with Powershell and Exchange? Communal mailboxes, or Service mailboxes. Previously, these would just be an AD account with a standard user mailbox attached. Well, in 2010 (and later for those lucky souls with 2013) you can have “Shared Mailboxes”. Want to know more… heres the Microsoft lowdown… and

You can do it from the – yes you’ve guessed it, Exchange Powershell…

New-mailbox sharedTest –shared –userprincipalname

Why not go further, and save some fiddling that you usually do in the console – and also add the permissions from Powershell too…

Add-MailboxPermission –Identity sharedtest –user “domain\user” –AccessRights “Full Access”

Gotcha…remember “Full Access” doesn’t give “Send as”…so add that one too after if you need that…

Add-ADPermission sharedtest –User "domain\user" –ExtendedRights Send-As

I’ll be back again in the next day or so, to show that Powershell is truly everywhere – this time, playing with SharePoint and Powershell!



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s