Questions tagged [start-job]

Start-Job is a Powershell CmdLet to run a Scriptblock as background job

205 questions
3
votes
2 answers

PowerShell - Passing expanded arguments to Start-Job cmdlet

We're trying to create an array with variables and then pass this array as expanded to a script, which shall be run by Start-Job. But actually it fails and we are unable to find the reason. Maybe someone can help!? $arguments= @() $arguments+=…
3
votes
1 answer

Powershell Start-Jobs throttling

I am having trouble with throttling of jobs and "hung" or "failed" jobs. Here is basically what I am trying to do. $allServers = Import-Csv "C:\temp\input.csv" $job = $allServers | % { while (@(Get-Job -State Running).Count -ge 6) { …
Acerbity
  • 417
  • 1
  • 11
  • 29
3
votes
4 answers

Invoke-Command in a background job

I have a powershell 2.0 script which should run a command on several servers and process the output. I want to run the command and the processing for each server in a background job. The comand works without any problems and terminates within half a…
bones
  • 33
  • 1
  • 1
  • 5
3
votes
3 answers

start-job Run command in parallel and output result as they arrive

I am trying to get specific KBXXXXXX existence on a list of servers , but once my script one server it takes time and return result and come back and then move to next one . this script works perfectly fine for me . I want my script to kick off and…
Fenomatik
  • 457
  • 2
  • 8
  • 22
3
votes
2 answers

PowerShell Job Queue

Run a job for each server in a list. I only want 5 jobs running at a time. When a job completes, it should start a new job on the next server on the list. Here's what I have so far, but I can't get it to start a new job after the first 5 jobs have…
Joe Brown
  • 63
  • 2
  • 5
3
votes
1 answer

Start-Job script block-- how to call cmdlets with arguments?

I'm new to the Start-Job cmdlet and am having trouble calling a script block with cmdlets in it that take arguments. Here's what I have so far: Start-Job -ScriptBlock { $ServiceObj = Get-Service -Name $ServiceName -ComputerName $Computer…
larryq
  • 15,713
  • 38
  • 121
  • 190
3
votes
3 answers

Function not recognized in start-job

I created a function "Get-Uptime" in a module sysinfo.psm1 and imported the module. C:/pstools> get-command -Module sysinfo CommandType Name Definition ----------- ---- …
Barry Chum
  • 829
  • 3
  • 14
  • 23
3
votes
1 answer

Call a jenkins job by using a variable for build the name

I try to launch a job from a parametrized trigger and I would compute the name from a given variable. Is it possible to set in field : Build Triggers Projects to build a value like this ${RELEASE}-MAIN-${PROJECT}-LOAD_START ?
user1541032
  • 31
  • 1
  • 2
2
votes
3 answers

Dismiss a Powershell form controlled by a start-job task

I've been tasked with building a powershell script with a GUI which enables users to install network printers. I've succesfully managed to do so, but I cannot meet the requirement that the user be shown a 'please wait' window whilst the printers…
Morten Nørgaard
  • 2,609
  • 2
  • 24
  • 24
2
votes
2 answers

Foreach-Object -Parallel, How to implement a timeout at thread level

Foreach-Object -Parallel is great. But sometimes the script block will hang, which will block the rest of the code. There is a timeOutSeconds parameter on the Foreach-Object, but it's a global one. When the timeout is reached, any remaining object…
2
votes
1 answer

EventNames of PowerShell jobs started with Start-Job

I want to run a script when a PowerShell job has successfully completed. But how do I find out all possible events of the job started with the Start-Job cmdlet? Here is an example: $myjob = Start-Job { Get-ChildItem } $jobEvent =…
bahrep
  • 29,961
  • 12
  • 103
  • 150
2
votes
3 answers

PowerShell, test the performance/efficiency of asynchronous tasks with Start-Job and Start-Process

I'm curious to test out the performance/usefulness of asynchronous tasks in PowerShell with Start-ThreadJob, Start-Job and Start-Process. I have a folder with about 100 zip files and so came up with the following test: New-Item "000" -ItemType…
2
votes
1 answer

PowerShell Script - Run multiple executables in parallel and wait for all launched executables to terminate before proceeding

I have an executable file (.exe) which has to be run multiple times with different arguments in parallel (ideally on different cores) from a PowerShell script, and at the end wait for all launched executables to terminate. To implement that in my…
2
votes
1 answer

Add Write-Progress to Get-Job/Wait-Job

I'm using the below code to display the results of PowerShell Jobs with a timeout of 120 seconds. I would like to enhance this code by incorporating Write-Progress (based on number of jobs completed). I tried using this example as a reference,…
MKANET
  • 573
  • 6
  • 27
  • 51
2
votes
1 answer

Update winforms GUI from Start-Job (Powershell)

I am trying to create a custom Robocopy status GUI in powershell, here is my basic code. $script:Robocopy = Start-Process -FilePath robocopy.exe -ArgumentList $ArgumentList -Verbose -PassThru -NoNewWindow; $RCStatus = Start-Job -Name RCLOOP…
RJ45
  • 55
  • 6
1 2
3
13 14