Skip to content

Instantly share code, notes, and snippets.

@aconn21
aconn21 / PS_StopStuckJobs.ps1
Created February 19, 2017 08:22
PowerShell Stop Stuck Running Jobs
$ThreadTimeout = 300
#Check for jobs we can timeout
$RunningJobs = get-job -State Running
foreach($RunningJob in $RunningJobs)
{
$CurrentTime = get-date
$TimeoutTime = $RunningJob.PSBeginTime
$TimeoutTime = $TimeoutTime.AddSeconds($ThreadTimeout)
@aconn21
aconn21 / PS_MultiThread_Example.ps1
Created February 19, 2017 08:17
PowerShell MultiThreading Examples
#Make new CSV File
$CSVFileName = "\\networkshare\folder\filename.csv"
"CSV,Header,With,Well,Named,Data,Columns" > $CSVFileName
$Timestamp = get-date -format o
#Log file
$LogFileName = "\\networkshare\folder\logfile_$Timestamp.log"
#Function to do stuff with IP address