Very new to Powershell, so I'm not sure I'm doing things the right way at the moment, but I'm struggling pass a variable into an Invoke-Expression string and was hoping someone would be able to help.
$projectLocation = "C:/Users/Admin/Desktop/Projects/repo"
Invoke-Expression 'cmd /c start powershell -Command {
cd $projectLocation;
git pull
}'
I've also tried splitting out the string with ' + $projectLocation + ', but still not having much luck.
The only way I've achieved my goal is by inserting the $projectLocation string manually.
I don't think I'm far off, but any help would be great! Thanks.
powershelldirectly or useStart-Processfrom within powershell?Invoke-Expressionseems wholy unnecessary here. What is the actual goal you're trying to achieve here?Invoke-Expression