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














































































































































































































































































































































Exchange 2007 Powershell CMDLETS
[Users]

	[Import Mailbox from PST]
		Import-Mailbox -Identity  -PSTFolderPath 
		[Or]
		Get-Mailbox -Identity  | Import-Mailbox -PSTFolderPath 
		[No Prompt]
		Import-Mailbox -Identity "domain\username1" -PSTFolderPath "c:\username1.pst" -Confirm:$False
		[Multiple]
		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 "@sgcity.org"


[Contacts]

	[Mail-Enable a Contact]
		Enable-MailContact -Identity "Foo" -ExternalEmailAddress foo@nothing.org

	[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 } }


[Groups]

	[Query all distribution groups]
		[Show which the user is a member of]
			$user = get-user "@sgcity.org"; 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 = $_.name; 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


[Journaling]

	[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 "journalarchiver7@sgcity.org" -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"


[Room]

	[Reply back if it accepts or denies invitatios]
		[Single]
			Set-MailboxCalendarSettings  -AutomateProcessing:AutoAccept
		[All]
			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 10.1.1.12:25 -RemoteIPRanges 10.1.9.9
	
	[Add to Relay]
		Set-ReceiveConnector -Identity "SMTP Relay" -RemoteIPRanges 10.1.1.35, 10.1.4.18, 10.1.9.8, 10.1.9.9, 192.168.1.141, 10.1.1.11, 192.168.8.80, 168.179.242.40


[SPAM]

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


[Outlook Anywhere]

	[Enable / Create]
		Enable-OutlookAnywhere -Server 'ECHO' -ExternalHostname 'echo.sgcity.org' -DefaultAuthenticationMethod 'Basic' -SSLOffloading $false
		
	[Testing]
		Test-OutlookWebServices


[Service]

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


[Blackberry]

	[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


[Certificate]

	[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]
		http://www.techotopia.com/index.php/The_Basics_of_the_Windows_PowerShell_1.0_Interactive_Shell

	[Tab and CSV]
		http://thepowershellguy.com/blogs/posh/archive/2007/03/24/hey-powershell-guy-how-can-i-parse-a-tab-delimited-file-and-then-save-that-as-a-comma-separated-values-file.aspx
	
	[Contacts and GAL]
		http://it.peterspowerblog.com/2008/07/03/hiding-contacts-from-global-address-list-using-exchange-powershell.aspx
	
	[Rooms]
		http://social.technet.microsoft.com/Forums/en-US/exchangesvrdeploy/thread/063bbfee-c2a9-4e61-a263-5862a315e9d2
	
	[BES 2007 ]
		http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB14502
		[Access Perms for SGSVR\besadmin]
			http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB12483
	
	[Journaling]
		http://technet.microsoft.com/en-us/magazine/2006.12.journaling.aspx
	
	[General Tips]
		http://www.eggheadcafe.com/conversation.aspx?messageid=30523978&threadid=30523969
	
	[Outlook Anywhere]
		http://blog.aaronmarks.com/?p=65
		http://blogs.technet.com/exchangept/archive/2008/03/07/global-certificates-and-outlook-anywhere.aspx
	
	[Spam]
		http://technet.microsoft.com/en-us/library/aa996044%28EXCHG.80%29.aspx
*/?>
Sponsored by rocketwave