All posts by ArchMunky

Watch text files in real time with powershell

To monitor the contents of a text file (like a log file) using Powershell, you can use the following command:

Get-Content someFile.txt -wait

Getting Windows build number

Normally you can just use “winver” (or “ver” in command prompt) to get the version number but it doesn’t always return the build number.

You can find the build number in the registry; use the following command in cmd:

reg query "HKLMSOFTWAREMicrosoftWindows NTCurrentVersion" | findstr BuildLabEx

Windows ISO version checking

If you want to see which version of Windows is contained in an ISO image, mount the image and run the following command in an elevated cmd/powershell window:

dism /Get-WimInfo /WimFile:A:sourcesboot.wim

Be sure to change A: to the correct drive letter where the image is mounted.  Also, combined x86/x64 ISO images will need to include the architecture before “sources”.

dism /Get-WimInfo /WimFile:A:x86sourcesboot.wim
dism /Get-WimInfo /WimFile:A:x64sourcesboot.wim

Windows Server activation via KMS

Nothing is more fun that finding out a production server has not been activating via KMS like it was supposed to be doing.  Imagine my surprise logging in and seeing a “Windows is not activated” message.  Re-entering the correct kms setup didn’t solve it; in fact, it didn’t even send a KMS message to the server.

It turns out the server was in MAK licensing mode.  I found that out by running the command “slmgr /dlv” in an elevated command prompt and seeing VOLUME_MAK in the description.

Continue reading Windows Server activation via KMS

SQL Server: database owner SID issue

If you restore a database on a different SQL Server you may see the following error message:

The database owner SID recorded in the master database 
differs from the database owner SID recorded in database...

The solution is to change the authorization on the database to a known SQL account:

alter authorization on database::{databasename} to {username}

Simply replace the {databasename} and {username} with the appropriate names; the brackets should not appear in the SQL query.