Passing arguments to Start-Job scriptblock?

后端 未结 1 1060
春和景丽
春和景丽 2020-12-18 08:03

I\'d like to setup a cmdlet to start and stop mysql, and I\'m trying to do so with Start-Job. the I\'ve got the following in my Powershell profile:

$mysqlpat         


        
相关标签:
1条回答
  • 2020-12-18 08:20

    you have to use the -argumentlist parameter see get-help start-job :

     start-job  -ScriptBlock { & $args[0] } -ArgumentList @($mysqlpath )
    

    note that in V3 you just have to use the prefix using: before your varname ex:

      Start-Job -ScriptBlock { & "$using:mysqlpath\mysqld.exe" }
    
    0 讨论(0)
提交回复
热议问题