Thursday, November 26, 2009

Changing blog again :(

After some time spend at this blog, I decided to move again. I started project OUT-WEB.NET with my colleagues Dennis Damen and Frank-Peter Schultze.

You can follow my posts at – and thanks for support :)


Saturday, November 14, 2009

Microsoft Office 2010 – designed for App-V?

FINALLY Microsoft adopts application virtualization :)

Click-to-Run is a new software delivery mechanism built by the Office product team. It’s based on core virtualization and streaming technologies from the Microsoft App-V team in Cambridge, MA.

Sunday, November 8, 2009

How to get SCCM site code using Powershell

I spent quite some time scripting SCCM using Powershell – I plan to write some blog post about what I have done, because it is probably most complex scripted solution I ever wrote, but for now, I would like to share one trick with you.

When you script SCCM, you do it through WMI classes. SCCM classes are however not stored in default namespace – therefore whenever you want to access SCCM, you need code that looks similar to below:

Get-WmiObject –ComputerName “ServerX” –NameSpace “Root\SMS\Site_<YouSite> –Class …

Which means that for every script you should accept at least arguments –ComputerName and –SiteCode, which can be pretty annoying to type over and over again. Therefore I use following trick to get sitecode automatically:

# Specify one of SCCM servers and Site code is returned automatically
Function Global:SCCM\Get-Site([string]$ComputerName = $(Throw "Required parameter -ComputerName was not specified in SCCM\Get-Site function")) {
    get-WMIObject -ComputerName $ComputerName -Namespace "root\SMS" -Class "SMS_ProviderLocation" | foreach-object{
        if ($_.ProviderForLocalSite -eq $true){$SiteCode=$_.sitecode}
    if ($SiteCode -eq "") {
        throw ("Sitecode of ConfigMgr Site at " + $ComputerName + " could not be determined.")
    } else {
        Return $SiteCode

Thursday, November 5, 2009

Problem with path longer than 260 characters


Thomas Lee wrote about some issues they are experiencing with Get-ChildItem in this excellent blog post – to make long story short, Powershell is limited by underlying .NET architecture. Thomas mentions mostly performance issues – however I don’t really care about performance as long as it is stable and reliable.

My biggest problem is with path limitation – event though NTFS itself supports paths up to 32.000 characters.

This is error message you get from Explorer when you try to specify longer path:


Very nice blog article about this problem can be found at Coding Horror. Eamon Nerbonne had some nice comments about this problem also.

Why is it so irritating? Almost everyone I mentioned this problem I received answer like “If you run into this problem, it’s your fault, because your are using too long folder\file names”. Shouldn’t 260 characters be enough for everyone?

I don’t think so. First, I don’t see any reason why people shouldn’t use deep structures if they prefer it. I don’t – but that doesn’t mean that everyone had to use same style of work as I do.

That applies to others, but doesn’t describe where is my problem with such limitation. I am mostly focused on enterprise customers – when you implement enterprise solutions, you cannot simply build something, but you must follow some guidelines, like naming conventions. Naming conventions usually apply to all departments – and more people or departments are involved, more complicated they get. If you store your files at network share, their name is also included in that limitation. Let’s consider that our fictional company called “Microsoft” will have development trusted domain. In that case, you can access it using following syntax:


On this network share, we store our installation sources. First of course we categorize them, because we got hundreds of applications:


Ok, so we got installation sources from Office 2007 – because there are multiple editions, we will use iso name as folder name:


And that’s it. So our final path is


If we could it together, we are at 101 characters already. Add longest file (\Proofing.en-us\Proof.en\ and we are at 135 characters.

Ok, that’s not that bad, isn’t it? Well, it is. With very basic categorization (no platform, no departments, no versioning etc…), we already reached 50% of the filesystem limit. And don’t forget that Office is VERY flat installation package compared to others (like XenApp for example).

If we have a look at another example, we can use Application Compatibility Toolkit. Longest file name is 174 characters – already after 50%:

"c:\Program Files (x86)\Microsoft Application Compatibility Toolkit 5\Internet Explorer Compatibility Test Tool\Agent Framework\Agents\Bucketizer\BktOutputReverseTransform.xsl"

If we would like to copy it to our sources (\\\CTX_D_Sources$\Admin\Microsoft Application Compatibility Toolkit 5\Internet Explorer Compatibility Test Tool\Agent Framework\Agents\Bucketizer\BktOutputReverseTransform.xsl), we are already at 214 characters (so almost over the limit).

Thursday, October 29, 2009

Fix Citrix\XenApp WMI issues

Today I run into problem with WMI registrations on few servers. Even though namespace root\Citrix was available, there were no classes.

Below is simple batch script that should be able to solve most WMI-related issues:

:: Remove Repository
Net Stop winmgmt
RmDir /s /q "%WinDir%\System32\WBEM\Repository"
Net Start winmgmt

:: Register core libraries
Regsvr32 /n /I /s "%WinDir%\system32\userenv.dll"
regsvr32 /n /I /s "%WinDir%\system32\scecli.dll"

:: Compile Windows WMI
If Exist "%WinDir%\System32\WBEM" (
    For /f "usebackq tokens=*" %%X IN (`Dir /b "%WinDir%\System32\WBEM\*.dll"`) Do (
        Call %S4_Lib%\SCRIPT_RUNLOG RegSvr32.exe /s "%WinDir%\System32\Wbem\%%X"
    For /f "usebackq tokens=*" %%X IN (`Dir /b "%WinDir%\System32\WBEM\*.mof"`) Do (
        Call %S4_Lib%\SCRIPT_RUNLOG MofComp.exe "%WinDir%\System32\Wbem\%%X"
    For /f "usebackq tokens=*" %%X IN (`Dir /b "%WinDir%\System32\WBEM\*.mfl"`) Do (
        Call %S4_Lib%\SCRIPT_RUNLOG MofComp.exe "%WinDir%\System32\Wbem\%%X"

:: Compile Citrix WMI
If Exist "%ProgramFiles%\Citrix\System32\Citrix\WMI" (
    For /f "usebackq tokens=*" %%X IN (`Dir /b "%ProgramFiles%\Citrix\System32\Citrix\WMI\*.dll"`) Do (
        Call %S4_Lib%\SCRIPT_RUNLOG RegSvr32.exe /s "%ProgramFiles%\Citrix\System32\Citrix\WMI\%%X"
    For /f "usebackq tokens=*" %%X IN (`Dir /b "%ProgramFiles%\Citrix\System32\Citrix\WMI\*.mof"`) Do (
        Call %S4_Lib%\SCRIPT_RUNLOG MofComp.exe "%ProgramFiles%\Citrix\System32\Citrix\WMI\%%X"
    For /f "usebackq tokens=*" %%X IN (`Dir /b "%ProgramFiles%\Citrix\System32\Citrix\WMI\*.fom"`) Do (
        Call %S4_Lib%\SCRIPT_RUNLOG MofComp.exe "%ProgramFiles%\Citrix\System32\Citrix\WMI\%%X"

Wednesday, October 21, 2009

Powershell and argument issue

I was creating very simple function today, however got stuck there for a while…

As you can see below, function is very, very simple:
Function Global:Security\Encrypt-String ([string]$Input){Return [LoginConsultants.Crypto.Password]::EnCrypt($Input)}

It’s using our library to encrypt some text… To my surprise, it didn’t work however. After a little investigation, it turned out that I made rookie mistake – I used $Input, while it is reserved variable :) Very, very stupid mistake of course, I was just surprised that Posh doesn’t complain if you use such parameter.

Anyway, below is small function you can use to test if parameter you want to use is valid:
function Test-ParameterName ([string]$Name) {
           Return [boolean]$($(Test-Path Variable:$Name) -eq 0)

As you can see, it’s extremely primitive, only interesting part is Return [boolean]$($(Test-Path Variable:$Name) -eq 0) – meaning of this function is to revert boolean value. So if Test-Path is $True, function will return $False and if Test-Path is $False, it will return $True. I remember that some years ago I used [boolean]$Foo – 1 in .NET, however it is not supported in Powershell itself (operator – is not defined for [boolean] and [int]).


Tuesday, October 20, 2009

Windows 7 madness

I think that every geek is googling for phrases like “Windows 7 tips and tricks” or “Windows 7 secrets” once he thinks he knows enough about new product.

Windows 7 is new IT phenomenon – you can discuss it, disagree with it, hate it, but that’s about it. Let’s have a look at Google Trends:

Win7 vs Leopard

Blue represents Windows 7, red is main competitor Snow Leopard

Just for fun, below is similar graph comparing Windows 7, Windows XP and Windows Vista.

Windows family

Windows 7 vs Windows XP vs Windows Vista

First, let me give you my presentation from 1.10.2009 about Windows 7.

Second, I was reading through a lot of tips and tricks pages. Today I noticed article called 77 Windows 7 Tips. To make long story short, it’s obvious that number 77 was chose first and then they started to think about the content :( Otherwise I don’t see any explanation for some of those tips.

On the other hand, there are other articles that are discussing new features and tips\tricks and are great. To mention just a few of them, Tim Sneath got great article and I also liked a lot article from TechRadar.

So, I decided to write a series of articles about Windows 7. Currently I got 91 tips, but I started yesterday, so it shouldn’t be problem to get to 100. Some of the tricks are really simple and can be explained on 2-3 lines, some will require a lot more space. I don’t want to simply publish tricks, but also explain how some new technologies works and provide some additional details (for example performance comparison of older Robocopy and new one). I will call these articles Windows 7 Maddness and I will try to group tips together.

Hold on to see more :)