Behind the Scenes and troubleshooting the impossible, a web log by Brandon Bundy */?>
 footer */?>  © Behind the Scenes and troubleshooting the impossible, a web log by Brandon Bundy */?>

Exchange 2007 Powershell CMDLETS

	[Import Mailbox from PST]
		Import-Mailbox -Identity  -PSTFolderPath 
		Get-Mailbox -Identity  | Import-Mailbox -PSTFolderPath 
		[No Prompt]
		Import-Mailbox -Identity "domain\username1" -PSTFolderPath "c:\username1.pst" -Confirm:$False
		Use the pipe " | "
	[Export Mailbox to PST]
		Export-Mailbox -Identity "username" -PSTFolderPath "c:\username.pst"
			-ExcludeFolders "\Deleted Items"
	[Give Admin Access for PST Import]
		get-mailbox * | Add-mailboxpermission -User SGSVR\Administrator -AccessRights FullAccess
	[Give Storage Group Admin]
		Add-AdPermission -identity 'First Storage Group' -AccessRights GenericAll -user 'SGSVR\Administrator'
		Add-AdPermission -identity 'Journaling Mailbox Database' -AccessRights GenericAll -user 'SGSVR\Administrator'
		Add-AdPermission -identity 'Second Storage Group' -AccessRights GenericAll -user 'SGSVR\Administrator'
	[Check Group Membership]
		See Below in Groups... "[Query all distribution groups]"
	[Send As Rights]
		1. Add-ADPermission "Mailbox" -User "Domain\User" -Extendedrights "Send As"
		2. Manually set it in the account properties in the management console.
	[Get Failed Message Results]
		Get-MessageTrackingLog -EventID FAIL -Sender ""


	[Mail-Enable a Contact]
		Enable-MailContact -Identity "Foo" -ExternalEmailAddress

	[All Contacts HideFromAddressLists]
		get-mailcontact * | set-mailcontact -hiddenfromaddresslistsenabled $true

	[Check which Contacts are Hidden from the Address List]
		get-mailcontact * | foreach {$dg = $_ ; get-mailcontact $dg | foreach {if($_.hiddenfromaddresslistsenabled -like $true) {"Set for " + $dg} } }

	[Check which Contacts are and aren't Hidden from the Address List]
		get-mailcontact * | foreach {$dg = $_ ; get-mailcontact $dg | foreach {"Set for " + $_.hiddenfromaddresslistsenabled + "`t" + $dg } }


	[Query all distribution groups]
		[Show which the user is a member of]
			$user = get-user ""; get-distributiongroup | foreach {$dg = $_ ; get-distributiongroupmember $dg | foreach {if($_.identity -like $user.identity) {"Member of " + $dg} } }
		[Show which all users are a member of]
			get-user * | foreach { $UserIdentity = $_.identity; $UserName = $; get-distributiongroup * | foreach { $dg = $_ ; get-distributiongroupmember $dg | foreach {if($_.identity -like $UserIdentity) {$UserName + " is Member of " + $dg} } } }

		[Set ReportToOriginatorEnabled to False]
			get-distributiongroup | foreach { $dg = $_ ; set-distributiongroup -Identity $dg -ReportToOriginatorEnabled $false }

	[Check which Groups are and aren't Hidden from the Address List]
		get-distributiongroup * | foreach {$dg = $_ ; get-distributiongroup $dg | foreach {"Set for " + $_.hiddenfromaddresslistsenabled + "`t" + $dg } }

	[Require that all senders are authenticated]
		[Query All]
			get-distributiongroup | foreach { $dg = $_ ; set-distributiongroup -Identity $dg -RequireSenderAuthenticationEnabled $False }
		[Find True and Set to False]
			Get-DistributionGroup | where {$_.RequireSenderAuthenticationEnabled -eq $True} | Set-DistributionGroup -RequireSenderAuthenticationEnabled $False
		[Display Them]
			get-distributiongroup * | foreach {$dg = $_ ; get-distributiongroup $dg | foreach {"Set for " + $_.RequireSenderAuthenticationEnabled + "`t" + $dg } }

	[List Member of a Distribution Group]
		get-distributiongroupmember media | fl ExternalEmailAddress


	[Create Journal Mailbox]
		New-Mailbox -Name 'Journal Archiver 8' -Alias 'journalarchiver8' -OrganizationalUnit 'sgserver.local/SGCITY Users/Service Accounts' -UserPrincipalName 'journalarchiver8@sgserver.local' -SamAccountName 'journalarchiver8' -FirstName 'Journal' -Initials '' -LastName 'Archiver 8' -ResetPasswordOnNextLogon $false -Database 'ECHO\Journaling Mailbox Database\Mailbox Database' -Password
	[Secure Journal Account]
		set-mailbox "journalarchiver8" -AcceptMessagesOnlyFrom "Microsoft Exchange" -RequireSenderAuthenticationEnabled $True
	[Set Mailbox to Journal]
		set-journalrule -Identity "Journal All Messages" -JournalEmailAddress "" -Scope Global
	[View Journal Account Policy]
		get-journalrule | fl

[Global Address List]

	[Update GAL]
		Update-GlobalAddressList -Identity "Default Global Address List"
	[Offline Address List]
		Update-OfflineAddressBook -Identity "Default Offline Address Book"


	[Reply back if it accepts or denies invitatios]
			Set-MailboxCalendarSettings  -AutomateProcessing:AutoAccept
			get-mailbox -RecipientTypeDetails roommailbox | Set-MailboxCalendarSettings -automateprocessing:autoaccept

[SMTP Connectors]

	[Relay Connector - Allow devices to relay trough]
		New-ReceiveConnector -Name "SMTP Relay" -Usage Custom -AuthMechanism ExternalAuthoritative -PermissionGroups ExchangeServers -Bindings -RemoteIPRanges
	[Add to Relay]
		Set-ReceiveConnector -Identity "SMTP Relay" -RemoteIPRanges,,,,,,,


	[Check Logs]
	[Check Logs - Specifics]
		get-AgentLog | where {$_.ReasonData -eq "blacklistName"}
		get-AgentLog | where {$_.P1FromAddress –contains ""}
		get-AgentLog | where {$_.IPAddress -eq ""}
		get-AgentLog -StartDate "04/20/2010 12:00:00 AM" | Export-Csv ""

[Outlook Anywhere]

	[Enable / Create]
		Enable-OutlookAnywhere -Server 'ECHO' -ExternalHostname '' -DefaultAuthenticationMethod 'Basic' -SSLOffloading $false


	[Restart Services]
		Get-Service MSExchangeImap4 | Restart-Service
		Get-Service MSExchangeTransport | Restart-Service


	[Exchange 2007 View-Only Admin]
		[Set Rights]
			add-exchangeadministrator SGSVR\besadmin -role ViewOnlyAdmin
		[View Rights]
			get-exchangeadministrator | Format-List
	[Send As, Receive As, and Administer Information Store permissions]
		[Set Rights]
			get-mailboxserver ECHO | add-adpermission -user SGSVR\besadmin -accessrights GenericRead, GenericWrite -extendedrights Send-As, Receive-As, ms-Exch-Store-Admin
		[View Rights]
			get-mailboxserver ECHO | get-ADpermission -user SGSVR\besadmin | Format-List
		[Receive As AND Administer Information Store]
			Get-MailboxDatabase | Add-ADPermission -User SGSVR\besadmin -AccessRights ExtendedRight -ExtendedRights Receive-As, ms-Exch-Store-Admin


	[Import and Set]
		Import into IIS
		Get-ExchangeCertificate | FL *
		Enable-ExchangeCertificate -Thumbprint  –Services "IMAP, POP, IIS, SMTP"

[ActiveSync Mailbox Policy]

	[Remove the Default (For PALM PHONES)]
		Remove-ActiveSyncMailboxPolicy –Identity "Default"

[Random Stuff]

	[Export to CSV]
		| Export-Csv ""
		ex: Get-Process | Export-Csv ""
	[Table Formatting]
		After command use: | format-table -autosize -wrap
		ex: get-QADUser username | format-table -autosize -wrap name, empID, memberof
		[Export Allowed Senders of Distribution Group]
			Get-DistributionGroup media | select -expand AcceptMessagesOnlyFrom | Sort-Object rdn | fl rdn | out-file 
	[Check Version]
		Get-ExchangeServer | fl name,edition,admindisplayversion

[Help Sites]

	[About Powershell]

	[Tab and CSV]
	[Contacts and GAL]
	[BES 2007 ]
		[Access Perms for SGSVR\besadmin]
	[General Tips]
	[Outlook Anywhere]
Sponsored by rocketwave