PowerShell & Exchange

A few handy PowerShell commands I just don’t use often enough to remember:

Change a users password

Set-MsolUserPassword -UserPrincipalName username@domain.com -NewPassword Password1 -ForceChangePassword $false

Hide a user from the address book

Set-Mailbox -Identity username  -HiddenFromAddressListsEnabled $true

Add Rights to a Public Folder

Add-PublicFolderClientPermission -Identity “\folder name” -AccessRights Editor -User username

Add an Address to an Account

set-Mailbox username -EmailAddress @{add=“address@something.com”}

Did it work?

get-Mailbox username | fl EmailAddresses


What is the user currently allowing?

get-MailboxJunkEmailConfiguration -identity username | select -expandproperty TrustedSendersAndDomains

Add something to WhiteList

set-MailboxJunkEmailConfiguration -identity username -TrustedSendersAndDomains @{Add=”domain.com”}

Block a sender for a particular user

$Temp = Get-MailboxJunkEmailConfiguration -Identity username
$Temp.BlockedSendersAndDomains += “domain.com”,”user@domain.com”
Set-MailboxJunkEmailConfiguration -Identity username -BlockedSendersAndDomains $Temp.BlockedSendersAndDomains

Or an easier way. . .
Set-MailboxJunkEmailConfiguration -Identity username -BlockedSendersAndDomains @{Add=”domain.com”}

Count and Delete Calendar Items

Search-Mailbox –identity username –SearchQuery kind:meetings –EstimateResultOnly
Search-Mailbox –identity username –SearchQuery kind:meetings –DeleteContent

Calendar Permissions
Of course these would work with any folder and yes, I could teach the user how to do this themselves, but they do it less frequently than I do; this is just easier.

List the current permissions on the Calendar

get-mailboxfolderpermission -Identity username:\calendar

Add permissions
(use set-mailboxfolderpermissions to change)

add-mailboxfolderpermission -Identity username:\calendar -user otheruser -accessrights Editor

Delete/remove Permissions

remove-mailboxfolderpermission -Identity username:\calendar -user otheruser -confirm:$false

Tags: ,

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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