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 http://www.out-web.net – and thanks for support :)

Martin

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.

http://blogs.technet.com/office2010/archive/2009/11/06/click-to-run-delivering-office-in-the-21st-century.aspx

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:

image

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:

\\CZPRGHOS1DV15.development.microsoft.com\CTX_D_Sources$

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

\Office

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

\EN_Office_Ultimate_2007_DVD_X12-22244

And that’s it. So our final path is

\\CZPRGHOS1DV15.development.microsoft.com\CTX_D_Sources$\Office\EN_Office_Ultimate_2007_DVD_X12-22244

If we could it together, we are at 101 characters already. Add longest file (\Proofing.en-us\Proof.en\Proof.cab) 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 (\\CZPRGHOS1DV15.development.microsoft.com\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]).

Martin

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 :)

Friday, September 25, 2009

Sorting hashtable in Powershell

I am using hashtables (or dictionaries) more and more in Powershell – once I figured out that syntax $Hashtable.Key works, it turned out to be extremely useful as something similar to custom class.

However I run into an issue (maybe bug?) with sorting hashtables:

PS C:\> $X.Martin = "Zugec"
PS C:\> $X.Kamila = "Vlasakova"
PS C:\> $X.Filip = "Puntik"
PS C:\> $X.Tereza = "Liska"
PS C:\> $X | Sort Name

Name                           Value
----                           -----
Filip                          Puntik
Kamila                       Vlasakova
Tereza                      Liska
Martin                       Zugec

As you can see, output is not sorted. After a while I tried to use raw method that is used in .NET:

PS C:\> $X.psbase.GetEnumerator() | Sort Name

Name                           Value
----                           -----
Filip                          Puntik
Kamila                       Vlasakova
Martin                       Zugec
Tereza                      Liska

As you can see, everything is sorted out correctly in this case. Another scenario where you could use GetEnumerator is if you want to handle name (key) and value:

PS C:\> $X.psbase.GetEnumerator() | Where {$_.Name -eq "Martin"}

Name                           Value
----                           -----
Martin                         Zugec

Without using enumerator, you got access only to values.

Monday, September 7, 2009

How to display all performance counters in console

Just run into this today – I am writing some scripts for Citrix License server and wanted to see which performance counters are available…

Turned out to be pretty simple – just use “TypePerf” command with –q:

   1: C:\Users\Martin>typeperf -q | more



   2: \TBS counters\CurrentResources



   3: \TBS counters\CurrentContexts



   4: \WSMan Quota Statistics(*)\Active Users



   5: \WSMan Quota Statistics(*)\Active Operations



   6: \WSMan Quota Statistics(*)\Active Shells



   7: ...


Friday, August 28, 2009

Get or set file\directory attributes using Powershell

This is just “reminder post” for me if I will need to use it in future…

I wanted to create hidden folder using Powershell – in fact, it’s not very hard:

$(MkDir “Martin Zugec”).Attributes = ‘Hidden’

.Attributes is FileAttributes enumeration, so you use same syntax when you want to create files. Below are available values:

Archive Applications use this attribute to mark file\folder for backup or removal
Compressed Is compressed
Device N/A – in future maybe ;) Looks promising :)
Directory “File is directory” :)
Encrypted Encrypted
Hidden Hidden
Normal If no other attributes are applied
NotContentIndexed Skip for indexing
Offline File\Folder is offline
ReadOnly File\Folder is read-only
ReparsePoint Contains reparse point. Reparse point is user data associated with this entry – one example where reparse points are used is when you mount folder into another.
SparseFile Sparse files are usually large files whose data are mostly zeros. To be honest, I never saw sparse file as far as I know – even fake huge files (FSUtil File CreateNew) are not sparse files.
System System file
Temporary If file is marked as temporary, file system will try to keep all the data in memory for quicker access instead of flushing data back to harddisk. Of course temporary file should be deleted as soon as possible if not needed ;)

If you want to change attribute of existing folder\file, it’s also very easy:

$(Get-Item “Martin Zugec”).Attributes = ‘Hidden’

Wednesday, August 26, 2009

How to return multiple values from Powershell function

I used this trick few times when I had function that had to return more values…

As I wrote here, you can access dictionary object using syntax $Dictionary.Key… If your function returns dictionary, then you can use it to your advantage :)

   1: Function Get-MultiValue () { 



   2:  [hashtable]$Return = @{} 



   3:  



   4:  $Return.Success = $True 



   5:  $Return.PercentComplete = 100 



   6:  $Return.ReturnTime = $(Get-Date) 



   7:  $Return.Username = "Martin Zugec" 



   8:  



   9:  Return $Return 



  10: }




Usage is pretty obvious:





   1: $Var = Get-MultiValue 



   2:  



   3: If ($Var.Success) { 



   4:     $Var.UserName 



   5:     $Var.ReturnTime 



   6: }




Easy and useful sometimes…

Monday, August 24, 2009

New-Enum for Powershell v2

Recently I wrote about new-enum function that should work both in Posh v1 and v2… Well, it doesn’t, because v1 will throw an error on @Args.

Below is updated version that should work in both powershells:

# Supports creation of custom Enums during runtime. 
# Because CoreFunctions and CustomFunctions requires already some enumerations (specifically LogType), it must be initialized in main script.
function Global:S4M\New-Enum ([string] $name, [switch]$FixMode, [array]$Members = @()) {

$Members += $Args

$appdomain = [System.Threading.Thread]::GetDomain()
$assembly = new-object System.Reflection.AssemblyName
$assembly.Name = "EmittedEnum"
$assemblyBuilder = $appdomain.DefineDynamicAssembly($assembly,
[System.Reflection.Emit.AssemblyBuilderAccess]::Save -bor [System.Reflection.Emit.AssemblyBuilderAccess]::Run);
$moduleBuilder = $assemblyBuilder.DefineDynamicModule("DynamicModule", "DynamicModule.mod");
$enumBuilder = $moduleBuilder.DefineEnum($name, [System.Reflection.TypeAttributes]::Public, [System.Int32]);

for($i = 0; $i -lt $Members.Length; $i++) {
If (([string]($Members[$i])).Contains("=")) {
[string]$EnumName = [string](($Members[$i].Split("="))[0])
$Null = $enumBuilder.DefineLiteral($EnumName, [int]($Members[$i].Split("="))[1]);
} Else {
$Null = $enumBuilder.DefineLiteral($Members[$i], $i);
}
}

$enumBuilder.CreateType() > $Null;

#Used to fix issue with Powershell v2
If ($Host.Version.Major -eq 1 -or $FixMode) {
$enumBuilder.CreateType() > $Null;
} Else {
S4M\New-Enum -FixMode -Name $name -Members $Members
$enumBuilder.CreateType() > $Null;
}
}

Friday, August 14, 2009

Bug in PowerShell?

Yesterday I wrote about a way how to use [HashTable] type as single storage for different values… Well, code has to be changed a bit.

Remember that you can access member by using $People.$Foo? But it doesn’t work always, so you should use $People.[string]$Foo instead.

Have a look at following code:

[hashtable]$Collection = @{}
For ($i = 0; $i -lt 10; $i += 1) {$Collection.$i = $i}



Looks fine, doesn’t it? Well, let’s have a look at keys:



PS C:\> $Collection.Keys
9
8
7
6
5
4
3
2
1
0



Still ok. Now try to retrieve value for one of the keys:



PS C:\> $Collection.9
Unexpected token '.9' in expression or statement.
At line:1 char:14
+ $Collection.9 <<<<
+ CategoryInfo : ParserError: (.9:String) [], ParentContainsError
RecordException
+ FullyQualifiedErrorId : UnexpectedToken



Hmmmmmm, error. Let’s have a look at key type:



PS C:\> $Collection.Keys | ForEach {$_.GetType()}

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType
True True Int32 System.ValueType



Have you noticed something? Key should be always string, however in this case, PowerShell doesn’t convert it automatically. Surprisingly, this allows us to have 2 keys with same name – something that should never happen ;)



PS C:\> $Collection."9" = 9
PS C:\> $Collection.Keys
9
9
8



Ok, and here comes solution. Whenever you assign key, specify that it is string:



[hashtable]$Collection = @{}
For ($i = 0; $i -lt 10; $i += 1) {$Collection.[string]$i = $i}

Create System.Array in PowerShell

Some months ago I posted following question:

I am working with MFCOM (COM interface for Citrix) and one of
properties requires Array as input type...

So I tried simple code, [Array]$Schedules = @(), however to my
surprise System.Array is only base object (never realized that
before).

# [array]$Schedules = @()
# $Schedules.GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]
System.Array

If I try to assign this value to COM, it will return error message
stating that input type is not supported.

Obviously, no answers so far, just Gerd Schneider confirmed that this is an issue.

Long story short, it can be done pretty easily:

[Object[]]$Schedules = @()

Of course, you can replace Object with your own type:
[Byte[]]$Bytes = $Source.ToCharArray()

Thursday, August 13, 2009

Easy database for Powershell

I run into situation with my current project where I need to have easy to use translation table. Nothing too complicated – just be able to search for PackageID (we are talking about SCCM) and retrieve location of that package.

Ideal candidate for such tasks is HashTable or dictionary – each entry in hashtable contains Key and Value. Key is unique identifier of that entry and allows you to easily retrieve value.

