Using -f operator on a string that contains curly braces Using -f operator on a string that contains curly braces powershell powershell

Using -f operator on a string that contains curly braces


Adding another set of curly braces seems to work:

$blankDefinition = @"define host{{        use             windows-server  ; Inherit default values from a template        host_name       {0}       ; The name we're giving to this host        alias           {0}       ; A longer name associated with the host        address         {1}     ; IP address of the host        }}"@$blankDefinition -f 'foo', 'bar', 'foo'

Output:

define host{        use             windows-server  ; Inherit default values from a template        host_name       foo       ; The name we're giving to this host        alias           foo       ; A longer name associated with the host        address         bar     ; IP address of the host        }