Thursday, July 17, 2008

Determining your Hyper-V version

<rant>

Figuring out versions is often way too hard. Why can't I simply see the version in Add or Remove Programs or in the feature overview? Why do I have to mess around with build numbers? Isn't this 2008!

</rant>

The other day, I had to figure out which Hyper-V and SCVMM version a server was running. Luckily, I found this and this article.

I PowerShelled the Hyper-V part, so you can use it easily in your scripts (and if you execute the WMIC command from PowerShell, it will not work owing to parsing differences between cmd and PowerShell). Here is my Get-HyperVVersion.ps1, but you can also execute it directly -

$file=get-command c:\windows\system32\vmms.exe
switch ($file.fileversioninfo.productversion.split(".")[-1]) {
17101 { "Beta" }
18004 { "RC0" }
18010 { "RC1" }
18016 { "RTM" }
}


Note how Get-Command can 'reveal' the versioninfo of a executable/DLL.

Tuesday, July 08, 2008

Get-PublicIp4Address.ps1

Using dyndns' checkip page and two lines of PowerShell, you can get your public IP address easily -

$wc=New-Object net.webclient
$wc.downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]"



Note the use of -replace with a single argument. This removes the pattern and works like -replace "string","". I also really like that you can call a method and work directly on the output.



You could turn this into a one-liner -




(New-Object net.webclient).downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]"



but I think the two-line version is much easier to read, so I'll stick to that.



PS. Regex interpreration: Remove everything not (^) a digit (\d) or a dot (\.). The webpage returns a string like "Current IP Address: 10.1.2.3" and I wanted to get rid of the extra stuff.

Monday, July 07, 2008

Microsoft Office Open Protocol Specifications

So Microsoft is releasing a lot of information on the way that it uses and support the different protocols in Office, which includes Office Communications Server 2007.

Why is this interesting for you/us? Well maybe you have a problem with ABS download, Firewall Traversal, Sending DTMF digits or similar issues that you have problems solving or maybe you are developing applications that integrate with the Microsoft UC platform; then these specifications are a excellent guide to the inner workings of OCS. Find information from the homepage here -

Microsoft Office Protocol Documents

The Microsoft Office protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used by Microsoft Office 2007 to interoperate or communicate with other Microsoft products.

The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information.

Audience

The Microsoft Office protocol documentation is intended for use in conjunction with publicly available standard specifications and network programming art. It assumes that the reader either is familiar with this material or has immediate access to it.

The technical documentation provides the following levels of audience support:

  • Implementer: Sufficient conceptual and reference information for a successful implementation of one or more protocol specifications for a given task or scenario.

  • Reviewer: A definitive resource for readers who want to evaluate or understand one or more protocols.

The Microsoft Office protocol documentation provides detailed technical specifications for Microsoft proprietary protocols (including extensions to industry-standard or other published protocols) that are implemented and used by Microsoft Office 2007 to interoperate or communicate with other Microsoft products.

The documentation includes a set of companion overview and reference documents that supplement the technical specifications with conceptual background, overviews of inter-protocol relationships and interactions, and technical reference information.

Find the documentation at MSDN

Friday, July 04, 2008

Constructing commands/command line - a PowerShell hint

I was just trying to compose a correct robocopy command in my script - and instead of having robocopy to give me an error, I would like to see the command before attempting to test the command. Naturally, I could built up the command in a string and echo/execute that, but when it can be done easier (we are talking a 5 line script here) it should.

I have something like this

robocopy $from "$(split-path -parent $myinvocation.mycommand.definition)"\subpath /mir



Now, if I want to see what that resolves to, I normally would surround it with quotes, echoing it out. But when you do that, you have to take the existing quotes into account and start duplicating or escaping them. Not so great. And using single quotes is not an option as that will turn off variable substitution. Luckily, PowerShell has the here-double quote operator: @" "@. This multi-line quoting operator does not require quotes in the content to be doubled.



So to see the command, surround it with @" on the line above and place "@ on the line below. Remember that "@ must start in column 1 of the line to end the string.




@"
robocopy $from "
$(split-path -parent $myinvocation.mycommand.definition)"\subpath /mir
"
@



 



You should also remember that PowerShell has the here-single quote operator @' and '@. In this case, variable substitution is not performed.

Wednesday, July 02, 2008

Hyper-V SuperSite Article

Paul Thurrott has written/updated his Windows Server 2008 Hyper-V article. Amongst other things, it seems like Hyper-V performance is very good. Read it for yourself - worth a read!