Prior to this change, Group-Object -AsHashtable -CaseSensitive would give a key duplication error when given entries that only differ by casing. This was due to always using a case-insensitive hashtable, despite the request for -CaseSensitive behaviour.
ConciseView shows MyCommand as the prefix to the error message, but for a scriptblock, MyCommand is the whole scriptblock. Fix is to use CategoryInfo.Activity if available first. Also handle case where it's a script function by seeing if it's a command and showing MyCommand in that case rather than the Activity.
* Add -SkipHttpErrorCheck to web request cmdlets
The -SkipHttpErrorCheck flag causes web request cmdlets
(Invoke-WebRequest and Invoke-RestMethod) to ignore HTTP statuses that
are error statuses and treat them as successful requests. This allows
users to handle the responses using their own error handler and gives
them access to the full, unmodified response body and headers.
* Add -ResponseStatusVariable to Invoke-RestMethod
This allows the user to specify a variable to set to the integer value
of the respons's status code, Analogous to using
-ResponseHeadersVariable to retrieve the headers of the response. This
can be used to distinguish error messages from success messages when
used with -SkipHttpErrorCheck.
* Fix coding-style error
The summary for the SkipHttpErrorCheck property didn't conform
to style guidelines. This changes the summary to start with
"Gets or sets".
* Add tests for -SkipHttpErrorCheck
This flag supresses terminating errors on web cmdlets.
The tests are written to check that it properly
supressed the errors.
* Add test for -StatusCodeVariable
Th -StatusCodeVariable parameter specifies an output
variable for the status code with Invoke-RestMethod.
This test makes sure it functions properly.
* Fix typos and style for -SkipHttpErrorCheck tests
Variables had different cases from each other and some parameter
names were lower case.
* Fix typos and style for -StatusCodeVariable test
Variables had different cases from each other and some parameter
names were lower case.
* Add failure tests when missing -SkipHttpErrorCheck
These tests ensure that Web Cmdlets fail when -SkipHttpErrorCheck
is missing.
* Clean up tests for -SkipHttpErrorCheck
Per discussion on the pull requests. This commit fixes up
style problems with the tests for -SkipHttpErrorCheck.
* Add more status tests for -StatusCodeVariable
Previously, the -StatusCodeVariable flag in Invoke-RestMethod
only had tests for 200 status. This commit adds tests for 404
and 500 statuses and removes -SkipHttpErrorCheck from the 200
check.
* Fix response body in -StatusCodeVariable test
The test was copy/pastes from the 200 status test. The body
indicated success. This commit fixes that so it is also an
error indicator.
ConvertTo-Json doesn't allow $null to be passed in even though it can be valid resulting json. Fix is to remove the check that the input is not null. NewtonSoft.Json handles it just fine.
* Enhance enum FileDesiredAccess with zero value GenericZero
* Use the GenericZero as desired access mode to read reparse point without access it
From docs:
If desired access is zero, the application can query certain metadata such as file, directory, or device attributes without accessing that file or device, even if GENERIC_READ access would have been denied
Clear-Host on Unix calls clear command which issues escapes. Before the change we write them to PowerShell output stream and it could be unwantedly intercepted. After the change we write the escapes directly to console.
It turns out this optimization brings in a breaking change: `$MyInvocation` is different comparing to before the optimization change. I tried to fix the breaking change, but couldn't without introducing more hacky code. Given that, that PR should be reverted.
* Update 'Microsoft.PowerShell.CoreCLR.Eventing' to resolve conflicts
* Add reference to 'System.Diagnostics.EventLog' to build Microsoft.PowerShell.Commands.Diagnostics on Unix
* Stop compiling Get/New-WinEvent on Unix
This is based on an issue, where Enter-PSHostProcess on a locked down (WDAC enforced) machine allows any admin to connect to any another local hosted PowerShell process and execute commands as that user. This amounts to privilege escalation on the policy locked down machine and something we want to prevent.
Fix is to check for system lock down and disable Enter-PSHostProcess cmdlet with an error message.