KMS activation of Windows 8.1 and Windows Server 2012 R2

In order to activate Windows 8.1 and Windows Server 2012 R2 using KMS hosted on previous generation of Windows operating system, Microsoft has published following kb article http://support.microsoft.com/kb/2885698/en-us .
After installing the update, you will be able to install and activate your KMS key for Windows 8.1 and (or) Windows Server 2012 R2.
Procedure for installing the KMS host key is the same as installing KMS host key from previous versions of Windows operating systems:
cscript %windir%\system32\slmgr.vbs /ipk <KMS host key>
You will experience following error if you are installing KMS host key on Windows operating system that is not associated with that host key:
0xc004f015: The Software Licensing Service reported that the license is not installed. SL_E_PRODUCT_SKU_NOT_INSTALLED
 For example:
  • Windows 7 KMS host key install on Windows Server 2008 R2
  • Windows 8 KMS host key install on Windows Server 2008 R2, Windows Server 2012
  • Windows 8.1 KMS host key install on Windows Server 2008 R2, Win Server 2012 and R2
 Activate the KMS host key using:
cscript %windir%\system32\slmgr.vbs /ato
In my case the KMS server was using proxy for connecting to internet and the user activating the KMS host key was not having proper permission to access the Microsoft's Internet Activation Servers. The activation was failing with following error message 0x8004FE92:
On a computer running Microsoft Windows non-core edition, run 'slui.exe 0x2a 0x8004FE92' to display the error text. Error: 0x8004FE92
Running the 'slui.exe 0x2a 0x8004FE92' does not provide a lot of help:

 
After providing proper Internet access for the user, activating the KMS host key has completed successfully. More about 0x8004FE92 error message can be found on http://support.microsoft.com/kb/2009934/en-us .

 

Folder redirected offline folders out of sync

A colleague of mine on his Windows 7 client workstation was complaining about his profile redirected offline folders that were out of sync with folders that were residing on file server. He tried almost everything to get those files and folders in sync, so finally last chance to rescue was to reset offline database and re-initialize the cache of offline files.
In order to do that, following registry entry has to be created:
FormatDatabase  DWORD (32 bit value) : 1
in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\CSC\Parameters

After rebooting the client, redirected offline folders started to work as expected.

Note: Before taking this action please make backup of your files, because unsynchronized changes will be lost.

Unable to delete VHD from VMM library

While browsing the VMM 2012 SP1 library, I found an obsolete VHD, and I wanted to delete it from there. But, when I tried to delete this obsolete VHD, VMM was complaining with following error message:

The library object (Name of the VHD) cannot be removed because following objects are dependent on it:
Virtual Hard Disk deployment configuration
In order to delete this VHD from VMM library I have opened table tbl_WLC_VHDConfig from VM database using SQL Management Studio. In this table there is a column named "SourceLocation". In this column we can find the ID of the offending VHD. But how to find the ID of VHD ? Using Get-VirtualHardDisk cmdlet you can list all the VHDs with their IDs:
Get-VirtualHardDisk | ft name,id
Now when we have the ID of the VHD, we can create new query from SQL Management Studio to delete the row containing VHD ID in SourceLocation column:

Delete From dbo.tbl_WLC_VHDConfig Where SourceLocation = 'VHD ID'


Note: Make a backup of the VM database before changing (deleting) rows from database, and this operation is not recommended by Microsoft, so perform at your own risk.

Creating Custom Queries For Searching TMG 2010 Logging Databases

In this case I was trying to find out unique client IP addresses that were accessing TMG published web site in last 3 days. TMG server was having locally installed logging database. One way to achieve this task is using SQL Server Management Studio, another way is using powershell. In this article, I'll show how I have found the ip addresses using powershell.
After importing the SQLServerCmdletSnapin100, Invoke-Sqlcmd cmdlet will be available for running:
Add-PSSnapin SQLServerCmdletSnapin100
Now it's time to create the SQL query using here-strings:
$query=@"
SELECT ClientIP as IPAddress from
(SELECT DISTINCT ClientIP
FROM [ISALOG_20130926_WEB_000].[dbo].[WebProxyLog] WHERE [WebProxyLog].[Rule] = 'TMG Rule Name'
UNION
SELECT DISTINCT ClientIP
FROM [ISALOG_20130925_WEB_000].[dbo].[WebProxyLog] WHERE [WebProxyLog].[Rule] = 'TMG Rule Name'
UNION
SELECT DISTINCT ClientIP
FROM [ISALOG_20130924_WEB_000].[dbo].[WebProxyLog] WHERE [WebProxyLog].[Rule] = 'TMG Rule Name')t1;
"@
The SQL query is simple, so I'm not going into details.
Now it's time to execute the query using invoke-sqlcmd :
Invoke-Sqlcmd -Query $query -ServerInstance localhost\msfw -QueryTimeout 300 | ft

The result will contain IP addresses in unfriendly readable format, something like:
C0A8018A-FFFF-0000-0000-000000000000 
The reason for this kind of logging, is that TMG is using same field for logging IPv4 and IPv6 addresses. One way for converting CAA8018A into 192.168.1.138 is using Excel formula which looks like this:

HEX2DEC(MID(A1,1,2)) &"."&HEX2DEC(MID(A1,3,2))&"."&HEX2DEC(MID(A1,5,2))&"."&HEX2DEC(MID(A1,7,2))


Happy IP addresses hunting :)

How to assign IP address in WinPE

This is quick one, assigning static IP address (for example 192.168.0.10/24 and gateway 192.168.0.1) in WinPE is using netsh:

netsh int ip set address "name of local area connection" static 192.168.0.10 255.255.255.0 192.168.0.1

How to check EMBG (Unique Master Citizen Number) using regex

In this post, I will share my implementation of how to check if some number looks like EMBG or Unique Master Citizen Number. For those of yo...