Tag Archives: exchange

Exchange 2010 Relay

New-ReceiveConnector -Name RelayConnector -usage Custom -Bindings ’192.168.1.10:25′ -fqdn server.domain.com -RemoteIPRanges 192.168.1.20 -server MYEXCHANGESERVER -permissiongroups ExchangeServers -AuthMechanism ‘TLS, ExternalAuthoritative’

The easist way is just to run this command in powershell:

Where:
192.168.1.10:25 is the IP address of the Exchange server
192.168.1.20 is the ip of the clients how need access to relay
server.domain.com is you exchange server FQDN
MYEXCHANGESERVER is you exchange server hostname

Change autodiscover URL (EWS URL / OAB URL / ECP URL / Activesync URL) – Exchange 2010

If you want to change Autodiscover / EWS / OAB / OWA / ECP / Activesync Url, this is how it works

Set-WebServicesVirtualDirectory -Identity “SERVERNAME\EWS (Default Web Site)” -InternalUrl https://INTERNALURL/EWS/Exchange.asmx -externalurl https://EXTERNALURL/EWS/Exchange.asmx -BasicAuthentication:$true

Set-AutoDiscoverVirtualDirectory -Identity "SERVERNAME\Autodiscover (Default Web Site)" -internalurl https://INTERNALURL/autodiscover/autodiscover.xml -externalurl https://EXTERNALURL/autodiscover/autodiscover.xml

set-OabVirtualDirectory -identity "SERVERNAME\OAB (Default Web Site)" -internalurl https://INTERNALURL/OAB -externalurl https://EXTERNALURL/OAB

set-EcpVirtualDirectory -identity "SERVERNAME\ecp (Default Web Site)" -internalurl https://INTERNALURL/ecp -externalurl https://EXTERNALURL/ecp

set-OwaVirtualDirectory -identity "SERVERNAME\owa (Default Web Site)" -internalurl https://INTERNALURL/owa -externalurl https://EXTERNALURL/owa

set-ActiveSyncVirtualDirectory  -identity "SERVERNAME\Microsoft-Server-ActiveSync (Default Web Site)" -internalurl https://INTERNALURL/Microsoft-Server-ActiveSync -externalurl https://EXTERNALURL/Microsoft-Server-ActiveSync

Set-ClientAccessServer -Identity "SERVERNAME" –AutoDiscoverServiceInternalUri https://INTERNALURL/autodiscover/autodiscover.xml

Or if this is a single server installation you can do it like this:

get-WebServicesVirtualDirectory | Set-WebServicesVirtualDirectory -InternalUrl https://INTERNALURL/EWS/Exchange.asmx -externalurl https://EXTERNALURL/EWS/Exchange.asmx -BasicAuthentication:$true

get-AutoDiscoverVirtualDirectory | Set-AutoDiscoverVirtualDirectory -internalurl https://INTERNALURL/autodiscover/autodiscover.xml -externalurl https://EXTERNALURL/autodiscover/autodiscover.xml

get-OabVirtualDirectory | set-OabVirtualDirectory -internalurl https://INTERNALURL/OAB -externalurl https://EXTERNALURL/OAB

get-EcpVirtualDirectory | set-EcpVirtualDirectory -internalurl https://INTERNALURL/ecp -externalurl https://EXTERNALURL/ecp

get-OwaVirtualDirectory | set-OwaVirtualDirectory -internalurl https://INTERNALURL/owa -externalurl https://EXTERNALURL/owa

get-ActiveSyncVirtualDirectory | set-ActiveSyncVirtualDirectory  -internalurl https://INTERNALURL/Microsoft-Server-ActiveSync -externalurl https://EXTERNALURL/Microsoft-Server-ActiveSync

get-ClientAccessServer | Set-ClientAccessServer  –AutoDiscoverServiceInternalUri https://INTERNALURL/autodiscover/autodiscover.xml

Lost trust on my Exchange 2010 after revert to a older snapshot

I was returing to an older snapshot of my Exchange servers. But when i want to logon to the Exchange server, it came with “Trust relationship has been lost with domain controller”.

Normally you just rejoin the domain, but this is not a good idea, when there is installed Exchange services on it.

