Powershell : Invoke variable as a command

When writting powershell script, you often need to run parse your command string and then run it as any regular command. Here is how you do it, using Invoke-Expression.

$portConfig = "$($port):1433"
$cmd = "docker run -d -p $portConfig -v $MOUNTPATH/:$CONTAINER_MOUNTPATH/ $DOCKER_IMAGE_NAME"
Invoke-Expression $cmd


Popular posts from this blog

Solving Sonarqube :- Project was never analyzed. A regular analysis is required before a branch analysis

spark - pyspark reading from excel files