Use the -ArgumentList
parameter on Start-Job
e.g.:
Start-Job -Scriptblock {param($p) "`$p is $p"} -Arg 'Server1'
In your case:
$pingblock = {param($servername) pathping $servername | Out-File C:\...\ServerPing.txt}
Start-Job $pingblock -Arg Server1
More Related Contents:
- Dynamically create variables in PowerShell
- How to get variable name?
- Creating or referencing variables dynamically in Sass
- What’s the difference between placing “mut” before a variable name and after the “:”?
- Error if don’t check if {{object.field}} exists
- Using a Variable (PowerShell) inside of a command
- When should an Excel VBA variable be killed or set to Nothing?
- Why are variables “i” and “j” used for counters?
- How do I pass variables with the Invoke-Command cmdlet?
- Which variable size to use (db, dw, dd) with x86 assembly?
- HiveQL: Using query results as variables
- Why won’t Variable update?
- setq and defvar in Lisp
- What is the difference between a member variable and a local variable?
- Is it possible to create a multi-line string variable in a Makefile
- Calling dynamic variable in PowerShell
- Determine variable names dynamically according to a string in Fortran
- Why there are two ways of declaring variables in Go, what’s the difference and which to use?
- Comparing IEEE floats and doubles for equality
- Why are variables “i” and “j” used for counters?
- Windows Batch files: what is variable expansion, and what does EnableDelayedExpansion mean?
- What is the difference between a constant and a static variable and which should I choose?
- What is the order of local variables on the stack?
- What is “_,” (underscore comma) in a Go declaration?
- Expanding variables in file contents
- Declaring global variable with php.ini
- Why does Go allow compilation of unused function parameters?
- Create a variable in swift with dynamic name
- Finding out reason of Pyomo model infeasibility
- When should I quote CMake variable references?