
========================Run Daily Report Script
---------------------------------------------------------------------------------------------
.\Get-ExchangeEnvironmentReport.ps1 -HTMLReport .\AECUK-Report.html

----------------------------------------------------

========================Get All Stopped Services with name MS*
---------------------------------------------------------------------------------------------
Get-service -ComputerName bhm1uc01 -Name ms* | Where-Object {$_.status -eq "stopped"} 

Get-service -ComputerName AEC01A-EX02 -Name ms* | Where-Object {$_.status -eq "stopped"}

---------------------------------------------------------------------------------------------


========================Set-ExecutionPolicy
---------------------------------------------------------------------------------------------
Set-ExecutionPolicy unrestricted

---------------------------------------------------------------------------------------------

=========Export Contact

New-MailboxExportRequest -IncludeFolders "#Contacts#" -Mailbox gai101 -FilePath \\bhm1mig01\CPUU\Contacts\gai101_contact.pst

--------
Check Progress..........Get-MailboxexportRequest | where {$_.status -eq "queued"} | fl

=========================Enable Mailbox
---------------------------------------------------------------------------------------------
Enable-Mailbox john@contoso.com -Database "MyServer\Mailbox Database"

E.g Enable-Mailbox john@contoso.com -Database "MyServer\Mailbox Database"

---------------------------------------------------------------------------------------------


=========================Mailbox Permission
This example grants Raymond Sam Full Access permissions to Terry Adams’ mailbox
---------------------------------------------------------------------------------------------
Add-MailboxPermission -Identity "Terry Adams" -User RaySam -AccessRights Fullaccess -InheritanceType all

---------------------------------------------------------------------------------------------


This example grants Mark Steele Full Access permissions to Jeroen Cool’s mailbox and disables the auto-mapping feature.
---------------------------------------------------------------------------------------------
Add-MailboxPermission -Identity JeroenC -User 'Mark Steele' -AccessRights FullAccess -InheritanceType All -Automapping $false
---------------------------------------------------------------------------------------------

There are 7 possible values for the -AccessRights parameter.

1.FullAccess 
2.SendAs 
3.ExternalAccount 
4.DeleteItem 
5.ReadPermission 
6.ChangePermission 
7.ChangeOwner 



This example sets Tony Smith as the owner of the resource mailbox Room 222.
---------------------------------------------------------------------------------------------
Add-MailboxPermission -Identity "Room 222" -Owner "Tony Smith"
---------------------------------------------------------------------------------------------

#Get Mailbox permission
Get-MailboxPermission -identity Alb100 | fl | ft | out-file c:\MailboxPermission.csv


====================Send-As permissions

If you want to give the user Pete Peterson the Send-As permission for the John Johnson Mailbox you can use the following command line:

get-user -identity “john.johnson@msexchangeblog.nl” | Add-ADPermission -User “pete.peterson@msexchangeblog.nl” -ExtendedRights Send-As

If you want to give the Active Directory group SendAsGroup the Send-As permission for the John Johnson Mailbox you can use the same command line:

get-user -identity “john.johnson@msexchangeblog.nl” | Add-ADPermission -User “SendAsGroup” -ExtendedRights Send-As



Assign Send As permissions for Shared Mailbox

PowerShell command Syntax
PowerShell
1
	
Add-RecipientPermission -Trustee <Identity> -AccessRights SendAs

PowerShell command Example
PowerShell
1
	
Add-RecipientPermission "Public MB" -Trustee "Office Users" -AccessRights SendAs


=============Calender Permission



---This example returns the permissions that Ayla has to view John's Marketing Reports folder.

Get-MailboxFolderPermission -Identity john@contoso.com:\Marketing\Reports -User Ayla@contoso.com



Assign Publishing Editor Permission to Calendar folder

---PowerShell command Syntax
	
Add-MailboxFolderPermission <Identity>:\calendar  -AccessRight PublishingEditor –User <Identity>


---PowerShell command Example

	
Add-MailboxFolderPermission John:\calendar  -AccessRight PublishingEditor -User Suzan

--------------------------------------------------------------------------------------------------------------------------------


======================Set-Outof Office.

Set-MailboxAutoReplyConfiguration -identity “alb100” –AutoReplyState Scheduled –StartTime “04/22/2015” –EndTime “04/22/2017” -InternalMessage $InternalMsg -ExternalMessage $ExternalMsg 

