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



Comments

Popular posts from this blog

PySpark - Working with JDBC Sqlite database