Splatting inside an array

This topic contains 5 replies, has 4 voices, and was last updated by Profile photo of Graham Beer Graham Beer 2 weeks, 5 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #53419
    Profile photo of Graham Beer
    Graham Beer
    Participant

    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
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

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

    #53436
    Profile photo of Graham Beer
    Graham Beer
    Participant

    Thanks Dave.

    #53452
    Profile photo of Dan Potter
    Dan Potter
    Participant

    Funky..but heck why not?😀

    #53465
    Profile photo of Jonathan Warnken
    Jonathan Warnken
    Participant

    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
    Profile photo of Graham Beer
    Graham Beer
    Participant

    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 ! ☺

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.