Initialization of hashtable is very simple:
[HashTable]$People = @{}

Also adding members is easy, either powershell way:
$People += “Martin” = “Zugec”
or using .NET approach:
$People.Add(“Martin”, “Zugec”)

In order to retrieve surname, easiest method is to used built-in functionality of Posh – it makes it very easy for you:
$People.Martin

Returned value is Zugec.

Ok, so far pretty easy. However I realized that for my project I don’t need only surname (package location), but also company. As I said before – hashtable is collection of key\value pairs and key must be unique. Well, value doesn’t need to be single value ;)

$People += @{“Martin Zugec” = @{“Name” = “Martin”; “Surname” = “Zugec”; “Company” = “Login Consultants”}}

In this case, I decided to use hashtable as value of hashtable. I really like the way how complicated stuff can be done easily using Powershell :)

To retrieve company, I can use $People.”Martin Zugec”.Company

Pretty useful sometimes

Tuesday, July 28, 2009

How to convert [String] to [Boolean]

If you always try to specify the type (as I do), maybe you already figured out that you cannot convert string to boolean in Powershell:

[Boolean]$Var = $True
$Var = “False”


Cannot convert value "System.String" to type "System.Boolean", parameters of th

is type only accept booleans or numbers, use $true, $false, 1 or 0 instead.


At line:1 char:5


+ $Var <<<<  = "False"


    + CategoryInfo          : MetadataError: (:) [], ArgumentTransformationMet


   adataException


    + FullyQualifiedErrorId : RuntimeException



Obviously, you should use $False or 0 instead… Sometimes this can be an issue – especially if you read your configuration from XML file, it is returned as string (so it is “0” instead of 0).



There is however workaround for this that allows you to convert string to boolean:



[Boolean]$Var = $False
$Var = [System.Convert]::ToBoolean("True")


Monday, July 27, 2009

Broken New-Enum in Powershell v2

I LOVE using enums in Powershell. If you don’t know about enumerations, you should definitely learn to use them (What the heck is an ENUM?)

I will try to describe it in my words. Enums allows you to define set of allowed arguments. Consider example when I am working with a technology that considers 0 as Write, 1 as Read and 2 as ReadWrite. You will remember that while you work with it, but what if you return back to your own scripts after one year?

Normally you would write following script:

Function Set-Security ([int]$Access = 1) {…}

$Access (as you probably already knows) means which permissions you want to give and by default we set it to Read. Your code will then follow with checking if user provided correct input

Switch ($Access) {
0 {“Write”}
1 {“Read”}
2 {“ReadWrite”}
Default {“Not supported”}
}

Later on you will decide that you want to add other type (Custom) and you need to rewrite all your scripts that are using this syntax. Not talking about fact that you require from users of your scripts to use techie language and use numbers instead of words.

Instead what you can do is to create following:
New-Enum MyAccess Write Read ReadWrite (function New-Enum was taken from Powershell blog)

Now your function can be simplified:
Function Set-Security ([MyAccess]$Access) {}

You can call your function using following syntax now:
Set-Security –Access 0
Set-Security –Access “Write”
Set-Security –Access [MyAccess]::Write

If you want to extend your enumeration, you simply add new enumeration and all your functions will support it out of the box.

Using enumerations is especially useful in case you create complex scripts – for example if you export some objects to XML and import it later on. You simply specify [string]$X = [MyAccess]$Var

In your XML file, instead of non-sense numbers you will get nice string values. Import afterwards is done same way: [MyAccess]$Var = $X. I got very good experiences with this approach especially when using COM based environments like MFCOM.

Ok, so are you into enumerations? They are perfect – however they doesn’t work in Powershell v2 :( New-Enum function works correctly and doesn’t return any error, however enumerations are not created. If you run SAME New-Enum twice, then everything works as expected.

I got my slightly modified version of New-Enum that works on Posh V2 also:

function Global:S4M\New-Enum ([string] $name, [switch]$FixMode) { 

$appdomain = [System.Threading.Thread]::GetDomain()
$assembly = new-object System.Reflection.AssemblyName
$assembly.Name = "EmittedEnum"
$assemblyBuilder = $appdomain.DefineDynamicAssembly($assembly,
[System.Reflection.Emit.AssemblyBuilderAccess]::Save -bor [System.Reflection.Emit.AssemblyBuilderAccess]::Run);
$moduleBuilder = $assemblyBuilder.DefineDynamicModule("DynamicModule", "DynamicModule.mod");
$enumBuilder = $moduleBuilder.DefineEnum($name, [System.Reflection.TypeAttributes]::Public, [System.Int32]);
for($i = 0; $i -lt $Args.Length; $i++) {
If (([string]($Args[$i])).Contains("=")) {
[string]$EnumName = [string](($Args[$i].Split("="))[0])
$Null = $enumBuilder.DefineLiteral($EnumName, [int]($Args[$i].Split("="))[1]);
} Else {
$Null = $enumBuilder.DefineLiteral($Args[$i], $i);
}
}
#Used to fix issue with Powershell v2
If ($Host.Version.Major -eq 1 -or $FixMode) {
$enumBuilder.CreateType() > $Null;
} Else {
S4M\New-Enum -FixMode -Name $Name @Args
$enumBuilder.CreateType() > $Null;
}
}



This version will automatically detect which version are you running and in case you don’t run Powershell V1, it will automatically re-run New-Enum once more. Interesting is usage of @Args instead of $Args – I will blog about this next time ;)



