31 May 2012

Migrate public folders in Exchange 2010

If you want to decommission an public folder database (in Exchange you can have one PF database per server), then you must move replicas to another database:

C:\Program Files\Microsoft\Exchange Server\V14\Scripts\MoveAllReplicas.ps1 -Server oldserver -NewServer newserver

Where oldserver is the server where is the database to be freed and newserver is the server where public folders should be located.

image

With those command you can see, where each folder needs to be replicated:

Get-PublicFolder -recurse | ft name,replicas
Get-PublicFolder -recurse \non_ipm_subtree | ft name, replicas

To speed up replication, you can use Exchange Public Folder Management Console (found on Exchange Management Console Toolbox):

image

This updates hierarchy information on connected public folder server (to change the focus to another server, you can use “connect to server…” option).

To update a particular public folder (the right click must be done on right pane, not on the tree):

image

To check replication status, you can use this command:

Get-PublicFolderStatistics –Server oldserver

image

After the replicas are gone, you can remove the database. If a folder is stuck, you must wait several hours or even days. If this doesn’t help, you can export the public folder to PST file and delete the folder. Then create a new folder and import the content.

30 May 2012

Distribute mailboxes around databases in Exchange 2010

Exchange 2010 has a functionality, that allows you to distribute mailboxes around databases. This example script frees up the (old) database and spreads mailboxes to other mailbox databases:

$mdb = Get-MailboxDatabase mailbox*
$mdb | Set-MailboxDatabase -IsExcludedFromProvisioning $true
Get-Mailbox -Database $mdb | New-MoveRequest -SuspendWhenReadyToComplete

First command gets the database object into $mdb variable. Second command excludes the (old) database from being used in optimization process. Third line get’s all mailboxes located on old mailbox database and moves them to best suitable database (it happens when you don’t specify the exact target database). Suspend option will pause the move in the very last phase on moving process – so this command can be executed even on business hours. On Exchange 2010 the move-request is a background process and consumes very little resources. When all move requests are at 95% (state: automatically suspended), then you can execute the command:

Get-MoveRequest | Resume-MoveRequest

This command should be executed on off-hours.

Outlook Web App/Outlook Web Access redirection

If you want to use OWA using plain external.name (http://external.name) instead of https://external.name/owa, then some kind of redirection is needed. IIS redirection can sometimes bite you on other exchange services (ews, oab etc.), so I suggest you NOT to use IIS redirection shown in the picture:

image

Best way to do the redirection for Outlook Web App is using an html file with the following code:

<meta HTTP-EQUIV="REFRESH" content="0; url=https://external.name/owa">

Usually the file can be named default.htm and placed in c:\inetpub\wwwroot on your exchange server.

A nice editor for editing html files is Notepad++ (http://notepad-plus-plus.org/). It shows colorful content for plain text files

image

29 May 2012

How to delete files older than X days from command line

You might need to use forfiles command for that. Following example removes all files older than 50 days from current directory :

forfiles /d -50 /c "cmd /c del @path"

For detailed instructions on forfiles switches see:

forfiles /?

Plain forfiles lists all files in current directory. Option /D -50 filters out files older than 50 days. And /c "cmd /c del @path" executes the command prompt with del command and exit’s from that command prompt.

28 May 2012

Convert AI file to bitmap/PNG

To convert AI file to bitmap/PNG file, the best free tool seems to be Inkscape http://inkscape.org/. It opens AI files naturally and has export to bitmap function (STRL+SHIFT+E).

image

The best thing is, that it supports transparency on PNG images. PNG is lossless picture format.

25 May 2012

Word 2010 “Error! Unknown document property name”

If you got an error in Word text after print preview or after printing:

image

This place in your document was containing some other text. If you want to print your document without error code(s), you must convert affecting fields to text before printing.

To see, what is the field formula behind that, you can press Alt+F9, which toggles the field codes on/off. Codes will look like this:

image

Anyway, you must open the document again and convert each field to text with Ctrl+Shift+F9 (your cursor must be inside the field and the surrounding text will be grayed). Of course you can select all text with Ctrl+A to replace all fields to text at once. If the field is in footer or header area, you must double-click it first, and then press Ctrl+A-

24 May 2012

Suppress Outlook 2010/2013 and Lync 2010/2013 autodiscover message

This message appears, when you start Outlook 2010 or Outlook 2013 and you use DNS SRV record to find your autodiscover service:

image

Lync 2010 has also sometimes the similar message with “Connect” and “Try Another Server” buttons:

image 

In Lync 2013 the message “Lync is attempting to connect to:” looks like this

 image

This feature can be fixed with the following registry keys

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Communicator]
"TrustModelData"="online.lync.com, outlook.com, lync.glbdns.microsoft.com, mail.yourdomain.com"

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Office\15.0\Lync]
"Trustmodeldata"="mail.yourdomain.com, lyncserver.yourinternaldomain.internal"

[HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\AutoDiscover\RedirectServers]
"mail.yourdomain.com"=hex(0):

[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\AutoDiscover\RedirectServers]
"mail.yourdomain.com"=hex(0):

where mail.yourdomain.com is the A record where your _autodiscover._tcp.maildomain.com SRV record points to. 14 and 15 are Outlook versions 2010 and 2013. Communicator part of the registry change is for Lync 2010 and 15.0/Lync part is for Lync 2013.

23 May 2012

Port forwarding on Windows computers

If you want to forward a incoming port to another computer, there’s a simple command to do this:

netsh interface portproxy add v4tov4 listenport=25 listenaddress=0.0.0.0 connectport=25 connectaddress=192.168.1.200

This command will “install” a SMTP server in one second. Nice thing is, that this port forwarding remains active even after restarting your computer.

