Skip to content

Commit

Permalink
Quality *-job code samples formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmiiz committed Sep 29, 2023
1 parent d6a2272 commit d6d1aeb
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions reference/5.1/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/start-job?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Start-Job
Expand Down Expand Up @@ -180,7 +180,7 @@ This example starts a job that collects a large amount of map data and then save
file.

```powershell
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module MapFunctions} -ScriptBlock {
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module -Name MapFunctions} -ScriptBlock {
Get-Map -Name * | Set-Content -Path D:\Maps.tif } -RunAs32
```

Expand All @@ -196,7 +196,7 @@ This example uses the `$input` automatic variable to process an input object. Us
view the job's output.

```powershell
Start-Job -ScriptBlock { Get-Content $input } -InputObject "C:\Servers.txt"
Start-Job -ScriptBlock { Get-Content -Path $input } -InputObject "C:\Servers.txt"
Receive-Job -Name Job45 -Keep
```

Expand Down
8 changes: 4 additions & 4 deletions reference/5.1/Microsoft.PowerShell.Core/Stop-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/stop-job?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Stop-Job
Expand Down Expand Up @@ -76,7 +76,7 @@ feature.

```powershell
$s = New-PSSession -ComputerName Server01 -Credential Domain01\Admin02
$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog System}}
$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Invoke-Command -Session $s -ScriptBlock { Stop-job -Job $Using:j }
```

Expand Down Expand Up @@ -168,14 +168,14 @@ selected job.
### Example 7: Stop a job on a remote computer

```powershell
$j = Invoke-Command -ComputerName Server01 -ScriptBlock {Get-EventLog System} -AsJob
$j = Invoke-Command -ComputerName Server01 -ScriptBlock {Get-EventLog -LogName System} -AsJob
$j | Stop-Job -PassThru
```

```Output
Id Name State HasMoreData Location Command
-- ---- ---- ----------- -------- -------
5 Job5 Stopped True user01-tablet get-eventlog system
5 Job5 Stopped True user01-tablet Get-EventLog -LogName Sy...
```

This example shows how to use the `Stop-Job` cmdlet to stop a job that is running on a remote
Expand Down
12 changes: 6 additions & 6 deletions reference/5.1/Microsoft.PowerShell.Core/Wait-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/wait-job?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Wait-Job
Expand Down Expand Up @@ -123,8 +123,8 @@ to determine how many of the jobs are finished.
### Example 3: Determine when the first job finishes

```powershell
$s = New-PSSession (Get-Content Machines.txt)
$c = 'Get-EventLog -LogName System | where {$_.EntryType -eq "error" --and $_.Source -eq "LSASRV"} | Out-File Errors.txt'
$s = New-PSSession -ComputerName (Get-Content -Path .\Machines.txt)
$c = 'Get-EventLog -LogName System | Where-Object {$PSItem.EntryType -eq "error" --and $PSItem.Source -eq "LSASRV"} | Out-File -FilePath Errors.txt'
Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$Using:c}
Invoke-Command -Session $s -ScriptBlock {Wait-Job -Any}
```
Expand Down Expand Up @@ -155,7 +155,7 @@ The fourth command uses `Invoke-Command` to run a `Wait-Job` command in the sess
### Example 4: Set a wait time for jobs on remote computers