This function contains 2 changes to original:



1.) You can assign special values to enumerations:




New-Enum MyEnum Test=1 Test2=2 Test3=256




2.) Powershell v2 compatibility is fixed

Sunday, July 26, 2009

What to expect in near future?

I was thinking about blogging in general and this blog in particular in last few days. And I made decision that I want to be more specific.

Those of you that knows me also know that I got tired by technology pretty soon – once I know it, I am looking for something else. There is however always one thing that keeps me interested – automating things ;)

So I decided that I will dedicate this blog to PowerShell – in last months I automated many technologies from XenApp through SCCM\Altiris to App-V. Every single one of them was interesting and I would like to post about using Posh V2 much more in upcoming months.

Also I would like to include all technologies related – from Subversion through different editors and tools to interesting articles.

Sunday, July 12, 2009

Adaptive smooth movie streaming

Wow, this is really nice. Jeffrey Snover posted following on Facebook.

It’s best video streaming I ever saw… Very smooth even behind proxy and try to click in the middle of video – it will almost instantly continue :)

http://www.iis.net/media/experiencesmoothstreaming

Really, really nice. Ah, and not to forget – Big Bucks Bunny is already really nice movie

Using svn:externals with TortoiseSVN and FSFS repository

 

If you use Subversion and TortoiseSVN client with repository hosted on filesystem, this can be interesting for you.

Many many years ago (4,5?) when I implemented my first repository, I used filesystem (and I still like it, simple and functional with hook scripts). Only drawback was syntax – which varied between command line subversion client and tortoise client.

In general, syntax is protocol://Location. Problem is if you are hosting your repository in UNC path. Then syntax looks really strange: file:///\server\share/repo.

Notice “\” and “/” – sometimes it works, sometimes you have to fight with it.

Recently I worked with project that was using svn:externals (you can link different repositories together, it’s like symlink on filesystem – even better, you can point to same repository, but different revision ;)). Suddenly it rejected to download externals. After a while I realized they changed syntax, you can still use old syntax, however usage of new is required in case of svn:externals (probably bug). New syntax is much easier to handle and I like it a lot.

Compare for yourself :) file:///\server\share/repo compared to file://server/share/repo.

 

Friday, June 19, 2009

Remove all special characters from string

What is easiest way to remove all special characters from string using Powershell?

Of course regex, but here you can see how it works:
[System.Text.RegularExpressions.Regex]::Replace($Text,"[^1-9a-zA-Z_]"," ");

 

For example

PS C:\Users\Martin> [System.Text.RegularExpressions.Regex]::Replace("I got cool
n1ck%/\/\name($7&","[^1-9a-zA-Z_]"," ");
I got cool n1ck     name

 

I am replacing special characters with space, however of course you can use whatever you want – typically “_”

GrooveShark is down 2

+- 1 month ago Grooveshark was down (this site allows you to search&play music online and I like it a lot)… I posted about it – and what is interesting, I was not angry at all, but it made my day because instead of anonymous message like “Under construction” or “Sorry” they had really funny message (see original post).

Today Grooveshark is down again and I am not mad at them, because again I received very funny message :)

image

Reminds me of Google Doogle – that’s the logo at main page…

Good luck with those pickles :)

Sunday, June 14, 2009

Speed up Access Suite Console load times

BTW am I the only one that is using his blog posts as “Post-it”? :)

Anyway, here comes quick tip. If you are using Access Suite Console (management console for Citrix products), maybe you noticed that it is loading extremely slow. I meant EXTREMELY.

Fix is pretty easy in fact – all you need to do is to disable certificate revocation check.

There are two ways how you can change it.

1.) Set following registry:

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\WinTrust\Trust Providers\Software Publishing]

"State"=dword:00023e00

 

2.) Or use Internet Explorer:
Internet Explorer --> Tools --> Internet Options --> Advanced --> Security: Uncheck "Check for publishers certificate revocation"

All credits go to my colleague Carsten Wallner.

Friday, June 12, 2009

Business cloud computing presentation

Hi,

as promised yesterday, you can find my presentation about cloud computing here. Soon I would like to wrote also series of blog posts about cloud computing, you can have a look at ppt meanwhile:

Wednesday, June 10, 2009

See results from Bing, Google and Yahoo on one page

Quite interesting project… You enter any search term you are interested in and three columns will appear.

Each one of them represents one of major search players: Bing, Google and Yahoo. Trick is that you don’t see names :) So you just vote which one was most useful for you and then names appears.

Surprisingly, Bing is doing pretty well – most of the time it returned best results. Surprise, surprise, I want to use this site for a moment and see which one suits me best.

Only shame is that currently you don’t see results :(

Some douche is gaming the system, I've removed the ability to see the results until I sort this out. Meanwhile you can still have fun playing with blind search. Feel free to blame the douche for ruining it for everybody. Meanwhile, I wouldn’t take this a scientific whats-e-ma-jing, it's just a bit of observational fun.

Well, thank you “douche” :(

Our cool technologies ;)

Hey guys,

if you are reading my blog, you maybe noticed that I am sometimes writing about deployment, sometimes about Powershell, sometimes about Windows 7… So maybe you are curious what I do for living :)

I work for consultancy company called Login Consultants and I would like to share with you what we are doing and how do we work. As mentioned, we are consultancy company and we focus mostly on deployment and especially on SBC. Below you can find really quick overview of our technologies.

I am sorry if it feels like advertisement, but trust me – it’s not :) Today I just really felt that what we are doing deserves some propagation and I haven’t spoke about it yet.

Solution4

Solution4 (or S4) is our flagship. Have you ever dreamed of product that could combine software delivery solution (like SCCM\Altiris\Unicenter…) with security or user environment management (like AppSense\PowerFuse…)?

Well, we cannot give you that – but instead of product we can give you framework :) You can ask what is the difference and answer is pretty simple. Have you EVER encountered ideal product? I haven’t. Difference between product and framework is that framework is unleashing YOUR potential and you can build solution that fits into your needs.

Ok, technically it means that complete S4 is build using XML and Powershell. GUI is XML-driven and you can easily extend it or completely change it. You can add brand new functionality if you want to. It’s similar as if we would give you source code – only difference is that framework (scripting framework) is designed to allow normal administrator to make such changes without need to study documentation and APIs for months.

Of course our framework is already preconfigured and supports tons of functionality – from deployment of MSI, through logon scripts, mapping of drives to more custom functionality like automated management of XenApp servers or Terminal Services farm. So you will get working solution out of the box and you can choose – either use it as it is or modify it in any way you want.

Below screenshot was taken from my colleague Henk Hofs, sorry Henk, I didn’t have any other screenshot ;)

image

Another advantage of S4 is that it is designed for integration – you can combine it with any other product you want like SCCM\Altiris\AppSense and just use functionality you want. For example you can use SCCM to deploy applications and then S4 for user environment management or security. I really love it – it’s solution that only depends on your fantasy :) Credits goes to Dennis Damen who is main architect behind S4.

S4Matic

Ok, now it’s turn for my child :) Imagine when you came to company as consultant – usually it’s really painful to get new AD account, email and everything you need… Would you believe that you could get everything setup before you will arrive to your new office? And roll it back once you leave this customer?

Or another (real life) example, would you believe me if I would tell you that I can dynamically rebuild your complete XenApp farm without any downtime needed? Oh, and btw, without any special configuration?

Or that I can dynamically provision servers for your virtual platform (be it XenServer, VMWare or Hyper-V) based on your requirements?

S4Matic is workflow framework used to automate technical processes. Same as S4 applies here – it is FRAMEWORK build on Powershell and XML files, therefore you can change it in any way you want to. Numerous technologies are supported – from XenApp through SCCM to Microsoft Virtual Server. There are numerous advantages – S4M doesn’t require any clients, doesn’t require any infrastructure except one server (that doesn’t need to be delegated), can be installed within minutes and of course is fully extendable.

One day (soon) I will write article about S4Matic and go into details.

VSI

VSI is project by Henk&Mark. Idea is pretty simple, but really brilliant. How many times have you argued with your colleague\boss whether it makes sense to switch your Terminal Servers\Citrix Servers\VDI to virtual servers? Or to switch to 64 bit? Or to tweak and tune some settings to increase performance? And how many times did you run into conflict – each one of you were sure that he is right?

Well, I don’t like such theoretical discussions – it’s very hard to prove who is right. VSI takes care of this – it will simulate users and calculate performance. So you can easily compare whatever you want and just see which result is best for you.

