function Update-PSJobMenu()
{
$jobs = Get-Job
if ($jobs)
{
$receive_Job_items = @{}
$stop_job_items = @{}
$remove_job_items = @{}
$jobs | % {
$receive_job_items[$_.name] = "Get-Job -id $([int] $_.Id) | Receive-Job "
$stop_job_items[$_.name] = "Stop-Job -id $([int] $_.Id) | Stop-Job "
$remove_job_items[$_.name] = "Remove-Job -id $([int] $_.Id) | Receive-Job ; Update-PSJobMenu "
}
}
$items = @{
"Get-Info" = { Get-Job }
"Run as Job" = {
$cmd = [scriptblock]::create($psIse.CurrentFile.Editor.Text)
Invoke-Command -computer localhost -ScriptBlock $cmd -asJob
Update-PSJobMenu
}
"Run selection as Job" = {
$cmd = [scriptblock]::Create($psIse.CurrentFile.Editor.SelectedText)
Invoke-Command -computer localhost -ScriptBlock $cmd -asJob
Update-PSJobMenu
}
"Stop-Job" = $stop_job_items
"Remove-Job" = $remove_job_items
"Receive-Job id" = $receive_job_items
"Refresh Menu" = { Update-PSJobMenu }
}
Add-IseMenu -name PSJobs $items
}
Update-PSJobMenu
Pure Capsaicin at Spiceworks!
vor 8 Monaten
Keine Kommentare:
Kommentar veröffentlichen