Donnerstag, 28. Januar 2016

Command output is an array of lines

If you need to have it as a single string, -join "`n" the output or pipe the output through Out-String.

Mittwoch, 27. Januar 2016

Problem

You need to replace a string containing double $$ using regular expression by a string containing a double $, e. g. original string $$Reusable_only_switch= replacement string $$Reusable_only_switch=true.

Solution

Put the $$ in a group and make the group part of the replacement string, e. g. regular expression ^(\$\$Reusable_only_switch=)\s*$ replacement expression $1true.

Shortcoming

If the double $ needs to end up at a different position, for the time being I do not see other solution but to take several steps.

Mittwoch, 20. Januar 2016

Create empty zip file

if (
       -not (
            Test-Path `
                -Path $pathAbsoluteArchiveFile `
                -PathType Leaf
       )
 ) {
       Set-Content -Path $pathAbsoluteArchiveFile (
             "PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
 }