Passing arguments to Start-Job scriptblock?

Question:

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:

The variable doesn’t seem to be expanding in the job command however? I must be missing some sort of scoping rule. Could someone please advise? Thanks!

Answer:

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


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

Source:

Passing arguments to Start-Job scriptblock? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply