Skip to content

Add reason for AvoidGlobalVars#426

Merged
sdwheeler merged 5 commits into
MicrosoftDocs:mainfrom
sdwheeler:sdw-w426224-why-AvoidGlobalVars
Jun 23, 2026
Merged

Add reason for AvoidGlobalVars#426
sdwheeler merged 5 commits into
MicrosoftDocs:mainfrom
sdwheeler:sdw-w426224-why-AvoidGlobalVars

Conversation

@sdwheeler

@sdwheeler sdwheeler commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

PR Summary

Add reason for AvoidGlobalVars

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.

Copilot AI review requested due to automatic review settings June 23, 2026 19:55
@learn-build-service-prod

Copy link
Copy Markdown

Learn Build status updates of commit f854fcc:

✅ Validation status: passed

File Status Preview URL Details
reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md ✅Succeeded View (ps-modules)
reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md ✅Succeeded View (ps-modules)
reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md ✅Succeeded View (ps-modules)

For more details, please refer to the build report.

@learn-build-service-prod

Copy link
Copy Markdown

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates PSScriptAnalyzer documentation, primarily by expanding the rationale for the AvoidGlobalVars rule, and also by adjusting/modernizing several PowerShell code samples in related articles.

Changes:

  • Adds explanatory rationale text and updates examples for AvoidGlobalVars.
  • Normalizes formatting in UseApprovedVerbs example snippets.
  • Refactors and updates multiple guidance/sample-code sections in create-custom-rule.md (including output type wording and example rule function).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md Formatting-only tweak to the PowerShell examples.
reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md Adds rationale text and rewrites the compliant/noncompliant examples.
reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md Updates guidance wording and significantly revises sample code for custom rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md
Comment thread reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md Outdated
Comment thread reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md
Comment thread reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md
Comment on lines 78 to +82
$result = [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord[]]@{
"Message" = "This is a sample rule"
"Extent" = $ast.Extent
"RuleName" = $PSCmdlet.MyInvocation.InvocationName
"Severity" = "Warning"
Message = 'This is a sample rule'
Extent = $ast.Extent
RuleName = $PSCmdlet.MyInvocation.InvocationName
Severity = 'Warning'
Comment thread reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md
Comment thread reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md
Comment thread reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md Outdated
Comment thread reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@learn-build-service-prod

Copy link
Copy Markdown

Learn Build status updates of commit e1a0027:

❌ Validation status: errors

Please follow instructions here which may help to resolve issue.

File Status Preview URL Details
❌Error Details

  • [Error: CannotMergeCommit] Cannot merge commit e1a0027115a9808326f3397cf9ca5e4024c619fe in branch sdw-w426224-why-AvoidGlobalVars of repository https://github.com/sdwheeler/PowerShell-Docs-Modules into branch main (commit cbf290cfeb7bac344a0dae521f108c7955cf44e8). Please follow this documentation: https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/ to use git.exe to resolve you content conflicts locally and then push to remote.

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.

@learn-build-service-prod

Copy link
Copy Markdown

PoliCheck Scan Report

The following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans.

✅ No issues found

More information about PoliCheck

Information: PoliCheck | Severity Guidance | Term
For any questions: Try searching the learn.microsoft.com contributor guides or post your question in the Learn support channel.

@learn-build-service-prod

Copy link
Copy Markdown

Learn Build status updates of commit 7cb011f:

✅ Validation status: passed

File Status Preview URL Details
reference/docs-conceptual/PSScriptAnalyzer/create-custom-rule.md ✅Succeeded View (ps-modules)
reference/docs-conceptual/PSScriptAnalyzer/Rules/AvoidGlobalVars.md ✅Succeeded View (ps-modules)
reference/docs-conceptual/PSScriptAnalyzer/Rules/UseApprovedVerbs.md ✅Succeeded View (ps-modules)

For more details, please refer to the build report.

@sdwheeler
sdwheeler merged commit 980f86d into MicrosoftDocs:main Jun 23, 2026
4 checks passed
@sdwheeler
sdwheeler deleted the sdw-w426224-why-AvoidGlobalVars branch June 23, 2026 20:33
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