Enabeling and Disabiling Active Sync for the user

Windows Mobiles can be configured for Active Sync. Active Sync is enabled for all users by Default in Exchange 2007. For Security reasons its recommended to disabled all users and enable only for the required users

Below power shell enabled and disabled Active for all the users in the exchange Organization

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$False

get-Mailbox -resultsize unlimited | set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to enable and disable active sync for given set of users in the text file

Get-content C:\users.txt | set-CASMailbox -ActiveSyncEnabled:$True

Get-content C:\users.txt| set-CASMailbox -ActiveSyncEnabled:$True

Below powershell command to get the list of users who ActiveSync is Enabled and Disabled

Get-CASMailbox -ActiveSyncEnabled:$True

Get-CASMailbox -ActiveSyncEnabled:$False

Powershell to get list of users who’s Dial in option is enabled in Active Directory

Powershell to get the list of users who has Dial in option is enabled in Active directory.  This has to be executed in Quest Active Roles management console. This will query all the active directory users and get the details if the user object has Dialin option is enabled

Get-QADUser -IncludeAllProperties | ?{$_.msNPAllowDialin -eq $true} |Select Displayname,mailnickname

Below powershell helps you to enable export dial in enabled users to CSV format file

Get-QADUser -IncludeAllProperties | ?{$_.msNPAllowDialin -eq $true} |Select Displayname,mailnickname | Export-Csv C:\Dialinusers.csv

Powershell to pull Application Event logs with Event Id 1221

Application Event ID 1221 gives the details of the white space on the Exchange Database.  With the amount of white space we can determine if we wanted to do a defrag on the store or not. Below powershell helps you to pull all the application events with id 1221 from last 2 days

$2DaysAgo = [DateTime]::Now.AddDays(-2)
$Events = Get-Eventlog Application | Where {($2DaysAgo -le $_.TimeWritten)} | ?{$_.eventid -eq “1221”}
$Events

Powershell to get the Home Directory Path

If we wanted to find Home Directory Path of the users in the Orginization then below commands helps you to pull the data

Get-QADUser | select DisplayName,Email,HomeDirectory | Export-Csv c:\HomeDirectory.csv

Command to get the Home Directory for the given list of users and export the result to CSV

get-content C:\users.txt | select DisplayName,Email,HomeDirectory | Export-Csv c:\HomeDirectory.csv

 

 

Powershell to Manager ManagedFolderpolicy on user accounts

Powershell to manage Managedfolderpolicy on user accounts

Below powershell to apply -Managedfolderpolicy new user mailbox at the time of new mailbox creation

New-Mailbox -Name $DName -Database $Database -UserPrincipalName $PrincipalName -FirstName $FName -LastName $LName -Alias $Aliasname -Password $passwd -ResetPasswordOnNextLogon $true -SamAccountName $Aliasname -ManagedFolderMailboxPolicy $MPolicy

Below  powershell to apply folderpolicy to set to all the mailbox in the orginization

$Folderpolicy = “Policyname”
get-mailbox -ResultSize unlimited |Set-Mailbox -Identity -ManagedFolderMailboxPolicy $Folderpolicy

Powershell to remove folderpolicy to specific users in the DL

Get-DistributionGroupMember $group | Set-Mailbox -Identity -ManagedFolderMailboxPolicy $null

Powershell to get the number of mails in the Inbox and number of unread emails in Inbox

Powershell using Outlook.Application to pull out the mailbox details

$outlook = new-object -com Outlook.Application
$session = $outlook.Session
$session.Logon()
$inbox = $outlook.session.GetDefaultFolder(6)
$unreadCount = (%{$inbox.Items | where {$_.UnRead}}).Count
Write-Host $unreadCount
$ItemCount = (%{$inbox.Items }).Count
Write-Host $ItemCount

 

Powershell to get the list of Hidden Mailbox and DL in the Exchange Organization

Below powershell helps you the get the list of the entire Hidden mailbox in the Exchange Organization

Get-Mailbox -ResultSize unlimited |Where{$_.HiddenFromAddressLissEnabled -eq $true}

If you wanted to the get the list of Hidden maibox from the specific Exchange server then

Get-Mailbox -ResultSize unlimited |Where{($_.servername -eq “<servername>”) -and ($_.HiddenFromAddressListsEnabled -eq $true)}

If you get the list of Hidden Mailboxes from the specific mailbox store then please use below command

Get-Mailbox -ResultSize unlimited |Where{($_.Database -eq “Server\SG\Store”) -and ($_.HiddenFromAddressListsEnabled -eq $true)}

Powershell to command to get the list of Hidden DL from the Orgnization

Get-DistributionGroup -resultsize unlimited| ?{$_.HiddenFromAddressLissEnabled -eq $true}

Powershell to Export list of Permission given to the mailbox to CSV file

If we need to get the list users who has access to the specific mailbox then below powershell help you the fetch the same. It gets all the details that have mailbox permission to the user krishna.k. It will only get the user accounts which are not inherited to the mailbox. User Permission which is given explicitly given to the mailbox

$user =”Krishna.k”
get-mailbox -identity $user| Get-MailboxPermission | ?{($_.IsInherited -eq $False) -and -not ($_.User -match “NT AUTHORITY”)}

Below powershell commming will export all the user mailbox permission of the mailbox to the CSV file. It exports all the mailbox permission which are explicit permission

Get-mailbox | Get-MailboxPermission | ?{($_.IsInherited -eq $False) -and -not ($_.User -match “NT AUTHORITY”)} |Select User,Identity,@{Name=”AccessRights”;Expression={$_.AccessRights}} | Export-csv C:\mailboxPermission.csv