A question of scope.

Welcome Forums Web Site Feedback & Assistance A question of scope.

This topic contains 2 replies, has 2 voices, and was last updated by

5 years, 9 months ago.

  • Author
  • #4392

    Points: 0
    Rank: Member

    Not really a question, just a piece of code I found interesting, so I'm putting it here in Discussions if anybody else finds it interesting enough to discuss.

    Jeffrey Snover blogged about Private scope recently:

    Variable Scopes and $PRIVATE:

    and one of the Scripting Games produced some discussion about selecting the protocol for CIM Sessions. They met in my ISE this morning and produced this:

    function Get-_CIMSession
      $_UseDCOM = New-CimSessionOption -Protocol DCOM
      $Private:PSDefaultParameterValues = $PSDefaultParameterValues.Clone()
      $PSDefaultParameterValues['New-CIMSession:SessionOption'] = $_UseDCOM
      $PSDefaultParameterValues['Test-WSMan:ErrorAction'] = 'Stop'
      foreach ($Computer in $ComputerName)
       { Try {Test-WSMan $Computer | out-null
       $_CIM = &{New-CimSession -ComputerName $Computer}}
       Catch { $_CIM = New-CimSession -Computername $Computer }



  • #4448

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Curious: What browser are you using? The editor borked your code a bit, but I edited it in FF and it took it all just fine. Did you use the "Visual" editor tab, and not the "Text" tab when launching the code-inserter-thing?

  • #4451

    Points: 0
    Rank: Member

    I did that in Chrome. Pretty sure I was on the Visual tab when I did it, but I can't swear to it now. I'll test that the next time if I post any more code.
    Thanks for fixing it. 🙂

The topic ‘A question of scope.’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort