Questions tagged [start-job]

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

205 questions
1
vote
2 answers

Powershell pass arguments to robocopy nested in a Start-Job

After a massive amount of headaches, I was able to get this almost functioning. Problem: In the error/output Robocopy appears to be treating $args[4] (ref: $sourcePath) as everysingle IP in the range instead of just one object. I'm assuming the…
1
vote
0 answers

Run functions in parallel - use same variable environment as calling script

We want to execute two PowerShell functions in parallel. We found that Start-Job is looking good; however, we don't know all the parameters the function needs, and therefore we cannot pass them all via the -ArgumentList parameter. How to call…
D.R.
  • 20,268
  • 21
  • 102
  • 205
1
vote
1 answer

Get-WmiObject with credential fails when within Start-Job scriptblock

I am successfully retrieving some information from Windows 2000 machines using the Get-WmiObjet cmdlet. These machines are not part of our domain so I am using the -Credential parameter to pass local administrator credentials. I am now trying to run…
Lucas
  • 23
  • 2
  • 5
1
vote
2 answers

PowerShell remote session and Start-Job issue

I am trying to run following script with job but the code in the block only executes 1st command and exits. Job is displayed completed on my computer $computers = get-adcomputer -filter * | where { ($_.DNSHostName -match 'server')} foreach…
opti2k4
  • 113
  • 1
  • 13
1
vote
1 answer

How to handle errors for the commands to run in Start-Job?

I am writing an automation script. I had a function which takes either a command or an executable. I had to wait until the command or executable has completed running and return if failed or passed. I also want to write the output to file. I am…
srikanth peetha
  • 229
  • 1
  • 3
  • 17
1
vote
1 answer

Powershell Start-Job not behaving correctly

I have several PHP scripts, which execute a Powershell Script to obtain performance counters of my server infrastructure. As I have multiple scripts, I wanted to execute them all at the same time, from just one location. I have created the following…
DARKOCEAN
  • 109
  • 3
  • 14
1
vote
1 answer

Task Scheduling and Powershell's Start-Job

Currently, I try to run a PowerShell-Script, which starts a few instances with Start-Job -name $jobname -Scriptblock { ... Code ...}; This PowerShell-Script should be executed every 15 minutes in the WIndows Task Schedule. I run this process with…
SUT
  • 323
  • 1
  • 3
  • 14
1
vote
1 answer

powershell run script in parallel

i'm using windows server 2003, now i have a script to restart one specific service, can someone guide me how to run this script in parallel? i already use start-job, but seems it only run in backround but still sequential, below is my script: file…
1
vote
2 answers

Job does not create VM

I want to create VM with a job. cls if (-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) { Add-PSSnapin VMware.VimAutomation.Core | Out-Null } #import VM settings $VMs = Import-CSV…
vencrena
  • 65
  • 1
  • 10
1
vote
1 answer

Powershell job unexpectedly returning 'System.Management.Automation.PSObject' object instead of System.Object

I run a maintenance Powershell script which remotely checks Windows server event logs for various entries and then takes appropriate corrective/alerting actions. The script runs every 5 minutes, but will occasionally run too long due to Get-WinEvent…
Graham
  • 21
  • 6
1
vote
1 answer

Powershell - updating textbox from start-job

I've been working on moving over a WPF program I wrote in C# over to PowerShell, and I'm having a little issue with appending text in my RichTextBox from Start-Job It looks like I can call the Set-RichTextBox where ever, except for inside the…
Rickybobby
  • 245
  • 1
  • 13
1
vote
1 answer

How do I get Start-Job to accept script parameters?

I have a PowerShell script that does multiple things, and takes in a delay parameter (time in seconds). I want to kick off a background job that plays a sound after a time defined by the delay parameter. So the user enters something…
Freakishly
  • 1,533
  • 5
  • 32
  • 61
1
vote
1 answer

Start-Job does not recognize module loaded

My question involves the specific module for PowerCLI, but I'm hoping it involves a more generic issue to PS Jobs. I'm loading a module needed by commands in the job scriptblock but those commands are not recognized, as though the module is not…
Tony A
  • 21
  • 2
1
vote
1 answer

Powershell Quoted variables parameters in a job

$buildDef = "Service.xxxx" $buildDefFull="MyProject/$buildDef" Start-Job -Name 'Service1' -ScriptBlock { tfsbuild start /collection:"http://yyyy:8080/tfs/DefaultCollection" /builddefinition:"$buildDefFull" } i get this error: Option…
user1161137
  • 1,067
  • 1
  • 11
  • 31
1
vote
2 answers

Powershell Job Memory Consumption Issue

I've been struggling with this for a week now and have exhausted all the methods and options I have found online. I am hoping someone here will be able to help me out with this. I am using powershell to start 8 jobs, each job running FFmpeg to…
Matt Wall
  • 475
  • 2
  • 7
  • 15