Splatting inside an array

This topic contains 5 replies, has 4 voices, and was last updated by  Graham Beer 1 year, 6 months ago.

  • Author
  • #53419

    Graham Beer

    I've enclosed two registry 'splats' inside an array. I really like the way it looks.

    Although it works fine, is it best practice ?

    # New build tattoo Registry Settings in Array     
    $nestedRegKeys = @(
        # Registry Value 1 Splatted
            Path  = $path
            name  = "Task Sequence"
            Value = '$TSeq'
        # Registry Value 2 Splatted
            Path  = $path
            name  = "Build Completed"
            Value = $(Get-Date -Format s)
    # Run in new keys
    $nestedRegKeys | foreach { New-ItemProperty @_ -Force }
  • #53434

    Dave Wyatt

    Seems fine to me. Looks a lot like DSC configuration data.

  • #53436

    Graham Beer

    Thanks Dave.

  • #53452

    Dan Potter

    Funky..but heck why not?😀

  • #53465

    Jonathan Warnken

    I don't see a different between this method and storing the data in an xml file and importing the xml doing the foreach against that data structure.

  • #53474

    Graham Beer

    That's a cool idea Jonathan using XML to parse in registry keys !
    Just cool to experiment with different styles of powershell code. Nice to be different ! ☺

You must be logged in to reply to this topic.