Interesting project based on VSI is Virtual Reality Check.

Project Virtual Reality Check (VRC) is a joint venture of Log•in Consultants and PQR, who have researched the optimal configuration for the different available hypervisors (hardware virtualization layers). The project arises from the growing demand for a founded advice on how to virtualise Terminal Server and Virtual Desktop (VDI) workloads. Through a number of researches, Log•in Consultants and PQR show you the scaling possibilities for Terminal Server environments as well as Virtual Desktops.

To simplify it – VSI is set of white papers where you can compare performance of different hypervisors with different configuration. Simple, yet effective.

Interested? Let me know in comments section ;)

Tuesday, June 9, 2009

Interesting information about project Natal

Dr. Funkenstein notified me recently about fact that Johnny Chung  Lee is currently working for Microsoft.

For those of you that don’t know that name, Johnny is very famous for his innovative ways how we worked with Wii. Johnny recently graduated with PhD in Human-Computer Interaction.

HCI is really cool if you are interested in new ways how to communicate with your computer, as example what it covers you can watch below video:

Because Natal is gaming project, you can be interested in previous work of Johnny. Have a look at below video – you can see how Wii could work (and it was NOT designed to do so ;)):

Doesn’t it look truly 3D? :) Sure it does. Having a look at Johnny’s blog, you can find following:

If you've been wondering why my project blog has been pretty quiet, I can finally say it is because I have been helping Xbox with Project Natal.

I am starting to be really, really excited about Natal :)

Thursday, June 4, 2009

Project Natal

Well, everyone is excited and I am not surprised – project Natal looks very, VERY interesting :)

For those of you that have no clue what we are talking about, check below video:

As you hopefully noticed, I try to blog here about technologies or tips and tricks that are not very famous or I try to post new information.

Project Natal is no difference for me :) So for those of you that are looking forward to any news, here are my wild guesses :)

1.) notice that project Natal is using RGB camera. Doesn’t that ring a bell? Simply have a look at older Microsoft project called Touchless (demo included). Using RGB differentiation between players (even if they swap places) could be easily done

2.) when you want to monitor what Microsoft plans, it’s important to check companies that are acquired. 3DV (Israel) company was sold to Microsoft recently. And if you have a look at below video, maybe you can notice some similarities with project Natal :)

 

Anyway, important information is that Microsoft hired technology, however not people from 3DV company. Therefore this will be (probably) only subset of Natal – bad news is that it means that technology is interesting, however not ready for release yet :( If you would ask me, I would expect it to be released before Christmas 2010, but it’s really just a wild guess.

Martin

Tuesday, June 2, 2009

Running application from remote Windows 7 – NICE :)

Maybe you noticed I am really interested in XP Mode (or RAIL) – I think it’s really cool and if it will be easy to use (and I can write utility that will help us), I think it will be really really cool…

Today I tried test to run remote application from my laptop on my desktop – and it worked :)

As you can see, I tried Windows Media Player and played movie over RDP – and it worked flawlessly :)

I would like to create utility that will generate RAIL configuration automatically – if you want to try RDP yourself now, you will need follow steps described here and then create modified .RDP file.

Wednesday, May 27, 2009

Keyboard shortcuts for Windows Virtual PC

Friend of mine (hi Henk ;)) was just complaining about the fact that new Virtual PC in Windows 7 doesn’t support keyboard shortcuts anymore (like Alt + Del etc).

I tried it and they works – Microsoft just changed them little bit ;)

To be honest, before running my VM I already had in mind that maybe Microsoft decided to consolidate controls and use same shortcuts in Windows Virtual PC than in Hyper-V… And surprisingly I was right.

So if you want to know keyboard mappings, check out Virtual PC Guy’s blog post – it’s about Hyper-V, however you can use same shortcuts in Windows Virtual PC.

Monday, May 25, 2009

XP Mode for other operating systems

Recently I blogged about internals of XP mode – how it works and I also mentioned that it is NOT only for Windows XP, however also Windows Vista and Windows 7 are supported.

For me personally, this mode is extremely interesting. For example I can try all new applications in my virtual pc first (however use it as RemoteApp from my regular desktop) and when I’ll like them, I can install them to my regular desktop… And if I won’t? Undo changes to VHD ;)

Another reason can be that sometimes you need access to applications that are not available for Windows 7 – I don’t use such legacy applications, but I am scripting in Powershell – and in Windows 7, you have Posh v2 ;) So for testing I can install multiple operating systems and just validate automatically whether my scripts works or not.

So what to do if you want to “publish” applications from Windows 7?

 

1.) Install Windows 7 to virtual PC

2.) Install Integration components

3.) Create new registry key in location HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TsAppAllowList\Applications\NameOfYourApplication

