PSCX and StrictMode

Aug 9, 2010 at 7:55 PM

I recently tried to load PSCX (2.0) with "strict" mode 1.0 turned on.  I got a couple of errors in the GetHelp module which were fairly easily remedied.  To what extent can I expect the rest of PSCX (actually running the functions) to work in strict mode?

Aug 9, 2010 at 8:02 PM
Hmm, in theory you shouldn't run into any issues with Set-StrictMode. OTOH I've only been testing with -Version 2.0 which I thought should be a complete superset of 1.0. Can you post the errors here so I can look into fixing them. Thanks.
Aug 11, 2010 at 1:59 AM

The only ones I've seen so far are in GetHelp.psm1, and are both relatively simple to fix (at least I think what I did fixed them).


First, at the top is this:

if ((!$SCRIPT:helpCache) -or $RefreshCache) {
    $SCRIPT:helpCache = @{}

I replaced it with this:

if ((!((get-variable helpCache -scope script -ea Silentlycontinue)) -or $RefreshCache)) {

    $SCRIPT:helpCache = @{}


The other one is a missing back-tick in the block-quote on line 541

It reads:

        PS> $obj = new-object system.xml.xmldocument

But it's in a block-quote (double-quote), so the $ needs to be escaped so it isn't interpreted:

        PS> `$obj = new-object system.xml.xmldocument

the rest of the references to $obj were escaped, so it's obvious this was just a simple mistake.


By the way, I didn't mean this in any way to be critical.  I've already found dozens of mistakes in my scripts in 2 days, and it's not quite the same scope as PSCX.  I really appreciate all of the hard work that the community has put into this tool, and recommend it to everyone I try to get to use PowerShell.




Sep 18, 2010 at 5:22 PM

OK, got this fixed and checked in.  I see no errors during import-module when Set-StrictMode is set to -Version 1.0.

Sep 18, 2010 at 8:30 PM

On Saturday, September 18, 2010, r_keith_hill
<> wrote:
> From: r_keith_hill OK, got this fixed and checked in.  I see no errors during import-module when Set-StrictMode is set to -Version 1.0. Read the full discussion online <>. To add a post to this discussion, reply to this email ([email removed] <[email removed]?subject\x3d[Pscx:222975]>) To start a new discussion for this project, email [email removed] You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings <> on Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at


404 signature missing