Skip to content

Conversation

surfingoldelephant
Copy link
Contributor

@surfingoldelephant surfingoldelephant commented Apr 13, 2025

PR Summary

In this PR, ForEach-Object example 17 is updated to reflect behavior consistent with PS v7.2+. Example 17 demonstrates use of variable access using nested -Parallel script blocks.

PR Context

In PS v7.2, ForEach-Object -Parallel was updated to correctly support variable access in nested script block scenarios. See:

Example 17 in the docs currently reflects the erroneous behavior exhibited in v7.1 and prior. This example was added as part of:

PR Checklist

  • Descriptive Title: This PR's title is a synopsis of the changes it proposes.
  • Summary: This PR's summary describes the scope and intent of the change.
  • Contributor's Guide: I have read the contributors guide.
  • Style: This PR adheres to the style guide.

In PS v7.2, ForEach-Object -Parallel was updated to support variable
access in nested script block scenarios.

Example 17 in the docs currently reflects the erroneous behavior
exhibited in v7.1 and prior. This change updates the example to
reflect the fixed behavior in v7.2.

See PS issue MicrosoftDocs#11817 for more information.
Copy link
Contributor

Learn Build status updates of commit c243621:

❌ Validation status: errors

Please follow instructions here which may help to resolve issue.

File Status Preview URL Details
reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md ❌Error Details
reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md ❌Error Details
reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md ❌Error Details
reference/7.4/CimCmdlets/Get-CimInstance.yml ⚠️Warning Details
reference/7.4/CimCmdlets/Get-CimSession.yml ⚠️Warning Details
reference/7.4/CimCmdlets/New-CimSession.yml ⚠️Warning Details
reference/7.4/CimCmdlets/New-CimSessionOption.yml ⚠️Warning Details
reference/7.4/CimCmdlets/Register-CimIndicationEvent.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Clear-Host.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Enable-PSRemoting.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Get-Command.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Get-Module.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Out-Default.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Out-Host.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Set-PSDebug.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Update-Help.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Core/Where-Object.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Diagnostics/Get-Counter.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Diagnostics/New-WinEvent.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Management/Clear-Item.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Management/Clear-ItemProperty.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Management/Copy-Item.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Management/Copy-ItemProperty.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Management/Debug-Process.yml ⚠️Warning Details
reference/7.4/Microsoft.PowerShell.Management/Get-ChildItem.yml ⚠️Warning Details

This comment lists only the first 25 files in the pull request.

reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md

  • Line 0, Column 0: [Error: MAML2Yaml_LoadFileFailed]
Failed to load file: C:/LocalRun/W/hsf0-s/reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md:468:(948) '```powershell
$test1 = 'TestA'
1..2 | ForEach-Ob...'
 Expect Heading, please try to use PlatyPS validate the content

reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md

  • Line 0, Column 0: [Error: MAML2Yaml_LoadFileFailed]
Failed to load file: C:/LocalRun/W/hsf0-s/reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md:468:(948) '```powershell
$test1 = 'TestA'
1..2 | ForEach-Ob...'
 Expect Heading, please try to use PlatyPS validate the content

reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md

  • Line 0, Column 0: [Error: MAML2Yaml_LoadFileFailed]
Failed to load file: C:/LocalRun/W/hsf0-s/reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md:468:(948) '```powershell
$test1 = 'TestA'
1..2 | ForEach-Ob...'
 Expect Heading, please try to use PlatyPS validate the content

reference/7.4/CimCmdlets/Get-CimInstance.yml

  • Line 23, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Format-Table.yml'.

reference/7.4/CimCmdlets/Get-CimSession.yml

  • Line 22, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Format-Table.yml'.

reference/7.4/CimCmdlets/New-CimSession.yml

  • Line 24, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Security/Get-Credential.yml'.
  • Line 86, Column 5: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Security/Get-Credential.yml'.
  • Line 193, Column 7: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Security/Get-Credential.yml'.

reference/7.4/CimCmdlets/New-CimSessionOption.yml

  • Line 24, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Security/Get-Credential.yml'.
  • Line 26, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Get-Culture.yml'.
  • Line 92, Column 7: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Get-Culture.yml'.