4.) Create registry entry with name Path (string). Value is location of your application.

image

Well, that’s it… I tried it and it works for me. All you need to do know is run following from Run (or cmd.exe\powershell.exe, create shortcut, it’s completely up to you):

vmsal.exe "Windows 7" "||IE" "IE"

As you can see below, I run one Internet Explorer from my own OS (glass) and another from virtualized Windows 7:

image

Running Elevator under normal user

As you maybe remember, some time ago I created small utility (proof of concept) called Elevator that allows you to

  • elevate program seamlessly (without UAC prompt) using context menu
  • create shortcuts that will run programs elevated automatically

Even though it was POC, I received tons of comments and feedback. There is however one question that keeps repeating – Why it doesn’t work under regular user account?

Well, answer is simple and very annoying – Elevator is using scheduled task to run programs elevated. In order to use elevator, you must have permissions to run scheduled task.

As you can see below, there is no Permissions tab in Windows Vista or Windows 7:

image

I have NO idea why they removed this. If you want to help Elevator, please vote for this bug report:

https://connect.microsoft.com/windows7/feedback/ViewFeedback.aspx?FeedbackID=410620

Friday, May 15, 2009

New perfect movie is coming in 2010

Hehe, really funny advertisement from Microsoft :)

Cloud presentation and list of my tools

To attendees of my yesterday presentation, few things I promised…

 

Presentation itself:

 

My Ketarin (to those that didn’t bring USB stick after presentation :)):

 

Hope you had fun yesterday and enjoyed it as much as I did :)

Tuesday, May 12, 2009

“Get” and Powershell

Sometimes you forget some cool features and remember them after months or event years…

This happened to me few times already with powershell.

So I wanted to share a simply trick I run into by accident. GET is optional in Powershell :)

Therefore you don’t need to write Get-WmiObject (in interactive session), you can use WmiObject without verb.

And it applies to your functions also:

PS C:\> function get-dog {Write-Host "Dog returned"}
PS C:\> get-dog
Dog returned
PS C:\> dog
Dog returned
PS C:\>

Monday, May 11, 2009

Cloud computing – compatibility mode :)

Well, as you all know cloud computing should allow you to have webtop – your regular desktop accessible from Internet (the Cloud).

I think idea is nice, however we are not there yet. There are many solutions that tries to achieve that. Some are providing you with “true” desktop experience, like eyeOS, glideOSiCloud or Startforce, some are still working in “compatibility” mode.

You can ask what compatibility mode means – it’s my term for solutions that are synchronization only and one of “nodes” or computers is online desktop. Good examples are tools like Live Mesh, Syncplicity or Dropbox.

Even though webtops like iCloud are getting nicer and more eye-candy, I still think time for webtops hasn’t come yet. It’s nice to try, however I can’t imagine replacing full desktop with webpage. My first concern is performance – even if uploading\downloading files would be only 50% of time on my desktop (which would be major improvement compared to current solutions), I would still feel it’s too slow.

Second related problem is that I want to store my Windows applications stored in cloud – utilities like Total Commander, Notepad++ or Miranda. Even if that would be possible, running and using such applications would be much slower compared to local access.

Therefore I prefer “tweaked” mutant desktops (half-cloud, half-physical).

My cloud is combination of multiple tools:

  • special outlook rules for synchronization of emails (Outlook\Exchange <-> Gmail)
  • LastPass for password management
  • Live Mesh for synchronization of documents, tools, installation sources
  • Ketarin to keep installation sources up to date
  • FlexProfiles to transfer configuration

Currently I want to have a look at Xmarks – utility to automatically synchronize bookmars (as you maybe remember, I complained that Live Mesh cannot handle conflicts properly and this is especially case with Favorites) and play a bit more with FlexProfiles to create seamless application configuration synchronization tool.

Live Mesh problems on Windows 7 – still open :(

Recently I blogged about problems with Live Mesh and Windows 7… I installed Windows 7 RC1 2 weeks ago and I thought it is working finally – however today morning it was broken again :(

I followed my own instructions and uninstalled Live Mesh – and everything works again.

I opened bug at Microsoft Connect – if you experienced same issues, please vote.

Tuesday, May 5, 2009

How XP Mode works

As promised, some details about VMSal – executable that is used to run published applications… I investigated little bit today and here comes first information :)

VMSal is used to run applications that are published from within virtual machines – and functionality called RAIL is used to achieve that – this feature is better known as RemoteApp in Terminal Services.

It is no surprise that Microsoft just re-used already existing functionality – I would be really surprised if they would try to re-invent the wheel (but you never know – just have a look at Live Mesh and SkyDrive, or Live Mesh remote desktop functionality).

Well, it IS based on TS technology :) You can easily discover following registry keys on virtual machines with RAIL installed:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Terminal Server\TsAppAllowList\Applications

