Here strings and the ExpandString method

You are here:
< Back

A here string is a handy method to specify text, like for example a command.
But when you want to use that command in a loop, and need to change a parameter on the command for each iteration it is handy to know about the ExpandString method.

Note that we have single quotes on the here string, so there will be no variable substitution.

In the foreach loop we populate the $ip variable with the different target IPs. Then we force variable substitution with the ExpandString method.

In case you have your data in an object, you will have to use the normal conventions for variable substitution in a string.

 

Previous Here string and variable substitution

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Table of Contents