I'd like to output the values of whatever parameters have been passed to my script for including in an email.
I've tried this:
foreach ($psbp in $PSBoundParameters)
{
$messageBody += $psbp | out-string + "`r`n"
}
But it didn't work. Can someone give me a hand?
This variable is present if a script or function you create that contains user-populated parameters. In other words, if you've got a script or function using the param () statement with one or more parameters inside and you've passed arguments to these parameters, the $PsBoundParameters variable will always be available.
The supported parameters and their defaults are: This parameter specifies the column separator character that separates columns in the file. The default column separator is ',' (comma). The delimiter parameter is not available for Outputters.Csv () and Outputters.Tsv ().
Unfortunately, the outputter cannot generate a BOM for the encoding, since the parallel processing of the outputter does not know which split is going to be the beginning of the output file. Since the outputter should not generate BOMs for every split, the built-in outputters are not adding BOMs. Encoding. [ASCII]
The delimiter parameter is not available for Outputters.Csv () and Outputters.Tsv (). Note that per default, the built-in outputters are quoting string values. Thus any delimiter inside a value will be protected. If quoting is turned off, then the escaping needs to be turned on to protect the delimiter character inside a value.
$PSBoundParameters is a hash table, use GetEnumerator to unfold its items
foreach($psbp in $PSBoundParameters.GetEnumerator())
{
"Key={0} Value={1}" -f $psbp.Key,$psbp.Value
}
function Get-PSBoundParameters
{
[CmdletBinding()]
Param($param1,$param2,$param3)
foreach($psbp in $PSBoundParameters.GetEnumerator())
{
"Key={0} Value={1}" -f $psbp.Key,$psbp.Value
}
}
PS> Get-PSBoundParameters p1 p2 p3 | ft -a
Key=param1 Value=p1
Key=param2 Value=p2
Key=param3 Value=p3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With