Under this key you can find regular settings of TSRemoteApp:

image

Name of that key is identifier of published application. BTW I was really surprised by ShowInTSWA – which is used to show published application in Terminal Services Web Access :) I want to play a bit with it and see if I can publish these applications to TS 2008 :)

When Windows 7 tries to run these remote applications, it is using (already mentioned) executable called VMSal.exe, that can be found in %WinDir%\System32 folder. This executable accepts 3 arguments:

  • Name of virtual machine
  • ID of application
  • Name of application (?) – not sure where is this one used, however it can be any string

ID of application is prefixed by “||”, so for example “||fa7d9”.

If you have a look at picture above, if I would like to run Internet Explorer, I can just call following executable:

“%WinDir%\System32\vmsal.exe” "Virtual Windows XP" "||IE" "IE"

That will automatically run “IE” as specified in virtual machine Virtual Windows XP.

So if you want to easily transfer your settings, simply backup all .lnk files on your Windows 7 and all RAIL registry keys from your virtual machine and that’s it. You can easily automate creation of these applications – I will maybe even build small script that will automatically give you all published applications based on your Windows XP start menu…

Martin

Virtual PC center is missing?

I just wanted to create new VM to test functionality (RAIL) I was talking about in my previous post, when I noticed there is no Virtual PC available in my start menu…

It turned out that you can either manually run %WinDir%\System32\VPWizard.exe or click on Create virtual machine in folder where you store your virtual machines:

image

Quick shortcut – if you want to open folder with your virtual machines, just open Run dialog (WinKey + R) and type VMWindow

BTW just out of curiosity, check out the VMSal.exe in Windows\System32 folder – this executable is used to run virtual applications from within virtual PC (at least description is Windows Virtual PC Application Launcher). If you try to run it, you get following error message:

image

Once my XPM is installed, I will try to give you parameters you can use.

XPM (XP Mode) for Windows Vista & Windows 7

At this moment I am downloading XPM and I want to play a little bit with it… However I was curious why XPM, why not UVM (Universal Virtual Mode :))?

As it turned out, XPM is pretty famous name these days, however technology that we are interested in (publishing of applications from within virtual machine) is not called XPM, it is called RAIL – it means Remote Applications Integrated Locally :)

Most definition of XPM describes it as built-in VirtualPC with free Windows XP license – however that is not complete description. Full definition should be that XP Mode is combination of VirtualPC and RDP. VirtualPC is used as backend (to run hidden virtual PC) and RDP is used to present you with parts of that virtual pc (applications).

RAIL is however not available only for Windows XP, however also for Windows Vista. Check out following links:

I will probably build few virtual machine next week and post some screenshots together with instructions how to enable virtual applications on all these operating systems.

Monday, May 4, 2009

Windows 7 and problems with DWM

Sometimes there are some problems with DWM – for example I use GoToMeeting from Citrix for conference calls, however when you are organizer, your desktop will automatically switch to Aero Basic mode – and once you are finished with confcall, it will switch back to full Aero interface.

Many windows however won’t recover. You can see below screenshot of my desktop:

image

As you can see, only Skype window is restored, rest of windows are all black. Also notice how taskbar looks like – shining start button, however that’s it :)

It’s very easy to recover once you know that DWN is responsible. Just kill DWM.exe process, it will automatically re-launch and all windows are recovered:

image

I already saw this few times and it can be quite handy to know what’s wrong. Also I experienced few times that some applications had black box instead of text (will try to get screenshot next time) – DWM restart helped also ;)

Comparison of AppLocker and SAFER

There is functionality called SAFER (Software Restrictions) in Windows since Windows 2000 (AFAIR)…

If you are familiar with SAFER, you maybe wondered what is difference between software restriction policies and new AppLocker in Windows 7?

Well, main difference is something I wanted long time ago (and even had presentation where I was talking about it) – it’s combination of SAFER and ACT.

In ACT (Application Compatibility Toolkit), you can easily define rules for executables not only based on path\hash (like SAFER), however using all properties of executables – like version, publisher etc…

And that’s major change in AppLocker – now you can not only specify rules based on path and hash, however also using publisher… Which allows you to specify rules using publisher, version of file, product name…

Really nice and much more powerful compared to (restricted) software restrictions :)

Also (don’t exactly remember whether it was possible before), you can specify Allow\Deny rules for AD groups.

Grooveshark is down

Grooveshark just stopped working for me – I am not surprised, after (expected) move by Last.FM (3$ per month) there must be many people searching for alternative…

What I wanted to share with you is page that appeared when you tried to access Grooveshark.com :)

image