Skip to content

Commit 84a0680

Browse files
authored
Format PowerShell code blocks and update links.
1 parent e5d4d77 commit 84a0680

14 files changed

+119
-98
lines changed

reference/5.1/PSScheduledJob/New-ScheduledJobOption.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ satisfied.
4545
module that is included in Windows PowerShell.
4646

4747
For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import
48-
the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
48+
the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see
49+
[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
4950

5051
This cmdlet was introduced in Windows PowerShell 3.0.
5152

@@ -98,7 +99,13 @@ returns to set the options for a new scheduled job.
9899

99100
```powershell
100101
$runAsAdmin = New-ScheduledJobOption -RunElevated
101-
Register-ScheduledJob -Name Backup -FilePath D:\Scripts\Backup.ps1 -Trigger $Mondays -ScheduledJobOption $RunAsAdmin
102+
$registerScheduledJobSplat = @{
103+
Name = 'Backup'
104+
FilePath = 'D:\Scripts\Backup.ps1'
105+
Trigger = $Mondays
106+
ScheduledJobOption = $RunAsAdmin
107+
}
108+
Register-ScheduledJob @registerScheduledJobSplat
102109
Get-ScheduledJobOption -Name Backup
103110
```
104111

@@ -138,7 +145,9 @@ order for easy reading.
138145

139146
```powershell
140147
$options = New-ScheduledJobOption -WakeToRun
141-
$options.psobject.Properties | Sort-Object -Property Name | Format-Table -Property Name, Value -AutoSize
148+
$options.psobject.Properties |
149+
Sort-Object -Property Name |
150+
Format-Table -Property Name, Value -AutoSize
142151
```
143152

144153
```Output
@@ -248,7 +257,7 @@ If the computer is not idle for the specified duration before the value of **Idl
248257
the scheduled job does not run until the next scheduled time, if any.
249258

250259
Enter a **TimeSpan** object, such as one generated by the `New-TimeSpan` cmdlet, or enter a value in
251-
\<hours\>:\<minutes\>:\<seconds\> format that is automatically converted to a **TimeSpan** object.
260+
`<hours>:<minutes>:<seconds>` format that is automatically converted to a **TimeSpan** object.
252261

253262
To enable this value, use the **StartIfIdle** parameter. By default, the StartIfNotIdle property of
254263
scheduled jobs is set to `$true` and Windows PowerShell ignores the **IdleDuration** and
@@ -274,7 +283,7 @@ parameter, the job does not run until the next scheduled time, if any. The defau
274283
hour.
275284

276285
Enter a **TimeSpan** object, such as one generated by the `New-TimeSpan` cmdlet, or enter a value in
277-
\<hours\>:\<minutes\>:\<seconds\> format that is automatically converted to a **TimeSpan** object.
286+
`<hours>:<minutes>:<seconds>` format that is automatically converted to a **TimeSpan** object.
278287

279288
To enable this value, use the **StartIfIdle** parameter. By default, the **StartIfNotIdle** property
280289
of scheduled jobs is set to `$true` and Windows PowerShell ignores the **IdleDuration** and
@@ -417,7 +426,8 @@ Accept wildcard characters: False
417426
Starts the scheduled job even if the computer is running on batteries at the scheduled start time.
418427
The default value is `$false`.
419428

420-
The **StartIfOnBattery** parameter sets the value of the StartIfOnBatteries property of scheduled jobs to `$true`.
429+
The **StartIfOnBattery** parameter sets the value of the StartIfOnBatteries property of scheduled
430+
jobs to `$true`.
421431

422432
```yaml
423433
Type: System.Management.Automation.SwitchParameter
@@ -479,7 +489,8 @@ Accept wildcard characters: False
479489

480490
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
481491
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
482-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
492+
-WarningAction, and -WarningVariable. For more information, see
493+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
483494

484495
## INPUTS
485496

reference/5.1/PSScheduledJob/Register-ScheduledJob.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ This example creates a scheduled job on the local computer.
8585
```powershell
8686
Register-ScheduledJob -Name "Archive-Scripts" -ScriptBlock {
8787
Get-ChildItem $HOME\*.ps1 -Recurse |
88-
Copy-Item -Destination "\\Server\Share\PSScriptArchive"
88+
Copy-Item -Destination "\\Server\Share\PSScriptArchive"
8989
}
9090
```
9191

@@ -141,7 +141,13 @@ $O = @{
141141
StartIfNotIdle=$false
142142
MultipleInstancePolicy="Queue"
143143
}
144-
Register-ScheduledJob -Trigger $T -ScheduledJobOption $O -Name UpdateVersion -FilePath "\\Srv01\Scripts\Update-Version.ps1"
144+
$registerScheduledJobSplat = @{
145+
Trigger = $T
146+
ScheduledJobOption = $O
147+
Name = 'UpdateVersion'
148+
FilePath = "\\Srv01\Scripts\Update-Version.ps1"
149+
}
150+
Register-ScheduledJob @registerScheduledJobSplat
145151
```
146152

147153
### Example 4: Create scheduled jobs on remote computers

reference/5.1/PSScheduledJob/Remove-JobTrigger.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ job triggers to delete. By default, `Remove-JobTrigger` deletes all job triggers
4848
that is included in Windows PowerShell.
4949

5050
For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import
51-
the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
51+
the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see
52+
[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
5253

5354
This cmdlet was introduced in Windows PowerShell 3.0.
5455

@@ -73,9 +74,11 @@ This command deletes only the third trigger (ID = 3) from the BackupArchive sche
7374
### Example 3: Delete AtStartup job triggers from all scheduled jobs
7475

7576
```powershell
76-
function Delete-AtStartup
77-
{
78-
Get-ScheduledJob | Get-JobTrigger | Where-Object {$_.Frequency -eq "AtStartup"} | ForEach-Object { Remove-JobTrigger -InputObject $_.JobDefinition -TriggerId $_.Id}
77+
function Delete-AtStartup {
78+
Get-ScheduledJob |
79+
Get-JobTrigger |
80+
Where-Object {$_.Frequency -eq "AtStartup"} |
81+
ForEach-Object { Remove-JobTrigger -InputObject $_.JobDefinition -TriggerId $_.Id}
7982
}
8083
```
8184

@@ -194,7 +197,8 @@ Accept wildcard characters: False
194197

195198
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
196199
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
197-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
200+
-WarningAction, and -WarningVariable. For more information, see
201+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
198202

199203
## INPUTS
200204

reference/5.1/PSScheduledJob/Set-JobTrigger.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ Id Frequency Time DaysOfWeek Enable
106106
```
107107

108108
```powershell
109-
Get-JobTrigger -Name "Inventory" -TriggerId 2 | Set-JobTrigger -Weekly -WeeksInterval 4 -DaysOfWeek Monday -At "12:00 AM"
109+
Get-JobTrigger -Name "Inventory" -TriggerId 2 |
110+
Set-JobTrigger -Weekly -WeeksInterval 4 -DaysOfWeek Monday -At "12:00 AM"
110111
```
111112

112113
```Output
@@ -131,7 +132,12 @@ This command is not required; it is included only to show the effect of the trig
131132
### Example 3: Change the user on a remote job trigger
132133

133134
```powershell
134-
Invoke-Command -ComputerName "Server01" -ScriptBlock {Get-ScheduledJob | Get-JobTrigger | Where-Object {$_.User} | Set-JobTrigger -User "Domain01/Admin02"}
135+
Invoke-Command -ComputerName "Server01" -ScriptBlock {
136+
Get-ScheduledJob |
137+
Get-JobTrigger |
138+
Where-Object {$_.User} |
139+
Set-JobTrigger -User "Domain01/Admin02"
140+
}
135141
```
136142

137143
This command changes the user in all **AtLogon** job triggers of scheduled jobs on the Server01
@@ -181,8 +187,10 @@ JobDefinition : Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition
181187
```
182188

183189
```powershell
184-
Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 | Set-JobTrigger -RepetitionInterval (New-TimeSpan -Minutes 90)
185-
Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 | Format-List -Property *
190+
Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 |
191+
Set-JobTrigger -RepetitionInterval (New-TimeSpan -Minutes 90)
192+
Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 |
193+
Format-List -Property *
186194
```
187195

188196
```Output

reference/5.1/PSScheduledJob/Set-ScheduledJob.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ as a template for other jobs.
6767
that is included in Windows PowerShell.
6868

6969
For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import
70-
the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
70+
the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see
71+
[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
7172

7273
This cmdlet was introduced in Windows PowerShell 3.0.
7374

@@ -88,7 +89,8 @@ Id Name Triggers Command
8889
```
8990

9091
```powershell
91-
Get-ScheduledJob -Name "Inventory" | Set-ScheduledJob -FilePath "C:\Scripts\Get-FullInventory.ps1" -PassThru
92+
Get-ScheduledJob -Name "Inventory" |
93+
Set-ScheduledJob -FilePath "C:\Scripts\Get-FullInventory.ps1" -PassThru
9294
```
9395

9496
```Output
@@ -120,7 +122,8 @@ operator (`|`) sends the job to the `Set-ScheduledJob` cmdlet to change it. The
120122
cmdlet uses the **ClearExecutionHistory** parameter to delete the execution history and saved
121123
results.
122124

123-
For more information about the execution history and saved job results of scheduled jobs, see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
125+
For more information about the execution history and saved job results of scheduled jobs, see
126+
[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md).
124127

125128
### Example 3: Change scheduled jobs on a remote computer
126129

@@ -170,7 +173,8 @@ for this parameter are:
170173
- `Negotiate`
171174
- `NegotiateWithImplicitCredential`
172175

173-
The default value is `Default`. For more information about the values of this parameter, see [AuthenticationMechanism Enumeration](/dotnet/api/system.management.automation.runspaces.authenticationmechanism)
176+
The default value is `Default`. For more information about the values of this parameter, see
177+
[AuthenticationMechanism Enumeration](/dotnet/api/system.management.automation.runspaces.authenticationmechanism)
174178
in the PowerShell SDK.
175179

176180
> [!CAUTION]
@@ -518,7 +522,8 @@ Accept wildcard characters: False
518522
519523
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
520524
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
521-
-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
525+
-WarningAction, and -WarningVariable. For more information, see
526+
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
522527
523528
## INPUTS
524529

reference/5.1/PSWorkflow/About/about_ActivityCommonParameters.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ For example, the following commands add a process object to the service object
7272
in the `$x` variable.
7373

7474
```powershell
75-
workflow Test-Workflow
76-
{
75+
workflow Test-Workflow {
7776
$x = Get-Service
7877
$x = Get-Process -AppendOutput $true
7978
}
@@ -84,8 +83,7 @@ can also use the `+=` assignment operator to add output to the value of a
8483
variable, as shown in the following example.
8584

8685
```powershell
87-
workflow Test-Workflow
88-
{
86+
workflow Test-Workflow {
8987
$x = Get-Service
9088
$x += Get-Process
9189
}
@@ -334,8 +332,7 @@ in a variable. Then, use the variable as the value of the **PSDebug** parameter
334332
of one or more activities, as shown in the following example.
335333

336334
```powershell
337-
workflow Test-Workflow
338-
{
335+
workflow Test-Workflow {
339336
$debugCollection = New-Object -Type `
340337
System.Management.Automation.PSDataCollection[System.Management.Automation.DebugRecord]
341338
inlinescript {\Server01\Share01\Get-AssetData.ps1} -PSDebug $debugCollection -Debug $true
@@ -380,15 +377,13 @@ in a variable. Then, use the variable as the value of the **PSError** parameter
380377
of one or more activities, as shown in the following example.
381378

382379
```powershell
383-
workflow Test-Workflow
384-
{
380+
workflow Test-Workflow {
385381
$typeName = "System.Management.Automation.PSDataCollection"
386382
$typeName += '[System.Management.Automation.ErrorRecord]'
387383
$ec = New-Object $typeName
388384
inlinescript {\Server01\Share01\Get-AssetData.ps1} -PSError $ec
389385
inlinescript {\Server01\Share01\Set-AssetData.ps1} -PSError $ec
390-
if ($ec.Count -gt 2)
391-
{
386+
if ($ec.Count -gt 2) {
392387
# Do Some Work.
393388
}
394389
}
@@ -537,8 +532,7 @@ the workflow. When you run the workflow with input, that input is used by the
537532
activity.
538533

539534
```powershell
540-
workflow Test-Workflow
541-
{
535+
workflow Test-Workflow {
542536
Get-Service -UseDefaultInput $true
543537
}
544538
@@ -600,25 +594,17 @@ parameters to run a `Get-EventLog` activity only on computers it a particular
600594
domain.
601595

602596
```powershell
603-
workflow Test-Workflow
604-
{
597+
workflow Test-Workflow {
605598
$UserDomain = Get-Content -Path '.\UserComputers.txt'
606599
$Log = (Get-EventLog -LogName "Windows PowerShell" `
607600
-PSComputerName $UserDomain)
608601
609-
if ($Log)
610-
{
602+
if ($Log) {
611603
# Do Work Here.
612604
}
613605
}
614606
```
615607

616-
<!--
617-
# KEYWORDS
618-
[about_Activity_Common_Parameters](about_Activity_Common_Parameters.md)
619-
[about_Activity_Parameters](about_Activity_Parameters.md)
620-
[about_ActivityParameters]()about_ActivityParameters.md) -->
621-
622608
## See Also
623609

624610
- [about_Workflows](about_workflows.md)

reference/5.1/PSWorkflow/About/about_Checkpoint-Workflow.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ The Checkpoint-Workflow activity is valid only in a workflow.
2323
### SYNTAX
2424

2525
```
26-
workflow <Verb-Noun>
27-
{
26+
workflow <Verb-Noun> {
2827
Checkpoint-Workflow
2928
}
3029
```
@@ -72,14 +71,12 @@ The following workflow includes a call to the Checkpoint-Workflow activity after
7271
long-running function and a script that share data.
7372

7473
```powershell
75-
workflow Test-Workflow
76-
{
74+
workflow Test-Workflow {
7775
$a = Invoke-LongRunningFunction
7876
inlinescript { \\Server\Share\Get-DataPacks.ps1 $Using:a}
7977
Checkpoint-Workflow
8078
81-
Invoke-LongRunningFunction
82-
{
79+
Invoke-LongRunningFunction {
8380
...
8481
}
8582
}

reference/5.1/PSWorkflow/About/about_Foreach-Parallel.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ each item in the collection.
2626
### SYNTAX
2727

2828
```
29-
foreach -Parallel ($<item> in $<collection>)
30-
{
29+
foreach -Parallel ($<item> in $<collection>) {
3130
[<Activity1>]
3231
[<Activity2>]
3332
...
@@ -59,8 +58,7 @@ the disks that the `Get-Disk` activity gets. The commands in the
5958
parallel. The disks might be processed concurrently and in any order.
6059

6160
```powershell
62-
workflow Test-Workflow
63-
{
61+
workflow Test-Workflow {
6462
$Disks = Get-Disk
6563
6664
# The disks are processed in parallel.
@@ -81,8 +79,7 @@ parallel. The parallel commands and the `foreach -Parallel` loop run
8179
concurrently.
8280

8381
```powershell
84-
workflow Test-Workflow
85-
{
82+
workflow Test-Workflow {
8683
#Run commands in parallel.
8784
parallel
8885
{

reference/5.1/PSWorkflow/About/about_InlineScript.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ in PowerShell but aren't valid in workflows. For example, the `New-Object`
136136
cmdlet with the **ComObject** parameter.
137137

138138
```powershell
139-
workflow Test-Workflow
140-
{
139+
workflow Test-Workflow {
141140
$ie = inlinescript {
142141
$ie = New-Object -ComObject InternetExplorer.Application -Property @{navigate2="www.microsoft.com"}
143142

reference/5.1/PSWorkflow/About/about_Parallel.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ The `parallel` keyword runs workflow activities in parallel. This keyword is val
1818
### SYNTAX
1919

2020
```
21-
workflow <Verb-Noun>
22-
{
23-
parallel
24-
{
21+
workflow <Verb-Noun> {
22+
parallel {
2523
[<Activity>]
2624
[<Activity>]
2725
...
@@ -36,10 +34,8 @@ The commands in a `parallel` script block can run concurrently. The order in whi
3634
For example, the following workflow includes a `parallel` script block that runs activities that get processes and services on the computer. Because the Get-Process and Get-Service commands are independent of each other, they can run concurrently and in any order.
3735

3836
```powershell
39-
workflow Test-Workflow
40-
{
41-
parallel
42-
{
37+
workflow Test-Workflow {
38+
parallel {
4339
Get-Process
4440
Get-Service
4541
}

0 commit comments

Comments
 (0)