26 November 2012

How to get Windows Server uptime

The quickest way to determine, how long the server you are working with, has been up and running is:

wmic os get lastbootuptime

It returns the result in ISO date format:

image

The +120 means time zone information (UTC +2 hours).

20 November 2012

How to remove unwanted e-mail addresses from Mail Contacts in Exchange 2010

Default e-mail address policy creates for every recipient object an address with @your.domain at the end. This is true even for Mail Contacts. So when you need an external contact (for adding to a distribution group for example), you unintentionally gave an address of your domain also. For that you need to create a new policy, to prevent such things.

The policy will be with the following parameters (the Container should also be selected, it’s not yet done on this screenshot):

image

The filtering part can be skipped with Next button. You cannot skip e-mail addresses page, so just create a new address, that is with an address, that is not present in internet (usually your local domain name will be sufficient @domain.local for example):

image

Click Next, Next and New. Now you should be done. If you create a new contact, only this address will be added. For existing contacts you need to remove previously created @your.domain addresses. For that you will need few commands in Exchange Management Shell:

$contacts = Get-MailContact -ResultSize unlimited
$contacts | foreach {$contact = $_; $email = $contact.emailaddresses; $email | foreach {if ($_.smtpaddress -like "*@your.domain") {$address = $_.smtpaddress ; Set-Mailcontact -Identity $contact.identity –forceupgrade -EmailAddresses @{Remove=$address}}}}

The script gets all MailContact objects into $contacts variable. For each member of the variable (each contact) email addresses will be extracted and verified to match for specific condition (matching your domain name). If it matched, then it will be removed from the corresponding MailContact object. ForceUpgrade is needed, if some of the objects are created in previous Exchange version.

17 November 2012

How to change case quickly in Word 2013 (and older versions)

Recently I made a typo in Word by pressing CTRL+SHIFT+K instead of SHIFT+K (uppercase letter K) and suddenly the word, I was in middle off, changed like that:

image

So it made lowercase letters to small capitals.

Which reminds me of an older discovery to change case with SHIFT+F3 key combination:

image

This rotates between small case, UPPERCASE and Title Case. First of all you need to be in the middle of a word

image

or select several words.

image

10 November 2012

How to save YouTube video to a file in played quality

To do this, you need 2 free tools:

  1. Google Chrome (www.google.com/chrome)
  2. VLC Player (www.videolan.org/vlc)

Start watching your video in chrome. To test, you can use this URL http://youtu.be/9bZkp7q19f0. Remember to choose the needed resolution:

image

Wait for the buffering to end. You don’t need to watch the video to the end. It’s the light grey bar that indicates the buffering:

image

Open the folder:

%localappdata%\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash

image

And copy the .TMP file to your desktop. Rename it to something more meaningful and change the extension to .FLV

image

You can open this video now with VLC Player.

As a side note, you can export the video to other audio/video formats using VLC (including MP3)

image

Enjoy your favorite videos even offline.

07 November 2012

How to monitor Exchange 2010 database health

If you have fault tolerant RAID1 disk system, you can have a failure of one HDD. But when this happens, you are vulnerable. So you need a solution for monitoring this kind of events.

In Exchange 2010 you can have mirrored databases, where you expect the same kind of fault tolerance. If you don’t have a huge monitoring software, you can use a simple PowerShell script:

$date = Get-Date
"Adding Exchange snapin"
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
$mailboxservers = Get-ExchangeServer | ? {$_.serverrole -like "*mailbox*"}
$info = $mailboxservers | foreach {Get-MailboxDatabaseCopyStatus -Server $_.name}

$filename2 = "c:\serverinfo\Exchange Databases {0}.{1:d2}.{2:d2} {3:d2}.{4:d2}.csv" -f $date.year,$date.month,$date.day,$date.hour,$date.minute
$info | Export-Csv -Path $filename2 -encoding utf8
$info2 = $info | where {($_.Status -ne "Healthy" -and $_.Status -ne "Mounted") -or $_.ContentIndexState -ne "Healthy"}
$info3 = $info2 | ConvertTo-Html
$info4 = [string]$info3

if($info2){
Send-MailMessage -SmtpServer yoursmtpservername -To
to@addre.ss -From from@addre.ss -Subject "Exchange databases having bad times" -Body $info4 -BodyAsHtml
}

This script in short:

It finds all mailbox servers, on each of them gets the status of mailbox database copies and if anything is wrong with database or index status, then it sends a message. As a bonus it saves the full info to a CSV file for troubleshooting.

This script should be run with task scheduler every hour or so.

02 November 2012

Change retention range for all protections groups in DPM 2012

Let’s assume, you have installed your DPM server, created a bunch of protection groups and everything runs smoothly. By default a protection group holds backups for 5 days. To get the information about your protections groups, use this command:

Get-ProtectionGroup -DPMServerName yourdpmservername | ft FriendlyName,OnsiteRecoveryRange -a

The result looks like this:

image

First you need to open protection group for writing:

Get-ProtectionGroup -DPMServerName yourdpmservername | Get-ModifiableProtectionGroup

To change the retention range to 10 days, use this command:

Get-ProtectionGroup -DPMServerName yourdpmservername | Set-PolicyObjective -RetentionRangeDays 10 -BeforeRecoveryPoint

This command doesn’t give any output and runs very fast.

To write changes, use this command:

Get-ProtectionGroup -DPMServerName yourdpmservername | Set-ProtectionGroup

After change you can confirm the result with the first command introduced in this article.