diff --git a/reference/5.1/Microsoft.PowerShell.Management/Remove-WmiObject.md b/reference/5.1/Microsoft.PowerShell.Management/Remove-WmiObject.md index a8b8fb2291e4..62736eb252a9 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Remove-WmiObject.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Remove-WmiObject.md @@ -77,7 +77,7 @@ The `Remove-WmiObject` cmdlet deletes an instance of an existing Windows Managem ```powershell notepad -$np = Get-WmiObject -Query "select * from win32_process where name='notepad.exe'" +$np = Get-WmiObject -Query "select * from Win32_Process where name='notepad.exe'" $np | Remove-WmiObject ``` @@ -96,14 +96,14 @@ instances of Notepad.exe. This command deletes the C:\Test folder. ```powershell -$a = Get-WMIObject -Query "Select * From Win32_Directory Where Name ='C:\\Test'" -$a | Remove-WMIObject +$a = Get-WmiObject -Query "Select * From Win32_Directory Where Name ='C:\\Test'" +$a | Remove-WmiObject ``` -The first command uses `Get-WMIObject` to query for the `C:\Test` folder, and then stores the object +The first command uses `Get-WmiObject` to query for the `C:\Test` folder, and then stores the object in the `$a` variable. -The second command pipes the `$a` variable to `Remove-WMIObject`, which deletes the folder. +The second command pipes the `$a` variable to `Remove-WmiObject`, which deletes the folder. ## PARAMETERS diff --git a/reference/5.1/Microsoft.PowerShell.Management/Reset-ComputerMachinePassword.md b/reference/5.1/Microsoft.PowerShell.Management/Reset-ComputerMachinePassword.md index 71d8c5c91709..28b271f61268 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Reset-ComputerMachinePassword.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Reset-ComputerMachinePassword.md @@ -51,14 +51,16 @@ password in the domain. ```powershell $cred = Get-Credential -Invoke-Command -ComputerName "Server01" -ScriptBlock {Reset-ComputerMachinePassword -Credential $using:cred} +Invoke-Command -ComputerName "Server01" -ScriptBlock { + Reset-ComputerMachinePassword -Credential $Using:cred +} ``` This command uses the Invoke-Command cmdlet to run a `Reset-ComputerMachinePassword` command on the Server01 remote computer. -For more information about remote commands in Windows PowerShell, see [about_Remote](../Microsoft.PowerShell.Core/About/about_Remote.md) -and `Invoke-Command`. +For more information about remote commands in Windows PowerShell, see +[about_Remote](../Microsoft.PowerShell.Core/About/about_Remote.md) and `Invoke-Command`. ## PARAMETERS @@ -141,7 +143,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/5.1/Microsoft.PowerShell.Management/Set-WmiInstance.md b/reference/5.1/Microsoft.PowerShell.Management/Set-WmiInstance.md index 15ad82542810..454e5e9d25b8 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Set-WmiInstance.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Set-WmiInstance.md @@ -137,7 +137,7 @@ reflects the new value. ```powershell $setWmiInstanceSplat = @{ - Class = 'win32_environment' + Class = 'Win32_Environment' Arguments = @{ Name="testvar" VariableValue="testvalue" diff --git a/reference/5.1/Microsoft.PowerShell.Management/Show-ControlPanelItem.md b/reference/5.1/Microsoft.PowerShell.Management/Show-ControlPanelItem.md index c52618e11ebc..1adb59087bcb 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Show-ControlPanelItem.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Show-ControlPanelItem.md @@ -80,7 +80,7 @@ This method is an alternative to using a `Show-ControlPanelItem` command. > [!NOTE] > In PowerShell, you can omit the .cpl file extension for control panel files because it's included -> in the value of the `$env:PathExt` environment variable. +> in the value of the `$Env:PATHEXT` environment variable. ## PARAMETERS diff --git a/reference/5.1/Microsoft.PowerShell.Management/Start-Transaction.md b/reference/5.1/Microsoft.PowerShell.Management/Start-Transaction.md index 555834f17185..40014045d58b 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Start-Transaction.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Start-Transaction.md @@ -52,7 +52,7 @@ Windows PowerShell. For more information, see [about_Transactions](../Microsoft. ### Example 1: Start and roll back a transaction ```powershell -Set-Location hkcu:\software +Set-Location HKCU:\software Start-Transaction New-Item "ContosoCompany" -UseTransaction New-ItemProperty "ContosoCompany" -Name "MyKey" -Value 123 -UseTransaction @@ -65,7 +65,7 @@ changes are made to the registry. ### Example 2: Start and complete a transaction ```powershell -Set-Location hkcu:\software +Set-Location HKCU:\software Start-Transaction New-Item "ContosoCompany" -UseTransaction New-ItemProperty "ContosoCompany" -Name "MyKey" -Value 123 -UseTransaction @@ -82,11 +82,11 @@ Set-Location HKCU:\software Start-Transaction New-Item -Path "NoPath" -Name "ContosoCompany" -UseTransaction New-Item -Path . -Name "ContosoCompany" -UseTransaction -Start-Transaction -RollbackPreference never +Start-Transaction -RollbackPreference Never New-Item -Path "NoPath" -Name "ContosoCompany" -UseTransaction New-Item -Path . -Name "ContosoCompany" -UseTransaction -# Start-Transaction (-rollbackpreference error) +# Start-Transaction (-RollbackPreference Error) Start-Transaction New-Item -Path "NoPath" -Name "ContosoCompany" -UseTransaction @@ -95,7 +95,7 @@ New-Item : The registry key at the specified path does not exist. ```Output At line:1 char:9 -+ new-item <<<< -Path NoPath -Name ContosoCompany -UseTransaction ++ New-Item <<<< -Path NoPath -Name ContosoCompany -UseTransaction ``` ```powershell @@ -109,9 +109,9 @@ At line:1 char:9 ``` ```powershell -# Start-Transaction (-rollbackpreference never) +# Start-Transaction (-RollbackPreference Never) -Start-Transaction -RollbackPreference never +Start-Transaction -RollbackPreference Never New-Item -Path "NoPath" -Name "ContosoCompany" -UseTransaction ``` @@ -235,7 +235,7 @@ As a result, the registry is changed. ### Example 6: Run commands that are not part of a transaction ```powershell -Set-Location hkcu:\software +Set-Location HKCU:\software Start-Transaction New-Item "ContosoCompany1" -UseTransaction New-Item "ContosoCompany2" @@ -308,7 +308,7 @@ New-Item HKCU:\Software\ContosoCompany -UseTransaction ```Output New-Item : Cannot use transaction. The transaction has been rolled back or has timed out. At line:1 char:9 -+ new-item <<<< MyCompany -UseTransaction ++ New-Item <<<< MyCompany -UseTransaction ``` This command uses the **Timeout** parameter of `Start-Transaction` to start a transaction that must diff --git a/reference/5.1/Microsoft.PowerShell.Management/Test-Connection.md b/reference/5.1/Microsoft.PowerShell.Management/Test-Connection.md index 2f4d836a5be2..220ec5ac6a19 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Test-Connection.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Test-Connection.md @@ -493,7 +493,7 @@ multiple connections, it returns an array of **Boolean** values. ## NOTES -This cmdlet uses the **Win32_PingStatus** class. A `Get-WMIObject Win32_PingStatus` command is +This cmdlet uses the **Win32_PingStatus** class. A `Get-WmiObject Win32_PingStatus` command is equivalent to a `Test-Connection` command. The **Source** parameter set was introduced in PowerShell 3.0. diff --git a/reference/5.1/Microsoft.PowerShell.Management/Undo-Transaction.md b/reference/5.1/Microsoft.PowerShell.Management/Undo-Transaction.md index 49488753956c..9fe1ed749b88 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Undo-Transaction.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Undo-Transaction.md @@ -48,7 +48,7 @@ This command rolls back the current, active, transaction. ### Example 2: Start and roll back a transaction ```powershell -Set-Location hkcu:\software +Set-Location HKCU:\software Start-Transaction New-Item -Path "ContosoCompany" -UseTransaction Undo-Transaction @@ -60,7 +60,7 @@ registry. ### Example 3: Roll back a transaction for all subscribers ```powershell -Set-Location hkcu:\software +Set-Location HKCU:\software Start-Transaction New-Item -Path "ContosoCompany" -UseTransaction Get-Transaction diff --git a/reference/5.1/Microsoft.PowerShell.Management/Use-Transaction.md b/reference/5.1/Microsoft.PowerShell.Management/Use-Transaction.md index 5e48629395aa..674ec7064a9a 100644 --- a/reference/5.1/Microsoft.PowerShell.Management/Use-Transaction.md +++ b/reference/5.1/Microsoft.PowerShell.Management/Use-Transaction.md @@ -162,7 +162,7 @@ Accept wildcard characters: False ### -UseTransaction Includes the command in the active transaction. This parameter is valid only when a transaction is -in progress. For more information, see [about_transactions](../Microsoft.PowerShell.Core/About/about_Transactions.md). +in progress. For more information, see [about_Transactions](../Microsoft.PowerShell.Core/About/about_Transactions.md). ```yaml Type: System.Management.Automation.SwitchParameter diff --git a/reference/5.1/Microsoft.PowerShell.Utility/ConvertFrom-String.md b/reference/5.1/Microsoft.PowerShell.Utility/ConvertFrom-String.md index 56bae42c8b3d..43cbab561607 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/ConvertFrom-String.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/ConvertFrom-String.md @@ -156,7 +156,7 @@ Wild Shrimp, (111) 222-3333, 1 '@ $PersonalData = $testText | ConvertFrom-String -TemplateContent $template -Write-output ("Pet items found: " + ($PersonalData.Count)) +Write-Output ("Pet items found: " + ($PersonalData.Count)) $PersonalData ``` @@ -206,7 +206,7 @@ Wild Shrimp, (111) 222-3333, 1 '@ $PersonalData = $testText | ConvertFrom-String -TemplateContent $template -Write-output ("Pet items found: " + ($PersonalData.Count)) +Write-Output ("Pet items found: " + ($PersonalData.Count)) $PersonalData ``` diff --git a/reference/5.1/PSReadLine/Get-PSReadLineOption.md b/reference/5.1/PSReadLine/Get-PSReadLineOption.md index d9296a218628..7b2471f95b5e 100644 --- a/reference/5.1/PSReadLine/Get-PSReadLineOption.md +++ b/reference/5.1/PSReadLine/Get-PSReadLineOption.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml Locale: en-US -Module Name: PSReadline +Module Name: PSReadLine ms.date: 12/13/2022 online version: https://learn.microsoft.com/powershell/module/psreadline/get-psreadlineoption?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 diff --git a/reference/5.1/PSReadLine/Remove-PSReadLineKeyHandler.md b/reference/5.1/PSReadLine/Remove-PSReadLineKeyHandler.md index 7e7dd53a7d75..2e9eb156fd4a 100644 --- a/reference/5.1/PSReadLine/Remove-PSReadLineKeyHandler.md +++ b/reference/5.1/PSReadLine/Remove-PSReadLineKeyHandler.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml Locale: en-US -Module Name: PSReadline +Module Name: PSReadLine ms.date: 12/13/2022 online version: https://learn.microsoft.com/powershell/module/psreadline/remove-psreadlinekeyhandler?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 diff --git a/reference/5.1/PSReadLine/Set-PSReadLineKeyHandler.md b/reference/5.1/PSReadLine/Set-PSReadLineKeyHandler.md index b7b0fbdc7da7..a61c98d8492c 100644 --- a/reference/5.1/PSReadLine/Set-PSReadLineKeyHandler.md +++ b/reference/5.1/PSReadLine/Set-PSReadLineKeyHandler.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.PowerShell.PSReadLine2.dll-Help.xml Locale: en-US -Module Name: PSReadline +Module Name: PSReadLine ms.date: 10/02/2023 online version: https://learn.microsoft.com/powershell/module/psreadline/set-psreadlinekeyhandler?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 diff --git a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs.md b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs.md index 057678279528..eaec456f0da1 100644 --- a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs.md +++ b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs.md @@ -156,7 +156,7 @@ The `Receive-Job` cmdlet gets the results of the most recent instance of the **ProcessJob** scheduled job (ID = 51). ```powershell -Receive-Job -ID 51 +Receive-Job -Id 51 ``` Even though the `Receive-Job` command did not include the **Keep** parameter, diff --git a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Advanced.md b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Advanced.md index f87032c4d47f..2a09c00b3262 100644 --- a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Advanced.md +++ b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Advanced.md @@ -117,7 +117,7 @@ Mode LastWriteTime Length Name ``` You can open and examine the **ScheduledJobDefinition.xml**, **Results.xml** -and **Status.xml** files or use the `Select-XML` cmdlet to parse the files. +and **Status.xml** files or use the `Select-Xml` cmdlet to parse the files. > [!WARNING] > Do not edit the XML files. If any XML file contains invalid XML, PowerShell @@ -145,7 +145,8 @@ Start-Job -DefinitionName ProcessJob ``` To manage the job and get the job results, use the job cmdlets. For more -information about the job cmdlets, see [about_Jobs](../../Microsoft.PowerShell.Core/About/about_Jobs.md). +information about the job cmdlets, see +[about_Jobs](../../Microsoft.PowerShell.Core/About/about_Jobs.md). > [!NOTE] > To use the Job cmdlets on instances of scheduled jobs, the **PSScheduledJob** @@ -172,9 +173,9 @@ instance in a table. A calculated property named **Label** displays the elapsed time of each job instance. ```powershell -Get-job -Name UpdateHelpJob | - Format-Table -Property ID, PSBeginTime, PSEndTime, -@{Label="Elapsed Time";Expression={$.PsEndTime - $.PSBeginTime}} +Get-Job -Name UpdateHelpJob | + Format-Table -Property Id, PSBeginTime, PSEndTime, + @{Label="Elapsed Time";Expression={$.PSEndTime - $.PSBeginTime}} ``` ```Output @@ -213,7 +214,8 @@ new instances of the scheduled job. The following example uses splatting to create `$JobParms` which are parameter values that are passed to the `Register-ScheduledJob` cmdlet. For more -information, see [about_Splatting.md](../../Microsoft.PowerShell.Core/About/about_Splatting.md). +information, see +[about_Splatting.md](../../Microsoft.PowerShell.Core/About/about_Splatting.md). The `Register-ScheduledJob` uses `@JobParms` to create a scheduled job. The command uses the **MaxResultCount** parameter with a value of 12 to save only the 12 newest job instance results of the scheduled job. diff --git a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Basics.md b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Basics.md index a0bcc6050524..8a00392977e9 100644 --- a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Basics.md +++ b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Basics.md @@ -108,7 +108,7 @@ Monday and Thursday at 5:00 AM. ## How to get a job trigger To get the job trigger of a scheduled job, use the `Get-JobTrigger` cmdlet. Use -the **Name**, **ID**, and **InputObject** parameters to specify the scheduled +the **Name**, **Id**, and **InputObject** parameters to specify the scheduled job, not the job trigger. `Get-JobTrigger` gets the job trigger of the **ProcessJob**. @@ -149,7 +149,7 @@ $O = New-ScheduledJobOption -WakeToRun ## How to get job options To get the job options of a scheduled job, use the `Get-ScheduledJobOption` -cmdlet. Use the **Name**, **ID**, and **InputObject** parameters to specify the +cmdlet. Use the **Name**, **Id**, and **InputObject** parameters to specify the scheduled job, not the job options. `Get-ScheduledJobOption` gets the job options of the **ProcessJob**. @@ -200,7 +200,7 @@ value of the **WakeToRun** option of the **ProcessJob** scheduledJob to **True**. The `Set` cmdlets in the **PSScheduledJob** module, such as the -`Set-ScheduledJobOption` cmdlet, don't have **Name** or **ID** parameters. You +`Set-ScheduledJobOption` cmdlet, don't have **Name** or **Id** parameters. You can use the **InputObject** parameter to specify the scheduled job options or pipe a scheduled job from `Get-ScheduledJobOption` cmdlet to `Set-ScheduledJobOption`. @@ -258,11 +258,11 @@ The default display does not show the start time, which typically distinguishes instances of the same scheduled job. The `Get-Job` cmdlet sends objects down the pipeline. The `Format-Table` cmdlet -displays the **Name**, **ID**, and **BeginTime** properties of the scheduled +displays the **Name**, **Id**, and **BeginTime** properties of the scheduled job. ```powershell -Get-Job ProcessJob | Format-Table -Property Name, ID, BeginTime +Get-Job ProcessJob | Format-Table -Property Name, Id, BeginTime ``` ```Output @@ -294,7 +294,7 @@ This examples gets the results of the newest instance of the ```powershell Import-Module PSScheduledJob -Receive-Job -ID 51 -Keep +Receive-Job -Id 51 -Keep ``` The results of scheduled jobs are saved on disk, so the **Keep** parameter of diff --git a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Troubleshooting.md b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Troubleshooting.md index 0125578e31c2..2b7f2d68c121 100644 --- a/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Troubleshooting.md +++ b/reference/5.1/PSScheduledJob/About/about_Scheduled_Jobs_Troubleshooting.md @@ -60,11 +60,11 @@ Id Name PSJobTypeName State HasMoreData Location ``` The `Get-Job` cmdlet sends **ProcessJob** objects down the pipeline. The -`Format-Table` cmdlet displays the **Name**, **ID**, and **PSBeginTime** +`Format-Table` cmdlet displays the **Name**, **Id**, and **PSBeginTime** properties of a scheduled job instance in a table. ```powershell -Get-Job ProcessJob | Format-Table -Property Name, ID, PSBeginTime -Auto +Get-Job ProcessJob | Format-Table -Property Name, Id, PSBeginTime -Auto ``` ```Output @@ -85,7 +85,7 @@ cmdlet. The following command gets the results of the newest instance of the ProcessJob (ID = 50). ```powershell -Receive-Job -ID 50 +Receive-Job -Id 50 ``` ### Basic method for finding job results on disk @@ -145,7 +145,7 @@ Get-ChildItem $Path ``` ```Output -Directory: C:\Users\User01\Appdata\Local\Microsoft\Windows\PowerShell +Directory: C:\Users\User01\AppData\Local\Microsoft\Windows\PowerShell \ScheduledJobs\ProcessJob\Output ``` @@ -182,7 +182,7 @@ To get the job instance results again, start a new PowerShell session by typing command again. ```powershell -Receive-Job -ID 50 +Receive-Job -Id 50 ``` ```Output @@ -190,7 +190,7 @@ Receive-Job -ID 50 ``` ```powershell -PowerShell.exe +powershell.exe ``` ```Output @@ -200,7 +200,7 @@ Copyright (C) 2012 Microsoft Corporation. All rights reserved. ```powershell Import-Module PSScheduledJob -Receive-Job -ID 50 +Receive-Job -Id 50 ``` ```Output @@ -218,7 +218,7 @@ To get the result of a job instance more than one time in a session, use the ```powershell Import-Module PSScheduledJob -Receive-Job -ID 50 -Keep +Receive-Job -Id 50 -Keep ``` ```Output @@ -230,7 +230,7 @@ Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ``` ```powershell -Receive-Job -ID 50 -Keep +Receive-Job -Id 50 -Keep ``` ```Output @@ -466,7 +466,7 @@ the **ScheduledJob** directory. The directory's location: -`$env:UserProfile\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs` +`$Env:USERPROFILE\AppData\Local\Microsoft\Windows\PowerShell\ScheduledJobs` For example: diff --git a/reference/5.1/PSScheduledJob/Add-JobTrigger.md b/reference/5.1/PSScheduledJob/Add-JobTrigger.md index 8150347d3984..683229023044 100644 --- a/reference/5.1/PSScheduledJob/Add-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/Add-JobTrigger.md @@ -42,7 +42,7 @@ triggers to multiple scheduled jobs. A job trigger starts a scheduled job on a one-time or recurring schedule or when an event occurs. Use the **Trigger** parameter of `Add-JobTrigger` to identify the job triggers to add. Use the -**Name**, **ID**, or **InputObject** parameters of `Add-JobTrigger` to identify the scheduled job to +**Name**, **Id**, or **InputObject** parameters of `Add-JobTrigger` to identify the scheduled job to which the triggers are added. To create job triggers for the value of the **Trigger** parameter, use the `New-JobTrigger` cmdlet diff --git a/reference/5.1/PSScheduledJob/Disable-JobTrigger.md b/reference/5.1/PSScheduledJob/Disable-JobTrigger.md index a9b71b5c8b73..b8bab09782fd 100644 --- a/reference/5.1/PSScheduledJob/Disable-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/Disable-JobTrigger.md @@ -37,10 +37,12 @@ triggers, the effect is the same as disabling the scheduled job. If you disable a scheduled job or disable all job triggers of a scheduled job, you can still start the job by using the `Start-Job` cmdlet or use the disabled scheduled job as a template. -`Disable-ScheduledJob` is one of a collection of job scheduling cmdlets in the **PSScheduledJob** module that is included in Windows PowerShell. +`Disable-ScheduledJob` is one of a collection of job scheduling cmdlets in the **PSScheduledJob** +module that is included in Windows PowerShell. For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import -the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). +the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see +[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). This cmdlet was introduced in Windows PowerShell 3.0. @@ -51,7 +53,7 @@ This cmdlet was introduced in Windows PowerShell 3.0. This example disables the first trigger a scheduled job on the local computer. ```powershell -PS C:\> Get-JobTrigger -Name "Backup-Archives" -TriggerID 1 | Disable-JobTrigger +PS C:\> Get-JobTrigger -Name "Backup-Archives" -TriggerId 1 | Disable-JobTrigger ``` The command uses the `Get-JobTrigger` cmdlet to get the job trigger. A pipeline operator (`|`)sends @@ -61,8 +63,10 @@ the job trigger to the `Disable-JobTrigger` cmdlet, which disables it. ```powershell Get-ScheduledJob -Name "Backup-Archives,Inventory" | Get-JobTrigger | Disable-JobTrigger -Get-ScheduledJob -Name "Backup-Archives,Inventory" | Get-JobTrigger | - Format-Table -Property ID, Frequency, At, DaysOfWeek, Enabled, @{Label="JobName";Expression={$_.JobDefinition.Name}} -AutoSize +Get-ScheduledJob -Name "Backup-Archives,Inventory" | + Get-JobTrigger | + Format-Table -Property Id, Frequency, At, DaysOfWeek, Enabled, + @{Label="JobName";Expression={$_.JobDefinition.Name}} -AutoSize ``` ```Output @@ -93,7 +97,11 @@ These commands disable all job triggers on two scheduled jobs and display the re This example disables the daily job triggers for a scheduled job on a remote computer ```powershell -Invoke-Command -ComputerName Server01 {Get-JobTrigger -Name DeployPackage | Where-Object {$_.Frequency -eq "Daily"} | Disable-JobTrigger} +Invoke-Command -ComputerName Server01 { + Get-JobTrigger -Name DeployPackage | + Where-Object {$_.Frequency -eq "Daily"} | + Disable-JobTrigger +} ``` The command uses the `Invoke-Command` cmdlet to run the commands on the Server01 computer. The @@ -176,7 +184,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/5.1/PSScheduledJob/Disable-ScheduledJob.md b/reference/5.1/PSScheduledJob/Disable-ScheduledJob.md index a24b0ea8bd43..868da854e5e1 100644 --- a/reference/5.1/PSScheduledJob/Disable-ScheduledJob.md +++ b/reference/5.1/PSScheduledJob/Disable-ScheduledJob.md @@ -59,7 +59,7 @@ This cmdlet was introduced in Windows PowerShell 3.0. This example disables a scheduled job on the local computer. ```powershell -Disable-ScheduledJob -ID 2 -PassThru +Disable-ScheduledJob -Id 2 -PassThru ``` This command disables the scheduled job with ID 2 on the local computer. @@ -121,11 +121,11 @@ TestJob scheduled job on each computer. ### Example 5: Disable a scheduled job by its global ID This examples shows how to disable a scheduled job by using its global identifier. The value of the -GlobalID property of a scheduled job is a unique identifier (GUID). Use the GlobalID value when -precision is required, such as when you are disabling scheduled jobs on multiple computers. +**GlobalId** property of a scheduled job is a unique identifier (GUID). Use the **GlobalId** value +when precision is required, such as when you are disabling scheduled jobs on multiple computers. ```powershell -Get-ScheduledJob | Format-Table -Property Name, GlobalID, Command -Autosize +Get-ScheduledJob | Format-Table -Property Name, GlobalId, Command -AutoSize ``` ```Output @@ -139,13 +139,13 @@ Test-HelpFiles 2f1606d2-c6cf-4bef-8b1c-ae36a9cc9934 .\Test-DomainHelpFiles.ps1 ``` ```powershell -Get-ScheduledJob | Where-Object {$_.GlobalID = d77020ca-f20d-42be-86c8-fc64df97db90} | Disable-ScheduledJob +Get-ScheduledJob | Where-Object {$_.GlobalId = d77020ca-f20d-42be-86c8-fc64df97db90} | Disable-ScheduledJob ``` -The first command demonstrates one way of finding the GlobalID of a scheduled job. The command uses -the `Get-ScheduledJob` cmdlet to get the scheduled jobs on the computer. A pipeline operator (`|`) -sends the scheduled jobs to the `Format-Table` cmdlet, which displays the Name, GlobalID, and -Command properties of each job in a table. +The first command demonstrates one way of finding the **GlobalId** of a scheduled job. The command +uses the `Get-ScheduledJob` cmdlet to get the scheduled jobs on the computer. A pipeline operator +(`|`) sends the scheduled jobs to the `Format-Table` cmdlet, which displays the **Name**, +**GlobalId**, and **Command** properties of each job in a table. The second command uses the `Get-ScheduledJob` cmdlet to get the scheduled jobs on the computer. A pipeline operator (`|`) sends the scheduled jobs to the `Where-Object` cmdlet, which selects the diff --git a/reference/5.1/PSScheduledJob/Enable-JobTrigger.md b/reference/5.1/PSScheduledJob/Enable-JobTrigger.md index 482aeee284b3..c95e29caf8bf 100644 --- a/reference/5.1/PSScheduledJob/Enable-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/Enable-JobTrigger.md @@ -44,7 +44,7 @@ This cmdlet was introduced in Windows PowerShell 3.0. ### Example 1: Enable a job trigger ```powershell -Get-JobTrigger -Name Backup-Archives -TriggerID 1 | Enable-JobTrigger +Get-JobTrigger -Name Backup-Archives -TriggerId 1 | Enable-JobTrigger ``` This command enables the first trigger (ID=1) of the Backup-Archives scheduled job on the local diff --git a/reference/5.1/PSScheduledJob/Enable-ScheduledJob.md b/reference/5.1/PSScheduledJob/Enable-ScheduledJob.md index 5cb01239dde0..db2782168d20 100644 --- a/reference/5.1/PSScheduledJob/Enable-ScheduledJob.md +++ b/reference/5.1/PSScheduledJob/Enable-ScheduledJob.md @@ -57,7 +57,7 @@ This cmdlet was introduced in Windows PowerShell 3.0. This example enables the scheduled job on a local computer. ```powershell -Enable-ScheduledJob -ID 2 -PassThru +Enable-ScheduledJob -Id 2 -PassThru ``` The `Enable-ScheduledJob` command enables the scheduled job with ID 2 on the local computer. The diff --git a/reference/5.1/PSScheduledJob/Get-JobTrigger.md b/reference/5.1/PSScheduledJob/Get-JobTrigger.md index cf5c526f1b86..7e8101849433 100644 --- a/reference/5.1/PSScheduledJob/Get-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/Get-JobTrigger.md @@ -70,7 +70,7 @@ scheduled job. ### Example 2: Get a job trigger by ID -The example uses the **ID** parameter of `Get-JobTrigger` to get the job triggers of a scheduled +The example uses the **Id** parameter of `Get-JobTrigger` to get the job triggers of a scheduled job. ```powershell @@ -87,14 +87,14 @@ Id Name Triggers Command ``` ```powershell -Get-JobTrigger -ID 3 +Get-JobTrigger -Id 3 ``` The first command uses the `Get-ScheduledJob` cmdlet to display the scheduled jobs on the local computer. The display includes the IDs of the scheduled jobs. The second command uses the `Get-JobTrigger` cmdlet to get the job trigger for the `Test-HelpFiles` -job (whose **ID** is `3`). +job (whose **Id** is `3`). ### Example 3: Get job triggers by piping a job @@ -111,12 +111,12 @@ This command gets the job triggers of all jobs that have `Backup` or `Archive` i This example gets the triggers of a scheduled job on a remote computer. ```powershell -Invoke-Command -ComputerName Server01 { Get-ScheduledJob Backup | Get-JobTrigger -TriggerID 2 } +Invoke-Command -ComputerName Server01 { Get-ScheduledJob Backup | Get-JobTrigger -TriggerId 2 } ``` The command uses the `Invoke-Command` cmdlet to run a command on the Server01 computer. It uses the `Get-ScheduledJob` cmdlet to get the `Backup` scheduled job, which it pipes to the `Get-JobTrigger` -cmdlet. It uses the **TriggerID** parameter to get only the second trigger. +cmdlet. It uses the **TriggerId** parameter to get only the second trigger. ### Example 5: Get all job triggers @@ -124,7 +124,7 @@ This example gets all job triggers of all scheduled jobs on the local computer. ```powershell Get-ScheduledJob | Get-JobTrigger | - Format-Table -Property ID, Frequency, At, DaysOfWeek, Enabled, @{Label="ScheduledJob";Expression={$_.JobDefinition.Name}} -AutoSize + Format-Table -Property Id, Frequency, At, DaysOfWeek, Enabled, @{Label="ScheduledJob";Expression={$_.JobDefinition.Name}} -AutoSize ``` ```Output @@ -276,7 +276,7 @@ Accept wildcard characters: False ### -TriggerId Gets the specified job triggers. Enter the trigger IDs of one or more job triggers of a scheduled -job. Use this parameter when the scheduled job that is specified by the **Name**, **ID**, or +job. Use this parameter when the scheduled job that is specified by the **Name**, **Id**, or **InputObject** parameters has multiple job triggers. ```yaml diff --git a/reference/5.1/PSScheduledJob/Get-ScheduledJobOption.md b/reference/5.1/PSScheduledJob/Get-ScheduledJobOption.md index a8cb12aff782..31e8441f5bbd 100644 --- a/reference/5.1/PSScheduledJob/Get-ScheduledJobOption.md +++ b/reference/5.1/PSScheduledJob/Get-ScheduledJobOption.md @@ -81,9 +81,13 @@ the job options of each scheduled job. This example shows how to find job options object with particular values. ```powershell -Get-ScheduledJob | Get-ScheduledJobOption | Where {$_.RunElevated -and !$_.WaketoRun} +Get-ScheduledJob | + Get-ScheduledJobOption | + Where-Object {$_.RunElevated -and !$_.WakeToRun} -Get-ScheduledJob | Get-ScheduledJobOption | Where {$_.RunElevated -and !$_.WaketoRun} | +Get-ScheduledJob | + Get-ScheduledJobOption | + Where-Object {$_.RunElevated -and !$_.WakeToRun} | ForEach-Object {$_.JobDefinition} ``` @@ -103,8 +107,12 @@ This example shows how to use the job options that `Get-ScheduledJobOption` gets job. ```powershell -$Opts = Get-ScheduledJobOption -Name "BackupTestLogs" -Register-ScheduledJob -Name "Archive-Scripts" -FilePath "\\Srv01\Scripts\ArchiveScripts.ps1" -ScheduledJobOption $Opts +$registerScheduledJobSplat = @{ + Name = "Archive-Scripts" + FilePath = "\\Srv01\Scripts\ArchiveScripts.ps1" + ScheduledJobOption = Get-ScheduledJobOption -Name "BackupTestLogs" +} +Register-ScheduledJob @registerScheduledJobSplat ``` The first command uses `Get-ScheduledJobOption` to get the jobs options of the BackupTestLogs @@ -186,7 +194,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/5.1/PSScheduledJob/New-JobTrigger.md b/reference/5.1/PSScheduledJob/New-JobTrigger.md index cd95f96613f6..04c379e204eb 100644 --- a/reference/5.1/PSScheduledJob/New-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/New-JobTrigger.md @@ -188,7 +188,13 @@ by the job trigger. This example creates a repeating job trigger to only run for a specific amount of time. ```powershell -New-JobTrigger -Once -At "09/12/2013 1:00:00" -RepetitionInterval (New-TimeSpan -Hours 1) -RepetitionDuration (New-Timespan -Hours 48) +$newJobTriggerSplat = @{ + Once = -Once + At = "09/12/2013 1:00:00" + RepetitionInterval = (New-TimeSpan -Hours 1) + RepetitionDuration = (New-TimeSpan -Hours 48) +} +New-JobTrigger @newJobTriggerSplat ``` This command creates a job trigger that runs a job every 60 minutes for 48 hours beginning on @@ -199,7 +205,8 @@ September 12, 2013 at 1:00 AM. This example stops a repeating job trigger. ```powershell -Get-JobTrigger -Name SecurityCheck | Set-JobTrigger -RepetitionInterval 0:00 -RepetitionDuration 0:00 +Get-JobTrigger -Name SecurityCheck | + Set-JobTrigger -RepetitionInterval 0:00 -RepetitionDuration 0:00 ``` This command forcibly stops the **SecurityCheck** job, which is triggered to run every 60 minutes @@ -214,7 +221,13 @@ repetition duration of the job trigger to zero (`0`). This example creates a repeating job trigger that runs indefinitely. ```powershell -New-JobTrigger -Once -At "9/21/2012 0am" -RepetitionInterval (New-TimeSpan -Hour 12) -RepetitionDuration ([TimeSpan]::MaxValue) +$newJobTriggerSplat = @{ + Once = -Once + At = "9/21/2012 0am" + RepetitionInterval = (New-TimeSpan -Hour 12) + RepetitionDuration = ([timespan]::MaxValue) +} +New-JobTrigger @newJobTriggerSplat ``` The following command creates a job trigger that runs a scheduled job once every 12 hours for an diff --git a/reference/5.1/PSScheduledJob/New-ScheduledJobOption.md b/reference/5.1/PSScheduledJob/New-ScheduledJobOption.md index 53a80127e7f4..3311be8acd04 100644 --- a/reference/5.1/PSScheduledJob/New-ScheduledJobOption.md +++ b/reference/5.1/PSScheduledJob/New-ScheduledJobOption.md @@ -45,7 +45,8 @@ satisfied. module that is included in Windows PowerShell. For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import -the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). +the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see +[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). This cmdlet was introduced in Windows PowerShell 3.0. @@ -98,7 +99,13 @@ returns to set the options for a new scheduled job. ```powershell $runAsAdmin = New-ScheduledJobOption -RunElevated -Register-ScheduledJob -Name Backup -FilePath D:\Scripts\Backup.ps1 -Trigger $Mondays -ScheduledJobOption $RunAsAdmin +$registerScheduledJobSplat = @{ + Name = 'Backup' + FilePath = 'D:\Scripts\Backup.ps1' + Trigger = $Mondays + ScheduledJobOption = $RunAsAdmin +} +Register-ScheduledJob @registerScheduledJobSplat Get-ScheduledJobOption -Name Backup ``` @@ -138,7 +145,9 @@ order for easy reading. ```powershell $options = New-ScheduledJobOption -WakeToRun -$options.PSObject.Properties | Sort-Object -Property Name | Format-Table -Property Name, Value -Autosize +$options.psobject.Properties | + Sort-Object -Property Name | + Format-Table -Property Name, Value -AutoSize ``` ```Output @@ -164,7 +173,7 @@ The first command uses the `New-ScheduledJobOption` cmdlet to create a **Schedul object. The command uses the **WakeToRun** parameter and saves the resulting object in the `$options` variable. -To get the properties of $Options as objects, the second command uses the **PSObject** property of +To get the properties of $Options as objects, the second command uses the **psobject** property of all Windows PowerShell objects and its Properties property. The command then pipes the property objects to the `Sort-Object` cmdlet, which sorts the properties in alphabetical order by name, and then to the `Format-Table` cmdlet, which displays the names and values of the properties in a table. @@ -248,7 +257,7 @@ If the computer is not idle for the specified duration before the value of **Idl the scheduled job does not run until the next scheduled time, if any. Enter a **TimeSpan** object, such as one generated by the `New-TimeSpan` cmdlet, or enter a value in -\:\:\ format that is automatically converted to a **TimeSpan** object. +`::` format that is automatically converted to a **TimeSpan** object. To enable this value, use the **StartIfIdle** parameter. By default, the StartIfNotIdle property of 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 hour. Enter a **TimeSpan** object, such as one generated by the `New-TimeSpan` cmdlet, or enter a value in -\:\:\ format that is automatically converted to a **TimeSpan** object. +`::` format that is automatically converted to a **TimeSpan** object. To enable this value, use the **StartIfIdle** parameter. By default, the **StartIfNotIdle** property of scheduled jobs is set to `$true` and Windows PowerShell ignores the **IdleDuration** and @@ -417,7 +426,8 @@ Accept wildcard characters: False Starts the scheduled job even if the computer is running on batteries at the scheduled start time. The default value is `$false`. -The **StartIfOnBattery** parameter sets the value of the StartIfOnBatteries property of scheduled jobs to `$true`. +The **StartIfOnBattery** parameter sets the value of the StartIfOnBatteries property of scheduled +jobs to `$true`. ```yaml Type: System.Management.Automation.SwitchParameter @@ -479,7 +489,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/5.1/PSScheduledJob/Register-ScheduledJob.md b/reference/5.1/PSScheduledJob/Register-ScheduledJob.md index 5ca092259ee9..23768ac6c75d 100644 --- a/reference/5.1/PSScheduledJob/Register-ScheduledJob.md +++ b/reference/5.1/PSScheduledJob/Register-ScheduledJob.md @@ -85,7 +85,7 @@ This example creates a scheduled job on the local computer. ```powershell Register-ScheduledJob -Name "Archive-Scripts" -ScriptBlock { Get-ChildItem $HOME\*.ps1 -Recurse | - Copy-Item -Destination "\\Server\Share\PSScriptArchive" + Copy-Item -Destination "\\Server\Share\PSScriptArchive" } ``` @@ -141,7 +141,13 @@ $O = @{ StartIfNotIdle=$false MultipleInstancePolicy="Queue" } -Register-ScheduledJob -Trigger $T -ScheduledJobOption $O -Name UpdateVersion -FilePath "\\Srv01\Scripts\Update-Version.ps1" +$registerScheduledJobSplat = @{ + Trigger = $T + ScheduledJobOption = $O + Name = 'UpdateVersion' + FilePath = "\\Srv01\Scripts\Update-Version.ps1" +} +Register-ScheduledJob @registerScheduledJobSplat ``` ### Example 4: Create scheduled jobs on remote computers @@ -158,8 +164,8 @@ Invoke-Command -ComputerName (Get-Content Servers.txt) -Credential $Cred -Script $params = @{ Name = "Get-EnergyData" FilePath = "\\Srv01\Scripts\Get-EnergyData.ps1" - ScheduledJobOption = $using:O - Trigger = $using:T + ScheduledJobOption = $Using:O + Trigger = $Using:T } Register-ScheduledJob @params } @@ -196,7 +202,7 @@ Register-ScheduledJob -Name "CollectEnergyData" -Trigger $T -MaxResultCount 99 - AsJob = $true ComputerName = (Get-Content Servers.txt) FilePath = '\\Srv01\Scripts\Get-EnergyData.ps1' - Credential = $using:Admin + Credential = $Using:Admin Authentication = 'CredSSP' } Invoke-Command @params diff --git a/reference/5.1/PSScheduledJob/Remove-JobTrigger.md b/reference/5.1/PSScheduledJob/Remove-JobTrigger.md index 9a56185496f1..1444e56eb39a 100644 --- a/reference/5.1/PSScheduledJob/Remove-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/Remove-JobTrigger.md @@ -40,15 +40,16 @@ The `Remove-JobTrigger` cmdlet deletes job triggers from scheduled jobs. A job trigger defines a recurring schedule or conditions for starting a scheduled job. To manage job triggers, use the New-JobTrigger, Add-JobTrigger, Set-JobTrigger, and `Set-ScheduledJob` cmdlets. -Use the **Name**, **ID**, or **InputObject** parameters of `Remove-JobTrigger` to identify the -scheduled jobs from which the triggers are removed. Use the **TriggerID** parameter to identify the +Use the **Name**, **Id**, or **InputObject** parameters of `Remove-JobTrigger` to identify the +scheduled jobs from which the triggers are removed. Use the **TriggerId** parameter to identify the job triggers to delete. By default, `Remove-JobTrigger` deletes all job triggers of a scheduled job. `Remove-JobTrigger` is one of a collection of job scheduling cmdlets in the PSScheduledJob module that is included in Windows PowerShell. For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import -the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). +the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see +[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). This cmdlet was introduced in Windows PowerShell 3.0. @@ -65,7 +66,7 @@ This command deletes all job triggers from scheduled job that have names that be ### Example 2: Delete selected job triggers ```powershell -Remove-JobTrigger -Name "BackupArchive" -TriggerID 3 +Remove-JobTrigger -Name "BackupArchive" -TriggerId 3 ``` This command deletes only the third trigger (ID = 3) from the BackupArchive scheduled job. @@ -73,9 +74,11 @@ This command deletes only the third trigger (ID = 3) from the BackupArchive sche ### Example 3: Delete AtStartup job triggers from all scheduled jobs ```powershell -function Delete-AtStartup -{ - Get-ScheduledJob | Get-JobTrigger | Where-Object {$_.Frequency -eq "AtStartup"} | ForEach-Object { Remove-JobTrigger -InputObject $_.JobDefinition -TriggerID $_.ID} +function Delete-AtStartup { + Get-ScheduledJob | + Get-JobTrigger | + Where-Object {$_.Frequency -eq "AtStartup"} | + ForEach-Object { Remove-JobTrigger -InputObject $_.JobDefinition -TriggerId $_.Id} } ``` @@ -94,19 +97,19 @@ trigger. The remainder of the command uses that valuable feature. A pipeline operator sends the AtStartup job triggers to the `ForEach-Object` cmdlet, which runs a `Remove-JobTrigger` command on each AtStartup trigger. The value of the **InputObject** parameter of `Remove-JobTrigger` is the scheduled job in the JobDefinition property of the job trigger. The value -of the **TriggerID** parameter is the identifier in the ID property of the job trigger. +of the **TriggerId** parameter is the identifier in the ID property of the job trigger. ### Example 4: Delete a job trigger from a remote scheduled job ```powershell -Invoke-Command -ComputerName "Server01" { Remove-JobTrigger -ID 38 -TriggerID 1 } +Invoke-Command -ComputerName "Server01" { Remove-JobTrigger -Id 38 -TriggerId 1 } ``` This command deletes the first job trigger from the Inventory job on the Server01 computer. The command uses the `Invoke-Command` cmdlet to run the `Remove-JobTrigger` cmdlet on the Server01 -computer. The `Remove-JobTrigger` cmdlet uses the **ID** parameter to identify the Inventory -scheduled job and the **TriggerID** parameter to specify the first trigger. The **ID** parameter is +computer. The `Remove-JobTrigger` cmdlet uses the **Id** parameter to identify the Inventory +scheduled job and the **TriggerId** parameter to specify the first trigger. The **Id** parameter is especially useful when multiple scheduled jobs have the same or similar names. ## PARAMETERS @@ -194,7 +197,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/5.1/PSScheduledJob/Set-JobTrigger.md b/reference/5.1/PSScheduledJob/Set-JobTrigger.md index 4e3c5b5f647b..d75e44b838d1 100644 --- a/reference/5.1/PSScheduledJob/Set-JobTrigger.md +++ b/reference/5.1/PSScheduledJob/Set-JobTrigger.md @@ -106,7 +106,8 @@ Id Frequency Time DaysOfWeek Enable ``` ```powershell -Get-JobTrigger -Name "Inventory" -TriggerID 2 | Set-JobTrigger -Weekly -WeeksInterval 4 -DaysOfWeek Monday -At "12:00 AM" +Get-JobTrigger -Name "Inventory" -TriggerId 2 | + Set-JobTrigger -Weekly -WeeksInterval 4 -DaysOfWeek Monday -At "12:00 AM" ``` ```Output @@ -121,7 +122,7 @@ scheduled job. The output shows that the job has two triggers a daily trigger an trigger. The second command uses the `Get-JobTrigger` cmdlet to get the **AtStartup** job trigger of the -`Inventory` job. The command uses the **TriggerID** parameter to identify the job trigger. A +`Inventory` job. The command uses the **TriggerId** parameter to identify the job trigger. A pipeline operator (`|`) sends the job trigger to the `Set-JobTrigger` cmdlet, which changes it to a weekly job trigger that runs every four weeks on Monday at midnight. The command uses the **PassThru** parameter to return the trigger after the change. @@ -131,7 +132,12 @@ This command is not required; it is included only to show the effect of the trig ### Example 3: Change the user on a remote job trigger ```powershell -Invoke-Command -ComputerName "Server01" -ScriptBlock {Get-ScheduledJob | Get-JobTrigger | Where-Object {$_.User} | Set-JobTrigger -User "Domain01/Admin02"} +Invoke-Command -ComputerName "Server01" -ScriptBlock { + Get-ScheduledJob | + Get-JobTrigger | + Where-Object {$_.User} | + Set-JobTrigger -User "Domain01/Admin02" +} ``` This command changes the user in all **AtLogon** job triggers of scheduled jobs on the Server01 @@ -163,7 +169,7 @@ Id Frequency Time DaysOfWeek Enable ``` ```powershell -Get-JobTrigger -Name "SecurityCheck" -TriggerID 3 | Format-List -Property * +Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 | Format-List -Property * ``` ```Output @@ -181,8 +187,10 @@ JobDefinition : Microsoft.PowerShell.ScheduledJob.ScheduledJobDefinition ``` ```powershell -Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 | Set-JobTrigger -RepetitionInterval (New-TimeSpan -Minutes 90) -Get-JobTrigger -Name "SecurityCheck" -TriggerID 3 | Format-List -Property * +Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 | + Set-JobTrigger -RepetitionInterval (New-TimeSpan -Minutes 90) +Get-JobTrigger -Name "SecurityCheck" -TriggerId 3 | + Format-List -Property * ``` ```Output @@ -206,9 +214,9 @@ scheduled job has three job triggers, so the commands use the **TriggerId** para The first command uses the `Get-JobTrigger` cmdlet to get all job triggers of the `SecurityCheck` scheduled job. The output, which displays the IDs of the job triggers, reveals that the **Once** job -trigger has an **ID** of `3`. +trigger has an **Id** of `3`. -The second command uses the **TriggerID** parameter of the `Get-JobTrigger` cmdlet to get the +The second command uses the **TriggerId** parameter of the `Get-JobTrigger` cmdlet to get the **Once** trigger of the `SecurityCheck` scheduled job. The command pipes the trigger to the `Format-List` cmdlet, which displays all of the properties of the **Once** job trigger. The output shows that the trigger starts the job once every hour (**RepetitionInterval** is 1 hour) for one day diff --git a/reference/5.1/PSScheduledJob/Set-ScheduledJob.md b/reference/5.1/PSScheduledJob/Set-ScheduledJob.md index e5d85d65070e..ace1a881113d 100644 --- a/reference/5.1/PSScheduledJob/Set-ScheduledJob.md +++ b/reference/5.1/PSScheduledJob/Set-ScheduledJob.md @@ -67,7 +67,8 @@ as a template for other jobs. that is included in Windows PowerShell. For more information about Scheduled Jobs, see the About topics in the PSScheduledJob module. Import -the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). +the PSScheduledJob module and then type: `Get-Help about_Scheduled*` or see +[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). This cmdlet was introduced in Windows PowerShell 3.0. @@ -88,7 +89,8 @@ Id Name Triggers Command ``` ```powershell -Get-ScheduledJob -Name "Inventory" | Set-ScheduledJob -FilePath "C:\Scripts\Get-FullInventory.ps1" -PassThru +Get-ScheduledJob -Name "Inventory" | + Set-ScheduledJob -FilePath "C:\Scripts\Get-FullInventory.ps1" -PassThru ``` ```Output @@ -120,7 +122,8 @@ operator (`|`) sends the job to the `Set-ScheduledJob` cmdlet to change it. The cmdlet uses the **ClearExecutionHistory** parameter to delete the execution history and saved results. -For more information about the execution history and saved job results of scheduled jobs, see [about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). +For more information about the execution history and saved job results of scheduled jobs, see +[about_Scheduled_Jobs](About/about_Scheduled_Jobs.md). ### Example 3: Change scheduled jobs on a remote computer @@ -170,7 +173,8 @@ for this parameter are: - `Negotiate` - `NegotiateWithImplicitCredential` -The default value is `Default`. For more information about the values of this parameter, see [AuthenticationMechanism Enumeration](/dotnet/api/system.management.automation.runspaces.authenticationmechanism) +The default value is `Default`. For more information about the values of this parameter, see +[AuthenticationMechanism Enumeration](/dotnet/api/system.management.automation.runspaces.authenticationmechanism) in the PowerShell SDK. > [!CAUTION] @@ -241,9 +245,9 @@ Accept wildcard characters: False ### -FilePath -Specifies a script that the scheduled job runs. Enter the path to a .ps1 file on the local computer. -To specify default values for the script parameters, use the **ArgumentList** parameter. Every -scheduled job must have either a **ScriptBlock** or **FilePath** value. +Specifies a script that the scheduled job runs. Enter the path to a `.ps1` file on the local +computer. To specify default values for the script parameters, use the **ArgumentList** parameter. +Every scheduled job must have either a **ScriptBlock** or **FilePath** value. ```yaml Type: System.String @@ -518,7 +522,8 @@ Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, --WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). +-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS diff --git a/reference/5.1/PSWorkflow/About/about_ActivityCommonParameters.md b/reference/5.1/PSWorkflow/About/about_ActivityCommonParameters.md index cd7934f351fc..21322d332b56 100644 --- a/reference/5.1/PSWorkflow/About/about_ActivityCommonParameters.md +++ b/reference/5.1/PSWorkflow/About/about_ActivityCommonParameters.md @@ -16,15 +16,15 @@ Describes the parameters that Windows PowerShell Workflow adds to activities. Windows PowerShell Workflow adds the activity common parameters to activities that are derived from the **PSActivity** base class. This category includes the -**InlineScript** activity and Windows PowerShell cmdlets that are implemented as +`inlinescript` activity and Windows PowerShell cmdlets that are implemented as activities, such as `Get-Process` and `Get-WinEvent`. The activity common parameters are not valid on the `Suspend-Workflow` and `Checkpoint-Workflow` activities and they are not added to cmdlets or expressions that Windows PowerShell Workflow automatically runs in an -**InlineScript** script block or similar activity. The activity common -parameters are available on the **InlineScript** activity, but not on commands -in the **InlineScript** script block. +`inlinescript` script block or similar activity. The activity common +parameters are available on the `inlinescript` activity, but not on commands +in the `inlinescript` script block. Several of the activity common parameters are also workflow common parameters or Windows PowerShell common parameters. Other activity common parameters are @@ -72,8 +72,7 @@ For example, the following commands add a process object to the service object in the `$x` variable. ```powershell -Workflow Test-Workflow -{ +workflow Test-Workflow { $x = Get-Service $x = Get-Process -AppendOutput $true } @@ -84,8 +83,7 @@ can also use the `+=` assignment operator to add output to the value of a variable, as shown in the following example. ```powershell -Workflow Test-Workflow -{ +workflow Test-Workflow { $x = Get-Service $x += Get-Process } @@ -145,7 +143,7 @@ piping objects to the activity one at a time. #### MergeErrorToOutput \ A value of `$true` adds errors to the output stream. A value of `$false` has -no effect. Use this parameter with the **Parallel** and `ForEach -Parallel` +no effect. Use this parameter with the `parallel` and `foreach -Parallel` keywords to collect errors and output from multiple parallel commands in a single collection. @@ -334,12 +332,11 @@ in a variable. Then, use the variable as the value of the **PSDebug** parameter of one or more activities, as shown in the following example. ```powershell -Workflow Test-Workflow -{ +workflow Test-Workflow { $debugCollection = New-Object -Type ` System.Management.Automation.PSDataCollection[System.Management.Automation.DebugRecord] - InlineScript {\Server01\Share01\Get-AssetData.ps1} -PSDebug $debugCollection -Debug $true - InlineScript {\Server01\Share01\Set-AssetData.ps1} -PSDebug $debugCollection -Debug $true + inlinescript {\Server01\Share01\Get-AssetData.ps1} -PSDebug $debugCollection -Debug $true + inlinescript {\Server01\Share01\Set-AssetData.ps1} -PSDebug $debugCollection -Debug $true if ($debugCollection -like "Missing") { ...} } ``` @@ -380,15 +377,13 @@ in a variable. Then, use the variable as the value of the **PSError** parameter of one or more activities, as shown in the following example. ```powershell -Workflow Test-Workflow -{ +workflow Test-Workflow { $typeName = "System.Management.Automation.PSDataCollection" $typeName += '[System.Management.Automation.ErrorRecord]' $ec = New-Object $typeName - InlineScript {\Server01\Share01\Get-AssetData.ps1} -PSError $ec - InlineScript {\Server01\Share01\Set-AssetData.ps1} -PSError $ec - if ($ec.Count -gt 2) - { + inlinescript {\Server01\Share01\Get-AssetData.ps1} -PSError $ec + inlinescript {\Server01\Share01\Set-AssetData.ps1} -PSError $ec + if ($ec.Count -gt 2) { # Do Some Work. } } @@ -445,7 +440,7 @@ also included in the command, the progress bar content appears in `:` format. This parameter is particularly useful for identifying activities in a -`ForEach -Parallel` script block. Without this message, activities in all +`foreach -Parallel` script block. Without this message, activities in all parallel branches are identified by the same name. #### PSRemotingBehavior \ @@ -537,8 +532,7 @@ the workflow. When you run the workflow with input, that input is used by the activity. ```powershell -workflow Test-Workflow -{ +workflow Test-Workflow { Get-Service -UseDefaultInput $true } @@ -600,25 +594,17 @@ parameters to run a `Get-EventLog` activity only on computers it a particular domain. ```powershell -Workflow Test-Workflow -{ +workflow Test-Workflow { $UserDomain = Get-Content -Path '.\UserComputers.txt' $Log = (Get-EventLog -LogName "Windows PowerShell" ` -PSComputerName $UserDomain) - if ($Log) - { + if ($Log) { # Do Work Here. } } ``` - - ## See Also - [about_Workflows](about_workflows.md) diff --git a/reference/5.1/PSWorkflow/About/about_Checkpoint-Workflow.md b/reference/5.1/PSWorkflow/About/about_Checkpoint-Workflow.md index 858943adad8d..242dcd21bd85 100644 --- a/reference/5.1/PSWorkflow/About/about_Checkpoint-Workflow.md +++ b/reference/5.1/PSWorkflow/About/about_Checkpoint-Workflow.md @@ -23,8 +23,7 @@ The Checkpoint-Workflow activity is valid only in a workflow. ### SYNTAX ``` -Workflow -{ +workflow { Checkpoint-Workflow } ``` @@ -33,7 +32,7 @@ The Checkpoint-Workflow activity does not accept any parameters, including commo workflow common parameters. You can place the Checkpoint-Activity checkpoint anywhere in a workflow after the CmdletBinding or -Param statement. However, when placing checkpoints, consider the performance cost of collecting the +`param` statement. However, when placing checkpoints, consider the performance cost of collecting the data and writing it to disk on the computer that is running the workflow. Be sure that the time it takes to rerun a section of the workflow if it is interrupted is greater @@ -72,14 +71,12 @@ The following workflow includes a call to the Checkpoint-Workflow activity after long-running function and a script that share data. ```powershell -Workflow Test-Workflow -{ +workflow Test-Workflow { $a = Invoke-LongRunningFunction - InlineScript { \\Server\Share\Get-DataPacks.ps1 $Using:a} + inlinescript { \\Server\Share\Get-DataPacks.ps1 $Using:a} Checkpoint-Workflow - Invoke-LongRunningFunction - { + Invoke-LongRunningFunction { ... } } diff --git a/reference/5.1/PSWorkflow/About/about_Foreach-Parallel.md b/reference/5.1/PSWorkflow/About/about_Foreach-Parallel.md index ac729aac9b72..30540366fe12 100644 --- a/reference/5.1/PSWorkflow/About/about_Foreach-Parallel.md +++ b/reference/5.1/PSWorkflow/About/about_Foreach-Parallel.md @@ -1,5 +1,5 @@ --- -description: Describes the `ForEach -Parallel` language construct in Windows PowerShell Workflow. +description: Describes the `foreach -Parallel` language construct in Windows PowerShell Workflow. Locale: en-US ms.date: 09/10/2021 online version: https://learn.microsoft.com/powershell/module/psworkflow/about/about_foreach-parallel?view=powershell-5.1&WT.mc_id=ps-gethelp @@ -9,25 +9,24 @@ title: about_Foreach-Parallel # about_Foreach-Parallel ## SHORT DESCRIPTION -Describes the `ForEach -Parallel` language construct in Windows PowerShell +Describes the `foreach -Parallel` language construct in Windows PowerShell Workflow. ## LONG DESCRIPTION -The **Parallel** parameter of the `ForEach` keyword runs the commands in a -`ForEach` script block once for each item in a specified collection. +The **Parallel** parameter of the `foreach` keyword runs the commands in a +`foreach` script block once for each item in a specified collection. The items in the collection, such as a disk in a collection of disks, are processed in parallel. The commands in the script block run sequentially on each item in the collection. -`ForEach -Parallel` is valid only in a Windows PowerShell Workflow. +`foreach -Parallel` is valid only in a Windows PowerShell Workflow. ### SYNTAX ``` -ForEach -Parallel ($ in $) -{ +foreach -Parallel ($ in $) { [] [] ... @@ -36,35 +35,34 @@ ForEach -Parallel ($ in $) ### DETAILED DESCRIPTION -Like the ForEach statement in Windows PowerShell, the variable that contains -collection `$` must be defined before the `ForEach -Parallel` +Like the `foreach` statement in Windows PowerShell, the variable that contains +collection `$` must be defined before the `foreach -Parallel` statement, but the variable that represents the current item `$` is -defined in the `ForEach -Parallel` statement. +defined in the `foreach -Parallel` statement. -The `ForEach -Parallel` construct is different from the `ForEach` keyword and -the **Parallel** parameter. The `ForEach` keyword processes the items in the +The `foreach -Parallel` construct is different from the `foreach` keyword and +the **Parallel** parameter. The `foreach` keyword processes the items in the collection in sequence. The **Parallel** parameter runs commands in a script block in parallel. You can enclose a Parallel script block in a -`ForEach -Parallel` script block. +`foreach -Parallel` script block. The target computers in a workflow, such as those specified by the **PSComputerName** workflow common parameter, are always processed in parallel. -You do not need to specify the `ForEach -Parallel` keyword for this purpose. +You do not need to specify the `foreach -Parallel` keyword for this purpose. ### EXAMPLES -The following workflow contains a `ForEach -Parallel` statement that processes +The following workflow contains a `foreach -Parallel` statement that processes the disks that the `Get-Disk` activity gets. The commands in the -`ForEach -Parallel` script block run sequentially, but they run on the disks in +`foreach -Parallel` script block run sequentially, but they run on the disks in parallel. The disks might be processed concurrently and in any order. ```powershell -workflow Test-Workflow -{ +workflow Test-Workflow { $Disks = Get-Disk # The disks are processed in parallel. - ForEach -Parallel ($Disk in $Disks) + foreach -Parallel ($Disk in $Disks) { # The commands run sequentially on each disk. $DiskPath = $Disk.Path @@ -75,16 +73,15 @@ workflow Test-Workflow ``` In this version of the workflow, the `Get-Process` and `Get-Service` commands -are run in parallel. The workflow function continues to the `ForEach -Parallel` +are run in parallel. The workflow function continues to the `foreach -Parallel` loop where the commands are run sequentially, but they run on the disks in -parallel. The parallel commands and the `ForEach -Parallel` loop run +parallel. The parallel commands and the `foreach -Parallel` loop run concurrently. ```powershell -workflow Test-Workflow -{ +workflow Test-Workflow { #Run commands in parallel. - Parallel + parallel { Get-Process Get-Service @@ -93,13 +90,13 @@ workflow Test-Workflow $Disks = Get-Disk # The disks are processed in parallel. - ForEach -Parallel ($Disk in $Disks) + foreach -Parallel ($Disk in $Disks) { # The commands run in parallel on each disk. - Parallel + parallel { Initialize-Disk - InlineScript {.\Get-DiskInventory} + inlinescript {.\Get-DiskInventory} } } } @@ -107,7 +104,7 @@ workflow Test-Workflow ## See Also -- [about_ForEach](../../Microsoft.PowerShell.Core/About/about_ForEach.md) +- [about_Foreach](../../Microsoft.PowerShell.Core/About/about_Foreach.md) - [about_Language_Keywords](../../Microsoft.PowerShell.Core/About/about_Language_Keywords.md) - [about_Parallel](about_Parallel.md) - [about_Workflows](about_Workflows.md) diff --git a/reference/5.1/PSWorkflow/About/about_InlineScript.md b/reference/5.1/PSWorkflow/About/about_InlineScript.md index 004a2b99a7b1..fde972c9fffb 100644 --- a/reference/5.1/PSWorkflow/About/about_InlineScript.md +++ b/reference/5.1/PSWorkflow/About/about_InlineScript.md @@ -1,5 +1,5 @@ --- -description: Describes the `InlineScript` activity, that runs PowerShell commands in a workflow. +description: Describes the `inlinescript` activity, that runs PowerShell commands in a workflow. Locale: en-US ms.date: 06/09/2017 online version: https://learn.microsoft.com/powershell/module/psworkflow/about/about_inlinescript?view=powershell-5.1&WT.mc_id=ps-gethelp @@ -11,37 +11,37 @@ title: about_InlineScript ## Short description -Describes the `InlineScript` activity, that runs PowerShell commands in a +Describes the `inlinescript` activity, that runs PowerShell commands in a workflow. ## Long description -The `InlineScript` activity runs commands in a shared PowerShell session's -workflow. `InlineScript` is only valid in workflows. +The `inlinescript` activity runs commands in a shared PowerShell session's +workflow. `inlinescript` is only valid in workflows. ## Syntax ``` -InlineScript {