I'm writing some powershell to talk to the AWS API, in a single module. I have written one function, Get-CloudFormation, which returns the status of a CloudFormation. I've written another function, Delete-CloudFormation, which after firing off a…
I am using a .NET component in Powershell which uses Trace.TraceWarning, Trace.TraceInformation etc.
I want to output these traces to the console when I run my Powershell script.
This works when I use the component in the current session. For…
I am having a difficult time understanding the most efficient to process large datasets/arrays in PowerShell. I have arrays that have several million items that I need to process and group. This list is always different in size meaning it could be…
I have (inherited) a PowerShell script that calls other PowerShell scripts by invoking them with a Start-Job cmdlet and the -FilePath parameter. For example, I have a script that does nothing:
Start-Sleep -Seconds 86400
Which I can invoke via a…
I have a few modules in my powershell profile, and their loading sometimes takes a lot of time (10-15s). I would like to load them in a background thread using something like this:
Start-Job -ScriptBlock { Import-Module -Global DockerCompletion…
I am using Invoke-Command, and within the -ScriptBlock I am using Start-Job. I have to use $Using:var within Start-Job but the session is looking for the declared variables in the local session (declared before Invoke-Command). Here's a very brief…
I have Powershell job.
$cmd = {
param($a, $b)
$a++
$b++
}
$a = 1
$b = 2
Start-Job -ScriptBlock $cmd -ArgumentList $a, $b
How to pass $a and $b by a reference so when the job is done they will be updated? Alternatively how to pass variables…
System: Windows Server 2012 R2 | PowerShell v4 | Jenkins v1.607 | 64-Bit Java Version 8u60
For whatever reason, I am able to login to the Windows server that Jenkins is running on, and execute the following code without issues:
Start-Job -Credential…
Background Info:
I have an application that makes several SQL connections to multiple databases which currently takes a very very long time to execute.
Powershell (.NET) will wait for each proceeding "SQL-GET" function to finish before it can fire…
In order to do some work when another job completes without blocking the current session, I want to create a job that waits on another, however when create the second job, it cannot detect the first job.
$Job = Start-Job -ScriptBlock { Start-Sleep…
I've been trying to create responsive GUIs for my personal Powershell scripts. I've come up with a problem that is highly discussed online: Freezing GUI (since Powershell is single threaded).
Similar to this problem, but my case is specific to…
I have a PowerShell script which starts a background job (it does port-forwarding using kubectl):
$forwardjob = Start-Job -ScriptBlock{kubectl port-forward service/db 7125:7125} -Name "Database Port-Forwarder"
This works fine, however every so…
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 =…
When I run the following script from a newly opened PowerShell console, the loop exits so there is clearly a match, but the $matches variable (and thus $matches.PORT) is not populated the first time around. When the script is run again, it is…
If I understand the PowerShell Scopes documentation, it should be possible to assign to $using scope variables from threads started using Start-ThreadJob. The documentation says (emphasis mine):
The Using scope modifier is supported in the…