0

I’m trying to use variables ($var1,$var2,$randomUser) in $IE.navigate2 commands, but they are being sent to the browser as text and not variables. Any ideas why?

$IE=new-object -com internetexplorer.application
$IE.navigate2('http://10.0.1.30:/?{"serverName":"$var1"}')


$IE=new-object -com internetexplorer.application
$IE.navigate2('http://10.0.1.30/?{"folder":"$var2","server":"$var1","userName":"$randomUser"}')
  • 1
    This is happening because you're using single quotes `'` instead of double quotes `"`. Variables don't expand in single quotes. You can see some alternatives in the linked question. – briantist May 30 '18 at 02:56
  • 1
    That was exactly it, thank you so much. I ended up using the $ExecutionContext.InvokeCommand.ExpandString() method. – JumboShrimp56 May 30 '18 at 21:03

0 Answers0