I fix this with netdom.
Logon to the Exchange with a locally logon account.
Start command with Administrator rights
Type: netdom /RESETPWD /server:DOMAINCONTROLLER /UserD:DOMAINNAME\ACCOUNTNAME /PasswordD:PASSWORD OR *

Exchange 2010, show permission on all folders in all mailboxes

Here is a script, that runs though you Exchange server, and return all permission on all folders in all mailboxes.

The script needs to be running from the Exchange management Shell, and will create a subfolder in c:\ call ExchangeMailboxPermission, where it will create a text file for all yours mailboxes.

#This script will return all permissions on all folders
#in all mailboxes
#
#Written by Kenneth Dalbjerg - http://www.kennethdalbjerg.dk
#
$FolderPath = 'C:\ExchangeMailboxPermission\'
if ((Test-Path -path $FolderPath) -ne $True)
{
New-Item $FolderPath -type directory
}

$mailboxes = get-mailbox -resultsize unlimited
foreach ($mailbox in $mailboxes) {
$alias = $mailbox.DistinguishedName
$username = $mailbox.SamAccountName
$SpecialExchangeFolders = "Top of Information Store|Recoverable Items|Deletions|Purges|Versions"
$mailboxfolderes = Get-MailboxFolderStatistics -folderscope all -identity $alias | where { $_.name-notmatch $SpecialExchangeFolders }
$File = $FolderPath + '\' + $username + '.txt'
$mailboxfolderes | foreach {
$folder = $username + ':' + $_.folderpath -replace "/","\"
echo $folder
Get-MailboxFolderPermission -identity $folder
} | Out-file $File
}

Exchange 2010, powershell full access and send-as permission

To get a CSV file, from you exchange with full access and send as permission, from all you mailboxes run these commands:

Full Access

Get-Mailbox | Get-MailboxPermission | where {$_.user.tostring() -ne “NT AUTHORITY\SELF” -and $_.IsInherited -eq $false} | Select Identity,User,@{Name=’Access Rights’;Expression={[string]::join(‘, ‘, $_.AccessRights)}} | Export-Csv -NoTypeInformation c:\mailboxpermissions.csv

Send As

Get-Mailbox | Get-ADPermission | where { ($_.ExtendedRights -like “*Send-As*”) -and ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”) } | Select Identity, User, Deny | Export-CSVc:\sendas.csv

Microsoft Exchange 2010 – Ahsay restore to recovery mailbox database / storage group.

Ahsay have no support for native restore to Exchange recovery group, but here is a workaround of that problems.

First create a recovery storagegroup
New-MailboxDatabase -Recovery -Name RDB1 -Server exch2010 -EdbFilePath “F:\Backup\Restore\Data\rdb1.edb” -LogFolderPath “F:\Backup\Restore\Log”
Where RDB1 is the name of the Recovery database and Exch2010 is the name of the servere where recovery database should be located.

Restore the Exchange 2010 database to a alternative location in ahsay. With both logfiles and the database files, restore it to “F:\Backup\Restore\Data\Mailbox Database.edb” or where you location is.

Then run repair of the restored database.
Eseutil /p “F:\Backup\Restore\Data\Mailbox Database.edb”

Then mount the database
Mount-Database -Identity ‘Mailbox Database’

Example restore a mailbox to a Restore mailbox in the real database.
Restore-Mailbox -Identity ‘mailbox_to_restore_content_to’ -RecoveryDatabase RDB1 -RecoveryMailbox ‘Mailbox_Restore’ -TargetFolder Recovery

This will create a folder name Recovery under mailbox_to_restore_content_to, with the content of Mailbox_Restore

[PS] C:\Recovery20110909>Restore-Mailbox -Identity jvrestore -RecoveryDatabase RDB1 -RecoveryMailbox ‘Jesper Vernegaard’
-TargetFolder Recovery

Roles to be installed before Exchange 2010 SP1

Start powershell and run import-module servermanager

Then run

Add-WindowsFeature NET-Framework,RSAT-ADDS,Web-Server,Web-Basic-Auth,Web-Windows-Auth,Web-Metabase,Web-Net-Ext,Web-Lgcy-Mgmt-Console,WAS-Process-Model,RSAT-Web-Server,Web-ISAPI-Ext,Web-Digest-Auth,Web-Dyn-Compression,NET-HTTP-Activation,RPC-Over-HTTP-Proxy -Restart