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 }
# temporary until the next 2 are working and renamed to a common path
"local background job (demo)" = {
Invoke-Command -computer localhost -ScriptBlock {(Get-ChildItem C:\windows -Recurse).Count} -asJob
Update-PSJobMenu
}
# not working, but would be very cool
"Run as Job" = {
$cmd = $psIse.CurrentFile.Editor.Text
Invoke-Command -computer localhost -ScriptBlock {$cmd } -asJob
Update-PSJobMenu
}
# not working, but would be very cool
# gci C:\windows -rec
"Run selection as Job" = {
$cmd = $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
I tell me would what I have to do to fix this. Many thanks in advance.
Bernd
Keine Kommentare:
Kommentar veröffentlichen