```powershell
PS> $s = New-PSSession Server01, Server02, Server03
PS> $s = New-PSSession -ComputerName Server01, Server02, Server03
PS> $jobs = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-Date}}
PS> $done = Invoke-Command -Session $s -ScriptBlock {Wait-Job -Timeout 30}
PS>
Expand Down Expand Up @@ -211,7 +211,7 @@ This command uses the job name to identify the job for which to wait.
### Example 8: Wait for jobs on local computer started with Start-Job

```powershell
$j = Start-Job -ScriptBlock {Get-ChildItem *.ps1| where {$_.lastwritetime -gt ((Get-Date) - (New-TimeSpan -Days 7))}}
$j = Start-Job -ScriptBlock {Get-ChildItem -Filter *.ps1| Where-Object {$PSItem.LastWriteTime -gt ((Get-Date) - (New-TimeSpan -Days 7))}}
$j | Wait-Job
```

Expand All @@ -231,7 +231,7 @@ finishes, the command displays the job object, which contains information about
### Example 9: Wait for jobs started on remote computers by using Invoke-Command

```powershell
$s = New-PSSession Server01, Server02, Server03
$s = New-PSSession -ComputerName Server01, Server02, Server03
$j = Invoke-Command -Session $s -ScriptBlock {Get-Process} -AsJob
$j | Wait-Job
```
Expand Down
10 changes: 5 additions & 5 deletions reference/7.2/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/start-job?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Start-Job
Expand Down Expand Up @@ -220,7 +220,7 @@ This example starts a job that collects a large amount of map data and then save
file.

```powershell
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module MapFunctions} -ScriptBlock {
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module -Name MapFunctions} -ScriptBlock {
Get-Map -Name * | Set-Content -Path D:\Maps.tif }
```

Expand All @@ -235,7 +235,7 @@ This example uses the `$input` automatic variable to process an input object. Us
view the job's output.

```powershell
Start-Job -ScriptBlock { Get-Content $input } -InputObject "C:\Servers.txt"
Start-Job -ScriptBlock { Get-Content -Path $input } -InputObject "C:\Servers.txt"
Receive-Job -Name Job45 -Keep
```

Expand Down Expand Up @@ -309,8 +309,8 @@ Major Minor Patch PreReleaseLabel BuildLabel
```

```powershell
$job = Start-Job { $PSVersionTable.PSVersion } -PSVersion 5.1
Receive-Job $job
$job = Start-Job -ScriptBlock { $PSVersionTable.PSVersion } -PSVersion 5.1
Receive-Job -Job $job
```

```Output
Expand Down
8 changes: 4 additions & 4 deletions reference/7.2/Microsoft.PowerShell.Core/Stop-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/stop-job?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Stop-Job
Expand Down Expand Up @@ -76,7 +76,7 @@ feature.

```powershell
$s = New-PSSession -ComputerName Server01 -Credential Domain01\Admin02
$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog System}}
$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Invoke-Command -Session $s -ScriptBlock { Stop-job -Job $Using:j }
```

Expand Down Expand Up @@ -168,14 +168,14 @@ selected job.
### Example 7: Stop a job on a remote computer

```powershell
$j = Invoke-Command -ComputerName Server01 -ScriptBlock {Get-EventLog System} -AsJob
$j = Invoke-Command -ComputerName Server01 -ScriptBlock {Get-EventLog -LogName System} -AsJob
$j | Stop-Job -PassThru
```

```Output
Id Name State HasMoreData Location Command
-- ---- ---- ----------- -------- -------
5 Job5 Stopped True user01-tablet get-eventlog system
5 Job5 Stopped True user01-tablet Get-EventLog -LogName Sy...
```

This example shows how to use the `Stop-Job` cmdlet to stop a job that is running on a remote
Expand Down
12 changes: 6 additions & 6 deletions reference/7.2/Microsoft.PowerShell.Core/Wait-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/wait-job?view=powershell-7.2&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Wait-Job
Expand Down Expand Up @@ -123,8 +123,8 @@ to determine how many of the jobs are finished.
### Example 3: Determine when the first job finishes

```powershell
$s = New-PSSession (Get-Content Machines.txt)
$c = 'Get-EventLog -LogName System | where {$_.EntryType -eq "error" --and $_.Source -eq "LSASRV"} | Out-File Errors.txt'
$s = New-PSSession -ComputerName (Get-Content -Path .\Machines.txt)
$c = 'Get-EventLog -LogName System | Where-Object {$PSItem.EntryType -eq "error" --and $PSItem.Source -eq "LSASRV"} | Out-File -FilePath Errors.txt'
Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$Using:c}
Invoke-Command -Session $s -ScriptBlock {Wait-Job -Any}
```
Expand Down Expand Up @@ -155,7 +155,7 @@ The fourth command uses `Invoke-Command` to run a `Wait-Job` command in the sess
### Example 4: Set a wait time for jobs on remote computers

```powershell
PS> $s = New-PSSession Server01, Server02, Server03
PS> $s = New-PSSession -ComputerName Server01, Server02, Server03
PS> $jobs = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-Date}}
PS> $done = Invoke-Command -Session $s -ScriptBlock {Wait-Job -Timeout 30}
PS>
Expand Down Expand Up @@ -211,7 +211,7 @@ This command uses the job name to identify the job for which to wait.
### Example 8: Wait for jobs on local computer started with Start-Job

