A script block groups PowerShell commands inside curly brackets so the code can be stored without executing immediately. It can later be converted to a string or passed as a parameter, while retaining syntax highlighting, IntelliSense, and code analysis. section 11.4.3
Script blocks are useful when automation must preserve executable code while generating or registering scripts:
- Convert the block to text with ToString() when writing a .ps1 file. section 11.4.3
Registering deferred Git configuration
$ScriptBlock = { git config --global init.defaultBranch main git config --global --list } New-ActiveSetup -Name 'Git' -ScriptBlock $ScriptBlock -Version '1.0'


