PowerShell -v behavior updated to align with other tools like git, curl, and bash where args after -v are silently ignored.
Built-in help updated to reflect changes we've made to the console host in PSCore6 removing unsupported parameters.
* [feature]
removed test that is no longer valid due to change in -version behavior to return error
* [feature]
fixed `-v X` so that it errors out correctly with proper exit code
updated test to catch this
* [feature]
address PR feedback
* [feature]
make -v have behavior consistent with other tools like git, curl, bash where args after -v are ignored
removed duplicate but not exactly help text that wasn't being used in the resource file
removed parameters from help that are not support in PSCore6
The code in `AssemblyLoadContext.dll` doesn't need to be in a separate DLL anymore.
S.M.A.dll depends on `AssemblyLoadContext.dll`, so keeping that code out of S.M.A.dll doesn't help make S.M.A smaller size or less dependent. So the code in `AssemblyLoadContext.dll` is moved to `S.M.A.dll` and then we remove `AssemblyLoadContext.dll`.
The changes are:
- Move `CorePsAssemblyLoadContext.cs` to `src\S.M.A\CoreCLR\`
- Update `CorePsAssemblyLoadContext.cs` to get the test took moved to `Utils.InternalTestHooks` and update tests
- Update `build.psm1` and `.csproj` accrodingly
- Update `pwrshcommon.cpp` to remove `AssemblyLoadContext.dll` from the TPA list.
- `S.M.A.AssemblyExtensions` is removed as `PackageManagement` has finished their move to .NET Core 2.0. (I will work with Bryan to get the latest version uploaded to powershell-core)
It's to solve a side-by-side problem we have with powershell core. If a .NET Core version assembly has the same name as it's .NET ancestor in GAC, then even if you specify the file path to `Import-Module`, powershell core will still load the one in GAC because it tries 'Assembly.Load' first.
Now we change it to use `Assembly.LoadFrom` first when a file path is given, so it works for modules that have side-by-side assemblies.
Transcription was relying on reading the screen buffer to record output from native commands.
This resulted in an unhandled exception calling an unimplemented API on non-Windows.
The fix is to use redirected output/error if reading the screen buffer is not supported.
We check whether screen scraping is supported or not only when the application is running standalone.
A number of tests require the sources to be present in order to work correctly.
During cleanup be sure to remove any lingering powershell.exe processes because subsequent runs will not be able to update the test binaries.
* Add file secret suppression
* Add line secret suppression
* This will be consumed in the VSTS daily build.
* Renamed tests with ConvertTo-SecureString to avoid false positives
* Change UserAgent App WindowsPowerShell -> PowerShell
* [Feature] Run Feature tests
* [feature] Address PR Feedback with more precise assertion
* [feature] Address PR Feedback and add PSUserAgent Test
* [feature] add tag to describe block
* [feature] Remove describe block Add pattern to User-Agent specific tests
* [feature] Address PF Feedback
Remove all assertions for User-Agent that are not specifically about the User-Agent header.
* [feature] Match -> MatchExactly
- Add tests for remote import-module
- Fix issue with remotely importing module where it was checking the version filter incorrectly against the proxy module
- The filters are applied when importing the module remotely
- After proxy module is generated it always has a module version of 1.0, so the filters will always fail when importing the proxy locally
- add ending newline to files missing it using:
`awk -F: '$2 ~ / no line terminators/ {print $1}' ~/text-files.txt | xargs -I{} sh -c 'printf "\n" >> "$1"' - {}`
- update .gitattributes to enforce autocrlf on all text files
- added <copyright> opening element where it was missing
removed file attribute pointing to wrong filename
- fix mis-encoded character to apostrophe
- replace incorrect encoding of copyright symbol with (c)
- updated file hashes in the test
* [feature]
allow * to be used in registry path for remove-item
* [feature]
address PR feedback
have remove-item return error if -literalpath doesn't resolve to path
* [feature]
fix in navigation exposed an issue with WSMan Config Provider tests
that require -Recurse to be used otherwise a confirmation prompt shows
up
- Add 'ArgumentCompletionsAttribute' to support argument completion for parameters that cannot have a ValidateSetAttribute.
- Use 'ArgumentCompletionsAttribute' for the '-Format' parameter of 'Get-Date' to enable useful argument compeltions.
* [Feature]Remove-Service added to Management module
* [Feature]Capitalization
* [Feature]Added test cases for Remove-Service, Removed return value
* [Feature]Documentation from copy-paste code corrected to reflect the new function
* [Feature]Erroraction to be sure that an error is thrown in testcase
* [Feature]Removed direct reference to module in Pester test
* [Feature]Removed extra line in test
* [Feature]Use FullyQualifiedErrorId in Remove-Service test without a valid servicename
* [Feature]Exposed Remove-Service
* [Feature]Consistent casing, Named Arguments & Remove incorrect exception on cleanup
* [Feature]Remove-Service test should fail if the service was not removed
* [Feature]Cleanup comments & add Remove-Service for CI
* [Feature]Remove-Service in CI set in alphabetic order
* [Feature]Use ParameterSetName instead of _ParameterSetName and rewrite test which used the function class directly
* Revert "[Feature]Use ParameterSetName instead of _ParameterSetName and rewrite test which used the function class directly"
This reverts commit da41f7deb8.
* [Feature]Remove _ParameterSetName check & added test for pipeline input in
Set-Service
When handling file redirection for CommandExpression, we don't call 'DoComplete' on the underlying PipelineProcessor of the FileRedirection object, and thus the EndProcessing method is not called on Out-File, which causes different behaviors between <expr> > out.txt and <expr> | Out-File out.txt.
The fix is to make sure 'DoComplete' is called after the stream output has been written to the redirection pipe.
Also fix another issue
This PR also fixes an issue that could mess up restoring the original pipes. Here is the repro:
PS> 1 *> b.txt > a.txt; 123
Cannot perform operation because object "PipelineProcessor" has already been disposed
The root cause is that we don't always restore pipes in the correct order. Please see the code changes in Compiler.cs for more details.
Fix#4812
* Add tests for Get-Content -Tail #4150
* Incorporated the review comments
* renamed couple of tests
* removed extra spaces
* Tests refactored into a Context and the checks broken down into separate tests
* Made the indents consistent with the other existing tests
* Incorporated the review comments
* [Feature]
fixed issues in WSMan Config Provider
added tests for get-item, get-childitem, set-item, new-item remove-item, clear-item, dynamic parameters
merged CoreClr and FullClr code
* [feature]
address PR feedback
* [feature]
revert to using microsoft.powershell plugin as base for test
keeps it simple rather than relying on additional scripts or cmdlets since these tests don't require remoting
* [feature]
address Aditya's feedback
* [feature]
address some cosmetic feedback
* [feature]
based on discussion with Jim, we should skip resx checks on non-Windows
* Updated default ModuleVersion in ModuleManifest to 0.0.1
* updates tests where manifests default versions where still matched agianst the old 1.0 version
* Add '-ErrorAction Stop' in Set-Service.Tests.ps1 to correctly test exceptions.
* Refactor StartupType service code and add a throw for disabled startup types (System, Boot).
* Made StartupType(-1) equivalent to Win32 SERVICE_NO_CHANGE.
* A simple and minimal fix of 4665 to check for the Visual Studio C++ 2015 redistributables. Note that this is specific to 2015 (vcruntime140.dll refers to the Visual Studio version 14.0, which maps to Visual Studio 2015).
A previous check registry check of 'SOFTWARE\Microsoft\DevDiv\VC\Servicing\14.0\RuntimeMinimum' failed because when the redistributables are installed via Windows update (which does not use MSI), then the registry entry did not get populated.
The 'Pending' attribute was removed from existing tests since the download links are now present again and the tests were improved using Pester TestCases.
* Fixed typo spotted in code review of PR 4745
* Remove DirectorySearch Id duplication by defining it once and referencing according to this special trick in the official WiX documentation here: http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/directorysearchref.html
Renamed property values as suggested.
* Remove replacements of HTTPS with HTTP, i.e. test against exact link. Use -UseBasicParsing switch with the hope of not having failures in the CI environment.
Added comment why there is no assertion about the StatusCode.
* Replace download links with link to pre-requisites page as suggested in PR 4745 because this page is easier to update
* Compilation error CNDL0012 fix: WiX does not allow lowercase characters for file search property Ids because due to them being used for a search property means that they must be public, hence lowercase is not allowed.
These two tests have been failing on CentOS for some time. It is because the available libcurl library does not support client authentication certificates
This change mitigates intermittent timeout failures in the access denied tests as well as fixes unintended cross-test dependencies. If PowerShell takes longer that 10 seconds to complete a race can cause the subsequent test to pick up the output file of the previous test and fail (i.e., the expected output error file already exists from the previous test because it was created by the long running PowerShell process after the second test started.) Worse case, the failure cascades causing the race to propagate through the remaining tests in the set.
The fix is two fold:
1: Increase the timeout for waiting for the launched powershell process. (mitigation)
2: Ensure each uses a unique name for the error and done files to avoid polluting the next test.
Partially implements #2112
- Adds `System.Net.Http.MultipartFormDataContent` as a possible type for `-Body`
- Adds `/Multipart/` test to WebListener
This allows for the user to create their own `Http.MultipartFormDataContent` object and submit it. Since `multipart/form-data` submissions are highly flexible, adding direct support for it to the CmdLets may over-complicate the command parameters and a limited implementation would not address the broad scope of use cases. This at least allows the user to submit multipart forms using the Web Cmdlets and not have to manage their own `HttpClient`. Once this is introduced, limited multipart implementations can be expanded to use the code in this PR.
* Add -WhatIf switch to Start-Process cmdlet
* Add test for the -WhatIf switch
* Added a test to ensure that using a whatif switch prevents the action from being performed.
* Incorporated code review comments
* merged two tests into one as suggested
* Included the error action at the end of the cmdlet
* Remove extra space before `StringUtil` and new line
* Renamed the resource string id ProcessStartInfo to StartProcessTarget
* Adds the /Get/ functionality to Weblistener
* Replaces the tests that rely on httpbin.org/get with WebListener
* [Feature] Move HttpBin/Get Tests to WebListener
* [Feature] update .spelling
* [Feature] Address PR Feedback
* [Feature] Add and document Home & /
* Readme Update
* [Feature] Should Match -> Should Be
Rerun CI
* [Feature] Rebase and Rerun CI
When dotting a script cmdlet, the locals of automatic variables from the `PSScriptCmdlet` is not set up in the current scope before parameter binding. The fix is to push the locals in `CommandProcessor.OnSetCurrentScope` and pop them in `CommandProcessor.OnRestorePreviousScope`, which will be called from `SetCurrentScopeToExecutionScope` and `RestorePreviousScope` respectively.
Summary of changes:
1. When a new local scope is used, currently we set the locals for `CommandProcessor` right before parameter binding (in `BindCommandLineParametersNoValidation`); we set the locals for `ScriptCommandProcessor` in `Prepare`. I moved both to the constructor, right after the new scope is created so that the code is more consistent.
2. In `CmdletParameterBinderController.cs`, we set up the `PSBoundParameters` and `MyInvocation` variables in `HandleCommandLineDynamicParameters` again, which I think is unnecessary because this method is only called from `BindCommandLineParametersNoValidation`, where the setup is done for the first time.
3. Currently, the locals will be set for dotted script cmdlet in `EnterScope()` and `ExitScope()`. Now, that logic is moved to `OnSetCurrentScope` and `OnRestorePreviousScope` of `CommandProcessor`. This not only makes sure that locals are set before parameter binding, but also is consistent with the `ScriptCommandProcessor`.
* Make count of tests the same between Windows and Non-Windows platforms
Change logic so test cases are created for all platforms, but only load the helper module on windows
* Ensure Get-ComputerInfo tests run the same number of tests regardless of platform
Update pull-request-process to clarify role/responsibility of author and reviewers based on recent feedback from team and community. Also moved it to `.github/CONTRIBUTING.md` so that all related information can be found at one place.
`Compiler.LoadModule` assumes that when `ps.HadErrors == true` the error stream is not empty. However, when `SilentlyContinue` is specified as the error action, the non-terminating error is not kept in `ErrorOutputPipe` of the cmdlet and thus does not appear in `ps.Streams.Error`. So when `ps.HadErrors == true` while `ps.Streams.Error` is empty, it suggests it's OK to ignore the errors because they are explicitly suppressed with `SilentlyContinue` error action.
So in my opinion, the expected behavior of `"using module .\mod.psm1"` in this case should be successful as if `ps.HaddErrors` is false.
This change removes the call to `ContentHelper.GetEncoding` since it's logic for returning a default encoding when a ContentType header is not found disables subsequent checks for meta charset definitions.
All variations of the Invoke-WebRequest tests have been mirrored for Invoke-RestMethod. Verbose output is used to verify the encoding since Invoke-RestMethod returns the JSON content directly instead of a response object. (See ExecuteRestMethod)
Introduce new test module 'WebListener.psm1'.
Now web HTTPS tests can use it to exclude using external sites.
PowerShell/PowerShell#4609
* [Feature] Add Tests for Web Cmdlet Certificate Authentication
PowerShell/PowerShell#4609
* [feature] Add new app to Publish-PSTestTools refactor tests
also add ASP.NET to .spelling
* [feature] spelling fix
* [feature] revert badssl changes
* [feature] Impliment suggestions
* [feature] Spelling, var rename, port 8443 to 8083
rebase fix conflict
* [feature] Rename to HttpsListener and Module-ize
.
* [feature] password protect ClientCert to fix macOS import issue
* [feature] Rename to WebListener
* Rename HttpsListener to WebListener
* Switch Listener from Razor pages to MVC
* Address PR feedback
* Adjust tests
* [feature] Address PR feedback
* [feature] Replace missing smeicolons
* [feature] Address PR Feedback
* [feature] Cleanup and minor fix
* Enum was not used
* GetStatus() was not accessing the correct property chain
* Added -Test param to make URL generation smoother in test code and to fix double / issues
* [feature] More minor fixes
* Https when it matters.
* Expand property... not exclude..
* Remove superfluous and outdated ToString() override
* [Feature] Move ClientCeret.pfx to WebListener Module
* Move the cert
* Adjust Get-WebListenerClientCertificate
* Remove cert from csproj
* ActionResult -> JsonResult (was mistakenly left as ActionResult during testing)..
* [Feature] Move ServerCert.pfx to Module
* Move cert
* Upate csproj
* Update module
* Add/Update README.md's
CI Retest.
* AlternateStreams support relies on pinvoke to win32 APIs which don't work on non-Windows and produces errors about not loading a DLL in the case of copy-item
* Address PR feedback, remove -Stream parameter for Unix added new -stream tests
* if/def out alternate stream syntax checks not applicable to Unix
GetMember/SetMember/InvokeMember operations on a COM object will generate code to unwrap the COM object if it's wrapped in PSObject. Due to a loose restriction, if you have a string wrapped to a PSObject with an ETS member of the same name, then the string PSObject will be unwrapped too and the ETS member will be lost. The fix is to use a more restricted rule by checking if the base object is a COM object.
* #4458 MSI installer checks that the Windows C Runtime and VS Studio 2015 C++ redistributables are present and returns error message if not.
Includes tests to check that the Wix file contains the download URLs and those URLs are not dead.
It is now possible to see the coverage based on the file and then format
the data so a report generator is not needed. You can map the files from
one location to another, so if you have a copy of the repo, but in a different
location, you can still format the output in a way so it may be studied
* Make invalid arg to -File consistent with -Command
Improve error message if ambiguous arg is passed to -File
* Update powershell console exit codes to match Unix standards
* Enable -WindowStyle to work
Create custom CIM classes (via MOF) and CDXML cmdlets against the new CIM class
Create tests for CRUD operations for CDXML cmdlets
Coverage for Microsoft.PowerShell.Cmdletization namespace is nearly 50%
* update tests to include -TestCase paramater in It block
* Move test functions to appropriate context blocks
* combine skipTest conditions
* move skipTest to Describe block
* correct typo, change to MatchExactly
1. The individual test files (.ps1) in `/test/powershell/engine` are moved to the corresponding subfolders.
2. The test asset file `test/powershell/Common/TestTypeFile.ps1xml` is moved to `test/powershell/Common/engine/Api/assets/` so that it's next to the test that is using the file.
* Clean up ShellExecuteHelper and enable ShellExecute in NativeCommandProcessor
* Minor fix
* [Feature] Fix NativeCommandProcessor to clean up in case an exception is thron
* [Feature] Update tests
* [Feature] Address comments
* address one more comment
* Address some more comments
* [Feature]
Fixed error message using a null resourcemanager
With most recent CoreFx supporting STA, removed special CoreClr code paths
Added test coverage
Removed some dead commented out code that was never used
* [Feature]
merged tests to one file, use runas to have relevant tests run as non-elevated
* [Feature]
Get-CredSSP returns text so only run that test if current culture is en-US
* [Feature] Update test to fix code exclusion
* [Feature] Fix Skipping on test cases that already had a Skip value
* Fix the hang issue in Travis CI build triggered by the [Feature] tag
* [Feature] Update badge only in daily build
* [Feature] Use the term 'daily build'
Fixes#1193 for most scenarios. The remaining scenario to be addressed is the Nano Server bring-up scenario. To continue supporting that scenario, I left the Install-PowerShellRemoting script in place.
This change
1. Ports Enable-PSRemoting and Disable-PSRemoting to PowerShell Core
2. Adds side-by-side PowerShell Core remoting support to the PSSessionConfiguration cmdlets and PSRemoting cmdlets.
3. Ports PSSessionConfiguration tests
This change also introduces a behavioral difference. The PSRemoting and PSSessionConfiguration cmdlets are now context-sensitive and only work for endpoints that match the PowerShell type. For example, Get-PSSessionConfiguration, when running in PowerShell Core, will only return PowerShell Core WinRM endpoints. It will only modify PowerShell Core WinRM endpoints and cannot be used to configure Windows PowerShell endpoints.
- Fixed the way common test modules are passed to elevated and unelevated powershell. Earlier, only elevated powershell got those through inheritance as a child process. Now we add them to the startup of the process.
- Fixed error reported by PSScriptAnalyzer about ? / Where-Object
- Converted all the parameters passed to powershell.exe to be a base64 encoded string to avoid complications with quotes.
- Removed code which was updated $env:PSModulePath as we do it in startup args for powershell process instead.
- Added a way to disable -Quiet for Pester.
- Opencover.console.exe gets confused when the base64 encoded parameter is given with '&' invoke.
Writing to a ps1 file and invoking the script works around the issue.
This also makes it similar to how unelevated tests are invoked.
* Add more TabCompletion tests
* Minor changes
* Add some more tests
* Add more tab completion tests
* Fix errors
* Add more test coverage
* Add 'AfterEach { Pop-Location }'
* Enable DSC resource name completion and address comments
* use both '/' and '\' in the path for completion
* Use a separate test for '\' and '/'
To improve code clarity and give better error messages when using ValidateRange, you can now specify:
```
[ValidateRange(ValidateRangeKind.Positive)]
```
instead of
```
[ValidateRange(1, 2147483647)]
```
Valid kinds are:
Positive
Negative
NonPostiive
NonNegative
* Add test coverage for Registry (#4148)
* Add coverage for Get-Item, Get-ChildItem, Set-Item, and Clear-Item
* Add test for accessing inaccessible path, per code review.
Using powershell.exe to execute a PowerShell script using -File currently provides no way to pass $true/$false as parameter values. Current behavior is that -File accumulates passed parameters as strings only.
Fix is to special case this based on discussion with PS-Committee to support $true/$false as parsed values to parameters. Switch values is also supported as currently documented syntax doesn't work.
In CI, notepad.exe isn't starting (or starting in time) when using start-process with .txt based on file association.
Since the test is validating opening files by association, fix is to create our own association that is predictable.
On CoreFx, UseShellExecute for Process start is false by default to be cross platform compatible.
In the case of a folder, Process.Start() returns Access Denied as it's not an executable.
On Windows, we can use the ShellExecute path to have explorer open the folder. On Unix, we use `xdg-open` and `open` for Linux and macOS respectively.
- Fix invalid value error message on some properties of ParameterAttribute to point to the specific properties.
- Avoid wrapping argument exception into not a useful 'requires' exception.
This change fixes 3 issues:
- According to [PowerShell Language Specification Version 3.0](https://www.microsoft.com/en-us/download/details.aspx?id=36389), as quoted: "_The result is the (possibly empty) unconstrained 1-dimensional array_", `@(...)` should only return `object[]` array.
- `@([object[]]$null).GetType()` fails with error `"You cannot call a method on a null-valued expression."`
- `@([System.Collections.Generic.List[object]]$null)` fails with error `"Object reference not set to an instance of an object."`