I'm a PowerShell newbie and I've got stuck on something very simple. I am trying to create a variable that use placeholders ({0}{1}...) using string format (-f). The place holder variables are passed as parameters to the function that builds/formats the string. Unfortunately, the place holders remain blank.
Here's my code:
function SendName(){
BuildReport $MyInvocation.MyCommand, 1, 2
}
Function BuildReport($functionName, $param1, $param2){
$report="You are in {0}. Parameter expected is {1}. Actual parameter is {2}" -f $functionName, $param1, $param2
write-host $report
}
SendName
The output I get is:
You are in System.Object[]. Parameter expected is . Actual parameter is