0

I've notice I'm not manage to format string in-place when calling a function in PowerShell. I need to format it because I want to output a number as hex and not decimal.

This didn't work like so:

WriteLog "Running Step | Retry=$RetryCount | EnabledDevices={0:X}" -f $EnabledDevices

It only works if I store the result in variable and then use it like so:

$Log = "Running Step | Retry=$RetryCount | EnabledDevices={0:X}" -f $EnabledDevices
WriteLog $Log

If there a way to do it in one statement instead of two?

1 Answer 1

2

Just put it in parentheses:

WriteLog ("Running Step | Retry=$RetryCount | EnabledDevices={0:X}" -f $EnabledDevices)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.