=======================MailEnableContactInOU
--------------------------------------------------------------------------------------------- 
get-contact -organizationalunit testou -RecipientTypeDetails Contact -Filter 'WindowsEmailAddress -ne $null' | 
 foreach { enable-mailcontact -Identity $_ -ExternalEmailAddress $_.WindowsEmailAddress.toString() }
 
---------------------------------------------------------------------------------------------


=======================Get and export mailbox hidden from address book
---------------------------------------------------------------------------------------------
Get-Mailbox -ResultSize unlimited| Where {$_.HiddenFromAddressListsEnabled -eq $True} | Select Name, HiddenFromAddressListsEnabled | export-csv c:\hiddenfromGAL_Hidden.csv
---------------------------------------------------------------------------------------------



========================New-DistributionGroup
---------------------------------------------------------------------------------------------
New-DistributionGroup -Name "<Distribution Group Name>" -DisplayName "<Distribution Group Display Name>" -Alias "<Alias>" -PrimarySmtpAddress "<Email Address>"
---------------------------------------------------------------------------------------------


========================Address List Hidden

List all mailboxes that are hidden from the global address list?
---------------------------------------------------------------------------------------------
Get-Mailbox -ResultSize unlimited |Where{$_.HiddenFromAddressListsEnabled -eq $true} | export-csv c:\hiddenfromGAL.csv
--------------------------------------------------------------------------------------------


List all mailboxes that are hidden from the global address list, on a specific Exchange server?
---------------------------------------------------------------------------------------
Get-Mailbox -ResultSize unlimited |Where{($_.servername -eq "<exchange-servername>") -and ($_.HiddenFromAddressListsEnabled -eq $true)}
---------------------------------------------------------------------------------------------

List all mailboxes that are hidden from the global address list, within a specific Mailbox Store?
--------------------------------------------------------------------------------------------------------
Get-Mailbox -ResultSize unlimited |Where{($_.Database -eq "ExchangeServer\StorageGroup\Store") -and ($_.HiddenFromAddressListsEnabled -eq $true)}
-----------------------------------------------------------------------------------------------------


List list the Distribution Lists that are hidden from the orgnization's global address list?
------------------------------------------------------------------------------------------
Get-DistributionGroup -resultsize unlimited| ?{$_.HiddenFromAddressListsEnabled -eq $true}

-----------------------------------------------------------------------------------------------



======Test Mail Flow

Test-Mailflow hnlmbx05 -TargetEmailAddress Luke.McBee@ithicos.com



================Get queue


    View queue on server;

        Get-Queue

    Messages on queue;

        Get-Queue | Get-Message

    view queue on specified server

        Get-Queue -Server serveradi

    view queue on all transport servers

        Get-TransportServer | Get-Queue

    Message on the all transport servers queue

        Get-TransportServer | Get-Queue | Get-Message

    Suspending all the messages on queue

        Get-Queue | Get-Message | Suspend-Message

    Deleting messages on queue

        Get-Queue | Get-Message | Remove-Message




-----------------------------------------------------------------------------------------------
Powershell script to get infomation about email-queue status

Exchange Server 2010
-----------------------------------------------------------------------------------------------
 

     

    $HubTransports=Get-ExchangeServer | Where {$_.ServerRole -like "*Hub*"}

     

    $HubTransports| foreach{

     

    Get-Queue|ft

     

    }

============== Make a connection to Exch Server

1. $Credentials = Get-Credential
2. $Session = New-PSSession –ConfigurationName Microsoft.Exchange –ConnectionUri ‘http://exch01.ct.local/PowerShell/?SerializationLevel=Full’ -Credential $Credentials –Authentication Kerberos
3. Import-PSSession $Session

OR
Connect-ExchangeServer -Server exserver1.contoso.com
OR

Invoke-Command -ScriptBlock {Get-Service} -ComputerName "exch01.ct.local" -Credential $Usercred -Authentication "kerber

os"

===When finish Remove Sesson
Remove-PSSession $ExSession



======Enable Mailbox
For example, the following command mailbox-enables users who aren't already mail-enabled and that have a value in the UserPrincipalName property, which helps ensure that you don’t inadvertently convert a system account to a mailbox.


Get-User -RecipientTypeDetails User -Filter { UserPrincipalName -ne $Null } | Enable-Mailbox
