December 2006 - Posts

11
Comments

A templating engine using PowerShell expressions by svdoever

[Update Januari 5, 2008: fixed a small bug, content was always saved in encoding ANSI, resulting in the loss of special characters. Changed the line: Set-Content -Path $destination -value $expandedText to Set-Content -Path $destination -value $expandedText...
Filed under: , ,
29
Comments

PowerShell pitfalls: reading text from file using get-content by svdoever

I had a really strange effect in PowerShell that puzzled me for hours! I have the following script: $a = @' One Two '@ $a $p = [regex]"One" $p.Replace($a, "OneReplaced") $b = get-content -path templ.txt $b $q = [regex]"One" $q.Replace($b, "OneReplaced...
Filed under: ,

Comments

PowerShell: calculating a relative path by svdoever

Sometimes you need a simple thing like calculating the relative path of a file given its full path and a base path. For example you have a file c:\a\b\c\d\e.doc and a base path c:\a\b\c, the relative path is now d\e.doc. I use the following PowerShell...
Filed under: ,

Comments

PowerShell and debugging by svdoever

I still did not found a good debugging environment for my PowerShell development. The thing I use most is a command I found in this blog post , part of a great blog post series on PowerShell debugging on the Windows PowerShell blog by the PowerShell team...
Filed under: ,

Comments

PowerShell: "Cleaning" a path name, searching for smarter solution... by svdoever

When you construct a path in powershell with for example Join-Path, you can get things like ".."in your path. For example: Join-Path -Path "c:\program files" -ChildPath "..\Temp" results in: "c:\program files\..\Temp" Instead of: "c:\Temp" I had to solve...
Filed under: ,
5
Comments

PowerShell and using .Net enum types by svdoever

[NOTE: Because this page is the first hit in Google when you search on Powershell + enum, and I landed on this page too often myself, I decided to expand the page with some additional information] Scripting is heaven when you can utilize the complete...
Filed under: ,

Comments

PowerShell and calling WebServices by svdoever

PowerShell does .Net objects. And for a web service you can create a .Net object wrapper using wsdl.exe. Combine those two and you are in business. Great way to write utilities against the extensive set of SharePoint web services. See the following weblog...
Filed under: ,

Comments

PowerShell Community Extensions 1.0 Released @ CodePlex by svdoever

Keith Hill released the PowerShell Community Extensions version 1.0 at http://www.codeplex.com/PowerShellCX . This well documented set of extra CmdLets, aliases and scripts provides you with a lot of goodies that make life in both PowerShell as a Shell...
Filed under: ,

Comments

PowerShell: $null and parameter type by svdoever

One of those things that can take you ages to find out: I create a function where a parameters that can either have a string value or can be $null: function doit { param ( [string]$a = $( throw "Missing: parameter a"), $b = $( throw "Missing: parameter...
Filed under: ,

Comments

PowerShell: strict mode and the variable provider by svdoever

When working in script languages where declaration of variables is not used there is always the problem of typos in names. PowerShell has a possibility to use 'strict" mode: when a variable is used without an initial assignment you get an error: set-psdebug...
Filed under: ,
More Posts Next page »