{"id":18036307,"url":"https://github.com/nightroman/powershelltraps","last_synced_at":"2025-04-08T11:09:34.226Z","repository":{"id":30136808,"uuid":"33686880","full_name":"nightroman/PowerShellTraps","owner":"nightroman","description":"Collection of PowerShell traps and oddities","archived":false,"fork":false,"pushed_at":"2025-01-22T02:00:30.000Z","size":690,"stargazers_count":448,"open_issues_count":0,"forks_count":40,"subscribers_count":36,"default_branch":"main","last_synced_at":"2025-04-01T09:33:45.437Z","etag":null,"topics":["issues","powershell","testing"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nightroman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["nightroman"]}},"created_at":"2015-04-09T18:59:48.000Z","updated_at":"2025-03-30T03:31:24.000Z","dependencies_parsed_at":"2024-11-06T19:36:54.370Z","dependency_job_id":"3434b105-c0da-4873-8c70-a3300dcf6968","html_url":"https://github.com/nightroman/PowerShellTraps","commit_stats":{"total_commits":382,"total_committers":3,"mean_commits":"127.33333333333333","dds":0.005235602094240788,"last_synced_commit":"28cb53fd44cdf74ffa446c07b5202db0de9c92d0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FPowerShellTraps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FPowerShellTraps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FPowerShellTraps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FPowerShellTraps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nightroman","download_url":"https://codeload.github.com/nightroman/PowerShellTraps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829498,"owners_count":21002996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["issues","powershell","testing"],"created_at":"2024-10-30T12:12:27.275Z","updated_at":"2025-04-08T11:09:34.205Z","avatar_url":"https://github.com/nightroman.png","language":"PowerShell","funding_links":["https://github.com/sponsors/nightroman"],"categories":[],"sub_categories":[],"readme":"\r\n[TESTS]: ./TESTS.md\r\n[Invoke-PowerShell.ps1]: https://www.powershellgallery.com/packages/Invoke-PowerShell\r\n\r\n*PowerShellTraps* is a collection of some PowerShell traps and oddities shown\r\nby demo scripts, workarounds, and automated tests. On invoking scripts change\r\nto their directory. See also [TESTS]. Some scripts require\r\n[Invoke-PowerShell.ps1].\r\n\r\n---\r\n\r\n## Index\r\n\r\n- [Basic](#basic)\r\n- [Class](#class)\r\n- [Clixml](#clixml)\r\n- [Cmdlets](#cmdlets)\r\n- [Module](#module)\r\n- [PowerShell.exe](#powershellexe)\r\n\r\n## Basic\r\n\r\n\u003c!--Basic--\u003e\r\n- [Operators `-and` and `-or` have the same precedence](Basic/And-and-or-have-same-precedence)\r\n- [Invoking native apps with error output](Basic/App-with-error-output)\r\n- [Automatic variables as parameters or local variables](Basic/Automatic-variables)\r\n- [Break and Continue with not matching label](Basic/Break-and-Continue-with-not-matching-label)\r\n- [Break and Continue without loop](Basic/Break-and-Continue-without-loop)\r\n- [Collection property enumeration](Basic/Collection-property-enumeration)\r\n- [Comparison operators work differently with scalars and collections](Basic/Comparison-operators-with-collections)\r\n- [Compound assignment operators](Basic/Compound-assignment-operators)\r\n- Count-and-Length\r\n    - [Mixed objects](Basic/Count-and-Length/Mixed-objects)\r\n    - [`PSCustomObject` does not have surrogate `Count` and `Length`](Basic/Count-and-Length/PSCustomObject)\r\n    - [`Count` and `Length` of a scalar fail in the strict mode](Basic/Count-and-Length/Strict-Mode)\r\n- [Dictionary Count, Keys, Values may misbehave](Basic/Dictionary-Count-Keys-Values)\r\n- [Different kinds of null](Basic/Different-kinds-of-null)\r\n- [Double quoted strings and sub-expressions with double quotes](Basic/Double-quoted-string)\r\n- DynamicParam\r\n    - [Dynamic switch parameter](Basic/DynamicParam/Dynamic-switch-parameter)\r\n    - [`$MyInvocation.ExpectingInput` is false in `DynamicParam`](Basic/DynamicParam/ExpectingInput-is-false)\r\n- [Enums evaluated to true](Basic/Enums-evaluated-to-true)\r\n- [Enums without `[Flags]` attribute](Basic/Enums-without-FlagsAttribute)\r\n- [Errors of unusual type](Basic/Errors-of-unusual-type)\r\n- [FormatEnumerationLimit](Basic/FormatEnumerationLimit)\r\n- [Function invoked like method](Basic/Function-invoked-like-method)\r\n- [Invocation with odd paths](Basic/Invocation-with-odd-paths)\r\n- [LastExitCode](Basic/LastExitCode)\r\n- [Local action preference variables](Basic/Local-ActionPreference)\r\n- [Magic method `Where`](Basic/Magic-method-Where)\r\n- [Misleading error location](Basic/Misleading-error-location)\r\n- [Missing ternary operator](Basic/Missing-ternary-operator)\r\n- [Negative number literal argument](Basic/Negative-number-literal-argument)\r\n- [Null converted to empty string](Basic/Null-converted-to-empty-string)\r\n- [Number of returned objects](Basic/Number-of-returned-objects)\r\n- [Operators `-match`, `-notmatch` do not reset `$matches`](Basic/Operators-match-notmatch-and-matches)\r\n- [Counter-intuitive equal precedence of some operators](Basic/Operators-with-equal-precedence)\r\n- [Tricky properties of types implementing IDictionary](Basic/Properties-of-IDictionary)\r\n- [Properties of XML nodes](Basic/Properties-of-XmlNode)\r\n- [Provider specific filters](Basic/Provider-specific-Filter)\r\n- [PSCustomObject](Basic/PSCustomObject)\r\n- [`[ref]` may be unwrapped unexpectedly](Basic/PSReference)\r\n- [Directive `#requires`](Basic/Requires)\r\n- [Runspace pool memory leaks with `Close()`](Basic/RunspacePool)\r\n- [Statements are not expressions](Basic/Statements-are-not-expressions)\r\n- [ErrorRecord formatting may fail in the strict mode in the default host](Basic/Strict-mode-ErrorRecord-formatting)\r\n- [String as Boolean](Basic/String-as-Boolean)\r\n- [String constructor](Basic/String-constructor)\r\n- [String equality operators](Basic/String-equality-operators)\r\n- [`switch` is a looping construct](Basic/Switch-is-a-looping-construct)\r\n- [Tempting wrong operators](Basic/Tempting-wrong-operators)\r\n- [`Throw` may not terminate](Basic/Throw-may-not-terminate)\r\n- ThrowTerminatingError\r\n    - [`ThrowTerminatingError` does not trigger the immediate catch](Basic/ThrowTerminatingError/Catch-is-not-called)\r\n    - [`ThrowTerminatingError` produces not true terminating errors](Basic/ThrowTerminatingError/Not-true-terminating)\r\n- [Too simple function names](Basic/Too-simple-function-names)\r\n- [`trap` creates a new scope](Basic/Trap-creates-a-new-scope)\r\n- [`trap` with `continue`](Basic/Trap-with-continue)\r\n- [`trap` with no `break` or `continue`](Basic/Trap-with-no-break-or-continue)\r\n- [`try` and `trap` catch terminating errors](Basic/Try-and-trap-catch-terminating-errors)\r\n- [Unexpected output](Basic/Unexpected-output)\r\n- [Unexpected overloaded method](Basic/Unexpected-overloaded-method)\r\n- [Unrolled collections](Basic/Unrolled-collections)\r\n- [v5 method `new()`](Basic/v5-Method-New)\r\n- [`ValidateScript` and cryptic error messages](Basic/ValidateScript-attribute)\r\n- [ValueFromPipeline used for several parameters](Basic/ValueFromPipeline)\r\n- [Parameters with ValueFromRemainingArguments](Basic/ValueFromRemainingArguments)\r\n- [When `process` block is called](Basic/When-Process-block-is-called)\r\n- [`WildcardPattern.Escape()` does not escape some backticks](Basic/WildcardPattern)\r\n\u003c!--Basic--\u003e\r\n\r\n## Class\r\n\r\n\u003c!--Class--\u003e\r\n- [Attribute with later defined type parameter](Class/Attribute-with-later-defined-type-parameter)\r\n- [Cannot derive a class from another defined later](Class/Cannot-derive-from-defined-later)\r\n- [Cannot derive from dot sourced](Class/Cannot-derive-from-dot-sourced)\r\n- [Identical script blocks issue](Class/Identical-scriptblocks-issue)\r\n- [Methods do not see implicitly created variables](Class/Method-cannot-see-created-variable)\r\n- [Parser fails on custom type](Class/Parser-fails-on-custom-type)\r\n\u003c!--Class--\u003e\r\n\r\n## Clixml\r\n\r\n\u003c!--Clixml--\u003e\r\n- [Cannot write to hidden files](Clixml/Cannot-write-to-hidden-files)\r\n- [Hashtable case sensitivity](Clixml/Hashtable-case-sensitivity)\r\n- [`OrderedDictionary` becomes `Hashtable`](Clixml/OrderedDictionary-becomes-Hashtable)\r\n- [`ScriptBlock` becomes `String`](Clixml/ScriptBlock-becomes-String)\r\n- [No `LiteralPath` in v2](Clixml/v2-no-LiteralPath)\r\n\u003c!--Clixml--\u003e\r\n\r\n## Cmdlets\r\n\r\n\u003c!--Cmdlets--\u003e\r\n- ConvertFrom-Csv\r\n    - [`ConvertFrom-Csv` has undocumented partial comment support](Cmdlets/ConvertFrom-Csv/Partial-comment-support)\r\n- ConvertFrom-Json\r\n    - [`ConvertTo-Json` different number types](Cmdlets/ConvertFrom-Json/Different-number-types)\r\n    - [`ConvertFrom-Json` returns an array not unrolled](Cmdlets/ConvertFrom-Json/Not-unrolled-result)\r\n    - [`ConvertFrom-Json` pipeline input](Cmdlets/ConvertFrom-Json/Piping-content)\r\n- ConvertTo-Json\r\n    - [`ConvertTo-Json` Array as PSObject](Cmdlets/ConvertTo-Json/Array-as-PSObject)\r\n    - [`ConvertTo-Json` without `Compress` may change data](Cmdlets/ConvertTo-Json/v3-Without-Compress)\r\n- Copy-Item\r\n    - [`Copy-Item` - `Exclude` is ignored with `Recurse`](Cmdlets/Copy-Item/Exclude-and-Recurse)\r\n    - [`Copy-Item` inconsistent destination directory](Cmdlets/Copy-Item/Inconsistent-destination)\r\n- [`ForEach-Object`](Cmdlets/ForEach-Object)\r\n- Get-ChildItem\r\n    - [`Get-ChildItem` gets items converted to strings differently](Cmdlets/Get-ChildItem/Different-FileInfo-ToString)\r\n    - [`Get-ChildItem` wildcard-path fails in a directory with backticks](Cmdlets/Get-ChildItem/Directory-with-backticks)\r\n    - [`Get-ChildItem -LiteralPath -Recurse` gets nothing for a directory with brackets](Cmdlets/Get-ChildItem/Directory-with-brackets)\r\n    - [`Get-ChildItem -Recurse` and missing `-Path` unexpected search](Cmdlets/Get-ChildItem/Missing-path-and-Recurse)\r\n    - [`Get-ChildItem -LiteralPath -Recurse` ignores `-Include`](Cmdlets/Get-ChildItem/v5-LiteralPath-Recurse-ignores-Include)\r\n- Get-Content\r\n    - [`Get-Content` with `OutVariable` and `ReadCount`](Cmdlets/Get-Content/OutVariable-and-ReadCount)\r\n- Get-Event\r\n    - [`Get-Event` erratic failures in v2-4](Cmdlets/Get-Event/v2-4-Erratic-failure)\r\n- Get-Item\r\n    - [`Get-Item` fails to get `Cert:`](Cmdlets/Get-Item/Certificate-provider)\r\n    - [`Get-Item` works incorrectly in some locations](Cmdlets/Get-Item/Directory-with-brackets)\r\n- Get-ItemPropertyValue\r\n    - [`Get-ItemPropertyValue` ignores `ErrorAction`](Cmdlets/Get-ItemPropertyValue/ErrorAction-ignored)\r\n- [`Get-Unique` oddities](Cmdlets/Get-Unique)\r\n- Get-WmiObject\r\n    - [`Get-WmiObject` - amended WMI data may fail in the strict mode `Latest`](Cmdlets/Get-WmiObject/Strict-mode-Latest)\r\n- Group-Object\r\n    - [`Group-Object -AsHashTable` and custom expressions](Cmdlets/Group-Object/AsHashTable)\r\n    - [`Group-Object` and properties made by expressions with no values](Cmdlets/Group-Object/Expression-with-no-value)\r\n- [`Import-Csv` may trim leading spaces](Cmdlets/Import-Csv)\r\n- Import-Module\r\n    - [`Import-Module` non-terminating error](Cmdlets/Import-Module/Non-terminating-error)\r\n- Invoke-Expression\r\n    - [`Invoke-Expression` `ErrorAction` is ignored in favour of `$ErrorActionPreference`](Cmdlets/Invoke-Expression/ErrorAction)\r\n- Invoke-RestMethod\r\n    - [`Invoke-RestMethod` returns an array not unrolled](Cmdlets/Invoke-RestMethod/Not-unrolled-result)\r\n- Join-Path\r\n    - [`Join-Path` fails if the path drive does not exist](Cmdlets/Join-Path/Drive-does-not-exist)\r\n    - [`Join-Path` with path separator](Cmdlets/Join-Path/With-path-separator)\r\n- Read-Host\r\n    - [v5 output before `Read-Host`](Cmdlets/Read-Host/v5-Output-before-Read-Host)\r\n- Remove-Item\r\n    - [`Remove-Item -LiteralPath` fails in a directory with brackets](Cmdlets/Remove-Item/Directory-with-brackets)\r\n    - [`Remove-Item` may ignore items specified by `Exclude`](Cmdlets/Remove-Item/Exclude-may-be-ignored)\r\n- [`Remove-ItemProperty -Confirm` fails on 'No' (Registry)](Cmdlets/Remove-ItemProperty)\r\n- Rename-Item\r\n    - [`Rename-Item` has no `LiteralPath` in v2](Cmdlets/Rename-Item/v2-no-LiteralPath)\r\n- Resolve-Path\r\n    - [`Resolve-Path -Path` with wildcards misses hidden items](Cmdlets/Resolve-Path/Wildcards-miss-hidden-items)\r\n- Select-Xml\r\n    - [`Select-Xml -Content` does not support input as stream](Cmdlets/Select-Xml/Content-as-stream)\r\n- Set-Content\r\n    - [`Set-Content` fails in a directory with brackets](Cmdlets/Set-Content/Directory-with-brackets)\r\n    - [`Set-Content` unexpected output location](Cmdlets/Set-Content/Unexpected-output-location)\r\n- [`Split-Path` with UNC paths: mind the current provider](Cmdlets/Split-Path)\r\n- [`Start-Process`](Cmdlets/Start-Process)\r\n- Test-Path\r\n    - [`Test-Path` oddities](Cmdlets/Test-Path/Incorrect-in-odd-location)\r\n    - [`Test-Path -Path` with wildcards misses hidden items](Cmdlets/Test-Path/Wildcards-miss-hidden-items)\r\n- [`Wait-Process` fails if a process name is not found](Cmdlets/Wait-Process)\r\n- [`Where-Object`](Cmdlets/Where-Object)\r\n- [`Write-Debug`](Cmdlets/Write-Debug)\r\n- [`Write-Progress`](Cmdlets/Write-Progress)\r\n\u003c!--Cmdlets--\u003e\r\n\r\n## Module\r\n\r\n\u003c!--Module--\u003e\r\n- [Conflict with aliases](Module/Conflict-with-aliases)\r\n- [Function parent scope](Module/Function-parent-scope)\r\n- [Not found function](Module/Not-found-function)\r\n- [Not found function (part 2)](Module/Not-found-function-2)\r\n- [Not found variable](Module/Not-found-variable)\r\n- [Script block scope](Module/Script-block-scope)\r\n- [How to set a variable in the caller scope](Module/Set-variable-in-caller-scope)\r\n- [Strict mode is not propagated](Module/Strict-mode-is-not-propagated)\r\n- [v2 does not support the manifest field `RootModule`](Module/v2-Manifest-RootModule-is-not-supported)\r\n\u003c!--Module--\u003e\r\n\r\n## PowerShell.exe\r\n\r\n\u003c!--PowerShell.exe--\u003e\r\n- [Exit code 0 with Command syntax error](PowerShell.exe/Exit-code-0-with-Command-syntax-error)\r\n- [Exit code 0 with File script error](PowerShell.exe/Exit-code-0-with-File-script-error)\r\n- [Exit code 5 with File, 1 with Command](PowerShell.exe/Exit-code-5-with-File-1-with-Command)\r\n- [Exit code depends](PowerShell.exe/Exit-code-depends)\r\n- [Global and script scope](PowerShell.exe/Global-and-script-scope)\r\n- [Not current version](PowerShell.exe/Not-current-version)\r\n- [Different positional parameters in powershell and pwsh](PowerShell.exe/Positional-Command-File)\r\n- [Switch parameter with value](PowerShell.exe/Switch-parameter-with-value)\r\n- [Unexpected start location](PowerShell.exe/Unexpected-start-location)\r\n- [v3 interactive issues](PowerShell.exe/v3-Interactive-issues)\r\n- [Parameter `Version` must be the first.](PowerShell.exe/Version-parameter)\r\n- [`Version` and scriptblock host problem](PowerShell.exe/Version-scriptblock-host-problem)\r\n\u003c!--PowerShell.exe--\u003e\r\n\r\n---\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2Fpowershelltraps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightroman%2Fpowershelltraps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2Fpowershelltraps/lists"}