reference/7.4/CimCmdlets/Register-CimIndicationEvent.yml

  • Line 22, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Get-Event.yml'.
  • Line 24, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Remove-Event.yml'.
  • Line 26, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Unregister-Event.yml'.
  • Line 28, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.Powershell.Utility/Write-Host.yml'.
  • Line 65, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Get-Event.yml'.

reference/7.4/Microsoft.PowerShell.Core/Clear-Host.yml

  • Line 26, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Get-Host.yml'.
  • Line 30, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Read-Host.yml'.
  • Line 32, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Write-Host.yml'.

reference/7.4/Microsoft.PowerShell.Core/Enable-PSRemoting.yml

  • Line 264, Column 14: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.WSMan.Management/Set-WSManQuickConfig.yml'.

reference/7.4/Microsoft.PowerShell.Core/Get-Command.yml

  • Line 43, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Export-PSSession.yml'.
  • Line 47, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Get-Member.yml'.
  • Line 51, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Import-PSSession.yml'.

reference/7.4/Microsoft.PowerShell.Core/Get-Module.yml

  • Line 76, Column 9: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Import-PSSession.yml'.
  • Line 301, Column 5: [Warning: file-not-found - See documentation] Invalid file link: '../Microsoft.PowerShell.Utility/Import-PSSession.yml'.

This comment lists only the first 25 errors (including error/warning/suggestion) in the pull request.
For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

For any questions, please:

Copy link

Expectations

Thanks for your submission! Here's a quick note to provide you with some context for what to expect from the docs team and the process now that you've submitted a PR. Even if you've contributed to this repo before, we strongly suggest reading this information; it might have changed since you last read it.

To see our process for reviewing PRs, please read our editor's checklist and process for managing pull requests in particular. Below is a brief, high-level summary of what to expect, but our contributor guide has expanded details.

The docs team begins to review your PR if you request them to or if your PR meets these conditions:

  • It is not a draft PR.
  • It does not have a WIP prefix in the title.
  • It passes validation and build steps.
  • It does not have any merge conflicts.
  • You have checked every box in the PR Checklist, indicating you have completed all required steps and marked your PR as Ready to Merge.

You can always request a review at any stage in your authoring process, the docs team is here to help! You do not need to submit a fully polished and finished draft; the docs team can help you get content ready for merge.

While reviewing your PR, the docs team may make suggestions, write comments, and ask questions. When all requirements are satisfied, the docs team marks your PR as Approved and merges it. Once your PR is merged, it is included the next time the documentation is published. For this project, the documentation is published daily at 3 p.m. Pacific Standard Time (PST).

@surfingoldelephant
Copy link
Contributor Author

surfingoldelephant commented Apr 13, 2025

@sdwheeler I've had a look, but it's not clear to me what's caused those validation errors/warnings.

@surfingoldelephant surfingoldelephant changed the title Update ForEach-Object -Parallel example 17 Update ForEach-Object example 17 to reflect current behavior Apr 13, 2025
Copy link
Contributor

Learn Build status updates of commit 1dcae2e:

✅ Validation status: passed

File Status Preview URL Details
reference/7.4/Microsoft.PowerShell.Core/ForEach-Object.md ✅Succeeded View (powershell-7.4)
reference/7.5/Microsoft.PowerShell.Core/ForEach-Object.md ✅Succeeded View (powershell-7.5)
reference/7.6/Microsoft.PowerShell.Core/ForEach-Object.md ✅Succeeded View (powershell-7.6)

For more details, please refer to the build report.

For any questions, please:

@sdwheeler
Copy link
Collaborator

I've had a look, but it's not clear to me what's caused those validation errors/warnings.

See https://learn.microsoft.com/powershell/scripting/community/contributing/powershell-style-guide#formatting-cmdlet-reference-articles

Within an example, the schema doesn't allow code blocks to be separated by paragraphs.

@sdwheeler sdwheeler merged commit 2a19cbf into MicrosoftDocs:main Apr 13, 2025
4 checks passed
@surfingoldelephant
Copy link
Contributor Author

Thanks Sean!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants