forked fromnightroman/PowerShellTraps
- Notifications
You must be signed in to change notification settings - Fork0
Collection of PowerShell traps and oddities
License
NotificationsYou must be signed in to change notification settings
sdwheeler/PowerShellTraps
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
PowerShellTraps is a collection of some PowerShell traps and oddities shownby demo scripts, workarounds, and automated tests. On invoking scripts changeto their directory. See alsoTESTS. Some scripts requireInvoke-PowerShell.ps1.
- Operators
-andand-orhave the same precedence - Invoking native apps with error output
- Automatic variables as parameters or local variables
- Break and Continue with not matching label
- Break and Continue without loop
- Collection property enumeration
- Comparison operators work differently with scalars and collections
- Compound assignment operators
- Count-and-Length
- Dictionary Count, Keys, Values may misbehave
- Different kinds of null
- Double quoted strings and sub-expressions with double quotes
- DynamicParam
- Enums evaluated to true
- Enums without
[Flags]attribute - Errors of unusual type
- FormatEnumerationLimit
- Function invoked like method
- Invocation with odd paths
- LastExitCode
- Local action preference variables
- Magic method
Where - Misleading error location
- Missing ternary operator
- Negative number literal argument
- Null converted to empty string
- Number of returned objects
- Operators
-match,-notmatchdo not reset$matches - Counter-intuitive equal precedence of some operators
- Tricky properties of types implementing IDictionary
- Properties of XML nodes
- Provider specific filters
- PSCustomObject
[ref]may be unwrapped unexpectedly- Directive
#requires - Runspace pool memory leaks with
Close() - Statements are not expressions
- ErrorRecord formatting may fail in the strict mode in the default host
- String as Boolean
- String constructor
- String equality operators
switchis a looping construct- Tempting wrong operators
Throwmay not terminate- ThrowTerminatingError
- Too simple function names
trapcreates a new scopetrapwithcontinuetrapwith nobreakorcontinuetryandtrapcatch terminating errors- Unexpected output
- Unexpected overloaded method
- Unrolled collections
- v5 method
new() ValidateScriptand cryptic error messages- ValueFromPipeline used for several parameters
- Parameters with ValueFromRemainingArguments
- When
processblock is called WildcardPattern.Escape()does not escape some backticks
- Attribute with later defined type parameter
- Cannot derive a class from another defined later
- Cannot derive from dot sourced
- Identical script blocks issue
- Methods do not see implicitly created variables
- Parser fails on custom type
- Cannot write to hidden files
- Hashtable case sensitivity
OrderedDictionarybecomesHashtableScriptBlockbecomesString- No
LiteralPathin v2
- ConvertFrom-Csv
- ConvertFrom-Json
- ConvertTo-Json
- Copy-Item
ForEach-Object- Get-ChildItem
Get-ChildItemgets items converted to strings differentlyGet-ChildItemwildcard-path fails in a directory with backticksGet-ChildItem -LiteralPath -Recursegets nothing for a directory with bracketsGet-ChildItem -Recurseand missing-Pathunexpected searchGet-ChildItem -LiteralPath -Recurseignores-Include
- Get-Content
- Get-Event
- Get-Item
- Get-ItemPropertyValue
Get-Uniqueoddities- Get-WmiObject
- Group-Object
Import-Csvmay trim leading spaces- Import-Module
- Invoke-Expression
- Invoke-RestMethod
- Join-Path
- Read-Host
- Remove-Item
Remove-ItemProperty -Confirmfails on 'No' (Registry)- Rename-Item
- Resolve-Path
- Select-Xml
- Set-Content
Split-Pathwith UNC paths: mind the current providerStart-Process- Test-Path
Wait-Processfails if a process name is not foundWhere-ObjectWrite-DebugWrite-Progress
- Conflict with aliases
- Function parent scope
- Not found function
- Not found function (part 2)
- Not found variable
- Script block scope
- How to set a variable in the caller scope
- Strict mode is not propagated
- v2 does not support the manifest field
RootModule
- Exit code 0 with Command syntax error
- Exit code 0 with File script error
- Exit code 5 with File, 1 with Command
- Exit code depends
- Global and script scope
- Not current version
- Different positional parameters in powershell and pwsh
- Switch parameter with value
- Unexpected start location
- v3 interactive issues
- Parameter
Versionmust be the first. Versionand scriptblock host problem
About
Collection of PowerShell traps and oddities
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Languages
- PowerShell99.3%
- Other0.7%