```powershell
$j = Start-Job -ScriptBlock {Get-ChildItem *.ps1| where {$_.lastwritetime -gt ((Get-Date) - (New-TimeSpan -Days 7))}}
$j = Start-Job -ScriptBlock {Get-ChildItem -Filter *.ps1| Where-Object {$PSItem.LastWriteTime -gt ((Get-Date) - (New-TimeSpan -Days 7))}}
$j | Wait-Job
```

Expand All @@ -231,7 +231,7 @@ finishes, the command displays the job object, which contains information about
### Example 9: Wait for jobs started on remote computers by using Invoke-Command

```powershell
$s = New-PSSession Server01, Server02, Server03
$s = New-PSSession -ComputerName Server01, Server02, Server03
$j = Invoke-Command -Session $s -ScriptBlock {Get-Process} -AsJob
$j | Wait-Job
```
Expand Down
8 changes: 4 additions & 4 deletions reference/7.3/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ This example starts a job that collects a large amount of map data and then save
file.

```powershell
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module MapFunctions} -ScriptBlock {
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module -Name MapFunctions} -ScriptBlock {
Get-Map -Name * | Set-Content -Path D:\Maps.tif }
```

Expand All @@ -235,7 +235,7 @@ This example uses the `$input` automatic variable to process an input object. Us
view the job's output.

```powershell
Start-Job -ScriptBlock { Get-Content $input } -InputObject "C:\Servers.txt"
Start-Job -ScriptBlock { Get-Content -Path $input } -InputObject "C:\Servers.txt"
Receive-Job -Name Job45 -Keep
```

Expand Down Expand Up @@ -309,8 +309,8 @@ Major Minor Patch PreReleaseLabel BuildLabel
```

```powershell
$job = Start-Job { $PSVersionTable.PSVersion } -PSVersion 5.1
Receive-Job $job
$job = Start-Job -ScriptBlock { $PSVersionTable.PSVersion } -PSVersion 5.1
Receive-Job -Job $job
```

```Output
Expand Down
8 changes: 4 additions & 4 deletions reference/7.3/Microsoft.PowerShell.Core/Stop-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/stop-job?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Stop-Job
Expand Down Expand Up @@ -76,7 +76,7 @@ feature.

```powershell
$s = New-PSSession -ComputerName Server01 -Credential Domain01\Admin02
$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog System}}
$j = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-EventLog -LogName System}}
Invoke-Command -Session $s -ScriptBlock { Stop-job -Job $Using:j }
```

Expand Down Expand Up @@ -168,14 +168,14 @@ selected job.
### Example 7: Stop a job on a remote computer

```powershell
$j = Invoke-Command -ComputerName Server01 -ScriptBlock {Get-EventLog System} -AsJob
$j = Invoke-Command -ComputerName Server01 -ScriptBlock {Get-EventLog -LogName System} -AsJob
$j | Stop-Job -PassThru
```

```Output
Id Name State HasMoreData Location Command
-- ---- ---- ----------- -------- -------
5 Job5 Stopped True user01-tablet get-eventlog system
5 Job5 Stopped True user01-tablet Get-EventLog -LogName Sy...
```

This example shows how to use the `Stop-Job` cmdlet to stop a job that is running on a remote
Expand Down
12 changes: 6 additions & 6 deletions reference/7.3/Microsoft.PowerShell.Core/Wait-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/wait-job?view=powershell-7.3&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Wait-Job
Expand Down Expand Up @@ -123,8 +123,8 @@ to determine how many of the jobs are finished.
### Example 3: Determine when the first job finishes