To view all active forwards, use the following command:

netsh interface portproxy show all

To delete all active forwards or to delete one of those, use one of the following commands:

netsh interface portproxy reset
netsh interface portproxy delete v4tov4 listenport=25 listenaddress=0.0.0.0

image

Not so nice thing is, that you cannot use 127.0.0.1 as connectaddress. This might be necessary when you want to publish your unknown service to another port. Also UDP cannot be forwarded. To verify, that a port is actually listening or forwarding you can use netstat:

netstat -ano | findstr :25

To view what is the process name using that port (XXX is process ID):

tasklist | findstr XXX

image


As an alternative you can use PassPort application http://sourceforge.net/projects/pjs-passport. It runs also on Windows XP, can forward UDP, use 127.0.0.1 as a destination and is graphical utility.

image

22 May 2012

Check Exchange 2010 internal and external URL configuration

To quickly get an overview of an Exchange system URL configuration, I recommend to use the following PowerShell commands:

Get-ActiveSyncVirtualDirectory   | ft server,*lur* -AutoSize
Get-AutodiscoverVirtualDirectory | ft server,*lur* -AutoSize
Get-ClientAccessServer           | ft name,  *lur* -AutoSize
Get-EcpVirtualDirectory          | ft server,*lur* -AutoSize
Get-OabVirtualDirectory          | ft server,*lur* -AutoSize
Get-OwaVirtualDirectory          | ft server,*lur* -AutoSize
Get-WebServicesVirtualDirectory  | ft server,*lur* –AutoSize

Output looks like that:

image

Host names can be different, but on small installation scenarios a common FQDN is used from both internal and external URL’s. Picture is good for checking the internalurl and externalurl formats.

21 May 2012

Microsoft DPM 2010 delete inactive replicas

Sometimes, when a protection group is modified, the leftovers from protection group will remain as inactive data. If you’re not intending to restore this data in the future, there’s a simple command to remove those and free up disk space.
image
Get-Datasource -Inactive | Remove-DatasourceReplica –Disk
Instead of graphical interface boring clicking and removing you can do this almost instantly. What this script does:
Get’s inactive datasources on defined server and removes them from your disk.

18 May 2012

Nslookup indefinitely using PowerShell

If you are waiting for a specific DNS record to be created, then it’s nice to use the following PowerShell command:

do {nslookup google.ee. 8.8.8.8;sleep 1} while (1)

image

It’s an indefinite loop with two commands:

  1. nslookup for DNS query;
  2. sleep for waiting one second between the next query

It can be used for other commands too.

17 May 2012

SharePoint Search is not working (WSS3)

Got the error message in event log:

Log Name:      Application
Source:        Windows SharePoint Services 3 Search
Date:          17.05.2012 12:38:44
Event ID:      4127
Task Category: Content index server
Level:         Error
Keywords:      Classic
User:          N/A
Description:
Content index on Search could not be initialized. Error The content index is corrupt.   0xc0041800.Component: ee266698-5555-4b4e-b742-1e5332811f54

Easy solution was to go to the SharePoint Administration Site and stop&start the Search Service (Operations –> Services on Server):

image

After pressing the start link I accepted all defaults except database name (which should be deleted from SQL first, but I chose to create a new database with different name)

IP to MAC conversion

On the LAN packets are sent between computers and switches using MAC addresses. FQDN (fully qualified domain name) will be resolved to IP addresses using DNS (domain name system) servers. To test how name is resolved to IP address, you can use command:

nslookup google.ee 8.8.8.8

“nslookup” is command’s name, “google.ee” is name to be resolved and “8.8.8.8” is a DNS server on the Internet or LAN (you can omit the last option, then it uses first DNS server found in ipconfig /all). Result looks like that:

image

Next step would be the IP to MAC conversion (this will be done only for local subnet addresses). If address is on remote subnet, then the local gateway’s MAC address needs to be resolved. To test a IP2MAC conversion, you probably ping the IP address and then run following command:

for IPv4 addresses: arp -a

to find a particular IP address: arp –a | findstr 192.168.0.1

image

for IPv6 addresses: netsh interface ipv6 show neighbors

to find a particular IP address: netsh interface ipv6 show neighbors | findstr fe80::3579

image

To find local MAC address, use getmac or ipconfig /all command

16 May 2012

Exchange 2010 new mailbox not appearing in Outlook 2010

The update in offline address book will take up to 2 days (or even more as I recently found out). The time taken is divided in 4 sub-tasks:

  1. Active Directory synchronization – for multiple sites and rare replication frequency from 15 minutes to 24 hours (usually not a big slowness factor)
  2. Offline Address Book generation – usually 24 hours refresh rate (will be create in the morning hour every day, but can be changed to more frequent basis)
    image
  3. Exchange File distribution service file updating on IIS web site – will be created every 480 minutes or 8 hours. Can be retrieved in Exchange Management Shell:
    Get-ExchangeServer | ? {$_.serverrole -like "*client*"} | Get-OabVirtualDirectory | ft server,pollinterval
    Gets all Exchange Servers, having Client Access Role. From those get OAB virtual directory parameter pollinterval. The parameter can be configured with Set-OabVirtualDirectory cmdlet.
    Get-ExchangeServer | ? {$_.serverrole -like "*client*"} | Get-OabVirtualDirectory | et-OabVirtualDirectory –pollinterval 15
  4. Outlook download address book once per day.

To speed up things:

  1. Start dssite.msc and replicate connections (Active Directory Sites and Services)
  2. Get-Offlineaddressbook | Update-OfflineAddressBook
  3. Get-ExchangeServer | ? {$_.serverrole -like "*client*"} | Update-FileDistributionService
  4. In Outlook:
    image