René's URL Explorer Experiment


Title: Rule request: Warning if `Set`/`Get-Variable` is invoked with only the basic `-Name`/`-Value` parameters · Issue #1706 · PowerShell/PSScriptAnalyzer · GitHub

Open Graph Title: Rule request: Warning if `Set`/`Get-Variable` is invoked with only the basic `-Name`/`-Value` parameters · Issue #1706 · PowerShell/PSScriptAnalyzer

X Title: Rule request: Warning if `Set`/`Get-Variable` is invoked with only the basic `-Name`/`-Value` parameters · Issue #1706 · PowerShell/PSScriptAnalyzer

Description: Referring to StackOverflow questions along with: How do I automaticaly create and use variable names?. The cmdlets: Get-Variable Set-Variable New-Variable Could completely mislead a novice PowerShell scripter in a wrong programming direc...

Open Graph Description: Referring to StackOverflow questions along with: How do I automaticaly create and use variable names?. The cmdlets: Get-Variable Set-Variable New-Variable Could completely mislead a novice PowerShe...

X Description: Referring to StackOverflow questions along with: How do I automaticaly create and use variable names?. The cmdlets: Get-Variable Set-Variable New-Variable Could completely mislead a novice PowerShe...

Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1706

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Rule request: Warning if `Set`/`Get-Variable` is invoked with only the basic `-Name`/`-Value` parameters","articleBody":"Referring to StackOverflow questions along with: [How do I automaticaly create and use variable names?](https://stackoverflow.com/q/68827910/1701026).\r\n\r\nThe cmdlets:\r\n* [`Get-Variable`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-variable)\r\n* [`Set-Variable`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-variable)\r\n* [`New-Variable`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/new-variable)\r\n\r\nCould completely mislead a novice PowerShell scripter in a wrong programming direction.\r\n\r\nThe general learning process of a scripter/programmer is playing with variables. Than it gets extended to list of variables like `$Var1 = 'One'`, `$Var2 = 'Two'`, .... The list extends further and they understand they need to automate this somehow but finding guidance for this is quiet a leap and if they ask for guidance at e.g. StackOverflow they often get a direct answer/comment in the direction of using one of these `\u003cverb>-Variable` cmdlets which is not a good practice for these users and what they atempt to do or learn.\r\n\r\nAfaik, there is no good reason to use one of these `\u003cverb>-Variable` cmdlets which just `-Name` and `-Value` parameters.\r\n\r\ne.g. `Get-Variable MyVar` can be replaced by `$MyVar` and  `Set-Variable MyVar 'Test'` can be replaced by `$MyVar = 'Test'`\r\n\r\nThe only other reason to use just the `-Name` and `-Value` parameters is to create dynamic variable names ([**variable indirection**](https://stackoverflow.com/a/68214332/1701026)) like:\r\n\r\n```PowerShell\r\nSet-Variable \"Var$i\" 'Test'\r\n```\r\nWhich is to my opinion a bad practice as they will be added to the same dictionary as the rest of the parameters and one might easily overwrite other general variables and lose the oversight.\r\n\r\n**Summary of the new feature**\r\n\r\nWhen it comes to creating a dynamic variables, a separated dictionary (in the form of a [hashtable](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables)) should be created and a warning/hint could be given in that direction.\r\n\r\nVisa verse, advanced users that know what they are doing, might simply avoid the warning by adding a specific (e.g. `-Scope Script`) parameter.\r\n\r\n**What is the latest version of PSScriptAnalyzer at the point of writing**\r\n`1.19.1`","author":{"url":"https://github.com/iRon7","@type":"Person","name":"iRon7"},"datePublished":"2021-08-19T14:24:13Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1706"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2c52e6ab-06c1-665a-ed24-8b45ee98f2f0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC5DA:266BB:14EC2FA:1D7AE36:6AFCE686
html-safe-nonce5db2ec99744d4bfe5d371ac5f0e12d5f353cca79dc536f4b89d4f769c8661081
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNURBOjI2NkJCOjE0RUMyRkE6MUQ3QUUzNjo2QUZDRTY4NiIsInZpc2l0b3JfaWQiOiIyNDk5MzkwMzk5MzI4MzQ3NzgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac43398df8d5219632015957355ab6d4112677ef1d2869f51bcf3c11504c0560f7
hovercard-subject-tagissue:974720029
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1706/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c0761acdfa058eebb0b8307330f809e994c501b550681c8ed4948925ef1aac50/PowerShell/PSScriptAnalyzer/issues/1706
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c0761acdfa058eebb0b8307330f809e994c501b550681c8ed4948925ef1aac50/PowerShell/PSScriptAnalyzer/issues/1706
og:image:altReferring to StackOverflow questions along with: How do I automaticaly create and use variable names?. The cmdlets: Get-Variable Set-Variable New-Variable Could completely mislead a novice PowerShe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameiRon7
hostnamegithub.com
expected-hostnamegithub.com
None99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id33149177
octolytics-dimension-repository_nwoPowerShell/PSScriptAnalyzer
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33149177
octolytics-dimension-repository_network_root_nwoPowerShell/PSScriptAnalyzer
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseecfd63ca125ec74b42f74eeb158b3fa081c8c497
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PSScriptAnalyzer/issues/1706#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F1706
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F1706
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPSScriptAnalyzer
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/1706
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/1706
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/1706
PowerShellhttps://github.com/PowerShell
PSScriptAnalyzerhttps://github.com/PowerShell/PSScriptAnalyzer
Codehttps://github.com/PowerShell/PSScriptAnalyzer
Issues407 (407)https://github.com/PowerShell/PSScriptAnalyzer/issues
Pull requests34 (34)https://github.com/PowerShell/PSScriptAnalyzer/pulls
Discussionshttps://github.com/PowerShell/PSScriptAnalyzer/discussions
Actionshttps://github.com/PowerShell/PSScriptAnalyzer/actions
Projectshttps://github.com/PowerShell/PSScriptAnalyzer/projects
Wikihttps://github.com/PowerShell/PSScriptAnalyzer/wiki
Security and qualityhttps://github.com/PowerShell/PSScriptAnalyzer/security
Insightshttps://github.com/PowerShell/PSScriptAnalyzer/insights
https://github.com/PowerShell/PSScriptAnalyzer
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1706
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1706
Rule request: Warning if Set/Get-Variable is invoked with only the basic -Name/-Value parametershttps://github.com/PowerShell/PSScriptAnalyzer/issues/1706#top
Area - Ruleshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Rules%22
Issue - New Rulehttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20New%20Rule%22
Up-for-Grabshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Up-for-Grabs%22
https://github.com/iRon7
iRon7https://github.com/iRon7
on Aug 19, 2021https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#issue-974720029
How do I automaticaly create and use variable names?https://stackoverflow.com/q/68827910/1701026
Get-Variablehttps://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/get-variable
Set-Variablehttps://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/set-variable
New-Variablehttps://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/new-variable
variable indirectionhttps://stackoverflow.com/a/68214332/1701026
hashtablehttps://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_hash_tables
Needs: Triage 🔍https://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Needs%3A%20Triage%20%3Amag%3A%22
on Aug 19, 2021https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#event-5181040097
https://github.com/rjmholt
Rob Holt (rjmholt)https://github.com/rjmholt
on Aug 19, 2021https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#issuecomment-902087458
Rob Holt (rjmholt)https://github.com/rjmholt
Area - Ruleshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Rules%22
Issue - New Rulehttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20New%20Rule%22
Up-for-Grabshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Up-for-Grabs%22
Needs: Triage 🔍https://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Needs%3A%20Triage%20%3Amag%3A%22
on Aug 19, 2021https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#event-5182169007
https://github.com/iRon7
iRon7https://github.com/iRon7
on Aug 29, 2023https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#issuecomment-1697830615
https://github.com/iRon7/PSRuleshttps://github.com/iRon7/PSRules
iRon7https://github.com/iRon7
on May 5, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#event-25188123074
Merge branch 'main' into PowerShell#1706-AvoidDynamicVariableNames2https://github.com/iRon7/PSScriptAnalyzer/commit/a20bdf5b7b8c55cc79695ed20d30c06f9fd47398
PowerShell#1706https://github.com/PowerShell/PSScriptAnalyzer/issues/1706
a20bdf5https://github.com/iRon7/PSScriptAnalyzer/commit/a20bdf5b7b8c55cc79695ed20d30c06f9fd47398
iRon7https://github.com/iRon7
on May 17, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/1706#event-25623118560
Merge branch 'main' into PowerShell#1706-AvoidDynamicVariableNames2https://github.com/iRon7/PSScriptAnalyzer/commit/578d02f0f727130619186b1e1a475c49460d23f6
PowerShell#1706https://github.com/PowerShell/PSScriptAnalyzer/issues/1706
578d02fhttps://github.com/iRon7/PSScriptAnalyzer/commit/578d02f0f727130619186b1e1a475c49460d23f6
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1706
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/1706
Area - Ruleshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Area%20-%20Rules%22
Issue - New Rulehttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20New%20Rule%22
Up-for-Grabshttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Up-for-Grabs%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.