```powershell
$s = New-PSSession (Get-Content Machines.txt)
$c = 'Get-EventLog -LogName System | where {$_.EntryType -eq "error" --and $_.Source -eq "LSASRV"} | Out-File Errors.txt'
$s = New-PSSession -ComputerName (Get-Content -Path .\Machines.txt)
$c = 'Get-EventLog -LogName System | Where-Object {$PSItem.EntryType -eq "error" --and $PSItem.Source -eq "LSASRV"} | Out-File -FilePath Errors.txt'
Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {$Using:c}
Invoke-Command -Session $s -ScriptBlock {Wait-Job -Any}
```
Expand Down Expand Up @@ -155,7 +155,7 @@ The fourth command uses `Invoke-Command` to run a `Wait-Job` command in the sess
### Example 4: Set a wait time for jobs on remote computers

```powershell
PS> $s = New-PSSession Server01, Server02, Server03
PS> $s = New-PSSession -ComputerName Server01, Server02, Server03
PS> $jobs = Invoke-Command -Session $s -ScriptBlock {Start-Job -ScriptBlock {Get-Date}}
PS> $done = Invoke-Command -Session $s -ScriptBlock {Wait-Job -Timeout 30}
PS>
Expand Down Expand Up @@ -211,7 +211,7 @@ This command uses the job name to identify the job for which to wait.
### Example 8: Wait for jobs on local computer started with Start-Job

```powershell
$j = Start-Job -ScriptBlock {Get-ChildItem *.ps1| where {$_.lastwritetime -gt ((Get-Date) - (New-TimeSpan -Days 7))}}
$j = Start-Job -ScriptBlock {Get-ChildItem -Filter *.ps1| Where-Object {$PSItem.LastWriteTime -gt ((Get-Date) - (New-TimeSpan -Days 7))}}
$j | Wait-Job
```

Expand All @@ -231,7 +231,7 @@ finishes, the command displays the job object, which contains information about
### Example 9: Wait for jobs started on remote computers by using Invoke-Command

```powershell
$s = New-PSSession Server01, Server02, Server03
$s = New-PSSession -ComputerName Server01, Server02, Server03
$j = Invoke-Command -Session $s -ScriptBlock {Get-Process} -AsJob
$j | Wait-Job
```
Expand Down
10 changes: 5 additions & 5 deletions reference/7.4/Microsoft.PowerShell.Core/Start-Job.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: System.Management.Automation.dll-Help.xml
Locale: en-US
Module Name: Microsoft.PowerShell.Core
ms.date: 12/12/2022
ms.date: 09/29/2023
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/start-job?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: Start-Job
Expand Down Expand Up @@ -220,7 +220,7 @@ This example starts a job that collects a large amount of map data and then save
file.

```powershell
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module MapFunctions} -ScriptBlock {
Start-Job -Name GetMappingFiles -InitializationScript {Import-Module -Name MapFunctions} -ScriptBlock {
Get-Map -Name * | Set-Content -Path D:\Maps.tif }
```

Expand All @@ -235,7 +235,7 @@ This example uses the `$input` automatic variable to process an input object. Us
view the job's output.

```powershell
Start-Job -ScriptBlock { Get-Content $input } -InputObject "C:\Servers.txt"
Start-Job -ScriptBlock { Get-Content -Path $input } -InputObject "C:\Servers.txt"
Receive-Job -Name Job45 -Keep
```

Expand Down Expand Up @@ -309,8 +309,8 @@ Major Minor Patch PreReleaseLabel BuildLabel
```

```powershell
$job = Start-Job { $PSVersionTable.PSVersion } -PSVersion 5.1
Receive-Job $job
$job = Start-Job -ScriptBlock { $PSVersionTable.PSVersion } -PSVersion 5.1
Receive-Job -Job $job
```

```Output
Expand Down
Loading

0 comments on commit d6d1aeb

Please sign in to comment.