Questions tagged [start-job]

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

205 questions
0
votes
1 answer

Multithread in Powershell

My script does the following: Run a process for packet capture (using windump) for 1 hour, data are saved textFile1 Dump data into database after 1 hour Delete text file Run another windump and save data to textfile2 (Then Repeat process. while…
lulala
  • 637
  • 4
  • 12
  • 21
0
votes
1 answer

I'm trying to execute an existing script on a remote server and capture the output in a local file

I want to run this on multiple servers(nearly 40-50 servers) parallely $Username = "user" $Password = "Password" $servers = get-content "c:\temp\servers.txt" $sb = {c:\temp\PsExec.exe -h \\$server -u $Username -p $password cmd.exe /c "echo . |…
Chand
  • 300
  • 3
  • 13
0
votes
1 answer

Powershell Start-Job jobs not completing

I am having some difficulty launching jobs and I am having trouble finding out what the issue is. Most if not all of the jobs just don't complete. Code below was working correctly when not started as a job. $timer =…
Acerbity
  • 417
  • 1
  • 11
  • 29
0
votes
0 answers

Powershell script - Increase progressbar in start-job scriptblock

I am pretty new to powershell (About 1 week in) and I am trying to create a tool for our helpdesk to import and export printers. The tool is running great except for the form is freezing when the code is being run. To mitigate the freezing, I found…
user3585839
  • 1,459
  • 3
  • 12
  • 18
0
votes
1 answer

Start-Job - check $lastexicode of robocopy inside a Scriptblock

I'm trying to do something simple. I want to create a robocopy job that would launch the copy and check the $lastexitcode. $Source = "c:\SourceFolder" $Destination "\\someserver\Destinationfolder" $ScriptBlock = [scriptblock]::Create("robocopy…
xashcorex
  • 134
  • 1
  • 3
  • 11
0
votes
0 answers

Powershell Passing Argument to background job

I have a script with the following parameters: [Parameter(ParameterSetName="FromPipe", Mandatory=$true, ValueFromPipelineByPropertyName=$true)] [string[]]$ComputerName, [Parameter(ParameterSetName="FromPipe", Mandatory=$true,…
Arluin
  • 594
  • 1
  • 8
  • 21
0
votes
1 answer

How to troubleshoot Start-job scriptblock that runs forever?

I have difficulties troubleshooting scriptblock used in start-job. Basically I wanted to get WMI properties for servers. If I issue the following command from Powershell, it works. c:/>$wmi=Get-WmiObject -class Win32_OperatingSystem -computer…
Barry Chum
  • 829
  • 3
  • 14
  • 23
0
votes
1 answer

Powershell Multi-Threading Start-Job Help Please

I'm trying to use Start-Job to run a command to collect security logs from some servers. I'm parsing a .ini file to get the list of servers, number of days etc. #___Collect Logs from Servers___# $servList = $iniContent["SERVERS"]["svr"] $days =…
user1131196
  • 77
  • 1
  • 3
  • 12
-1
votes
2 answers

Selenium in Powershell does not work correctly in Start-Job

I am trying to execute PowerShell script with Selemiun using Start-Job Start-Job { $Url = 'https://stackoverflow.com/' $Driver = Start-SeChrome Enter-SeUrl -Url $Url -Driver $Driver } The script should open Chrome and follow the…
-1
votes
1 answer

I'm trying to remote into a server, run a script that resides on that server and capture the information displayed & store in a local file

##this code starts job but never exits or get any output### clear $test = 1 $Username = Read-host "Username (Example:Hosting.com\Your Username)" "" $Pass = Read-Host -assecurestring "Password" $Password =…
Chand
  • 300
  • 3
  • 13
1 2 3
13
14