Commit graph

1181 commits

Author SHA1 Message Date
Mark Kraus 28fa53a77c [Feature] Fix AppVeyor Fails (#5520) 2017-11-21 15:57:34 -08:00
Aditya Patwardhan 381134ba59 Updated csproj to use the latest help package (#5454) 2017-11-15 16:29:04 -08:00
Dongbo Wang c4f0d1c893
Add a test for the powershell hang fix (#5451)
- Add test for the powershell hang fix
- Ignore the 'Sync-PSTags' warning
2017-11-15 09:41:11 -08:00
Mark Kraus c832e1687d Add PSTypeName Support for Import-Csv and ConvertFrom-Csv (#5389)
closes #5134

Adds PSTypeName preservation on Import-Csv and ConvertFrom-Csv
2017-11-14 11:15:18 -08:00
Mark Kraus 87bcd4132a Fix Single Value JSON null in Invoke-RestMethod (#5338)
* [Feature] Fix Single Value JSON null in Invoke-WebRequest

* [Feature] Switch from Regex to JToken.Parse()

* [Feature] Address PR Feedback: use `n
2017-11-14 07:53:43 +04:00
Mark Kraus ecf0f8c151 Add SslProtocol Support to WebCmdlets (#5329)
closes #2662

This feature adds the ability to restrict the SSL/TLS protocol used when making the web request. In 5.1 the user could make use of .NET API's to enforce this on the Web Cmdlets. With the move to HttpClient in PowerShell Core, those APIs have no impact. The user still has requirements to ensure specific protocols are used.

The public enum WebSslProtocol is added as a wrapper to the underlying SslProtocols enum. Neither it nor SecurityProtocolType can be used because Ssl3 and Ssl2 are not supported by HttpClientHandler.SslProtocols. While it may not be intuitive to a PowerShell user to use -bor or "Tls, Tls11" to set multiple options, the general use case for this will be a single protocol.

Adds -SslProtocol parameter to Web Cmdlets
Adds WebSslProtocol Enum to support limited subset of SslProtocol enum supported by HttpClientHandler
Adds TLS 1.1 and TLS 1.0 listening ports to WebListener
2017-11-13 10:45:46 -08:00
Ilya c86f243ca0 Make Import-Csv support CR, LF and CRLF as line delimiters (#5363)
With the fix, `Import-Csv` support CR (\r), LF (\n), CRLF (\r\n) as line delimiters.
2017-11-10 14:02:45 -08:00
Chunqing Chen 2be13a623e Disable cmdlets that are not supported under unix system (#5083)
* permanently remove cmdlets that are not supported under Unix and move tests to defaultcommands.tests.ps1
2017-11-10 10:36:08 -08:00
Mark Kraus ee7edb7427 Add error on Legacy Credential over non-HTTPS for Web Cmdlets (#5402)
- Add an error when a user tries to use `-Credential` (legacy usage without `-Authentication`) or `-UseDefaultCredentials` over a non-HTTPS URI
- User can bypass error with `-AllowUnencryptedAuthentication`
- `-UseDefaultCredentials` can only be reliably tested on Windows as support on other platforms depends on a Kerberos infrastructure. 
- Add `/Auth/` tests to WebListener for challenge authentication Basic, Negotiate, and NTLM

Incidentally, this increases test coverage for the web cmdlets as `-Credential` and `-UseDefaultCredentials` were not being tested.
2017-11-10 08:11:57 -08:00
Ilya 5fd1b4759c
Don't write an error if file already unblocked (Unblock-File) (#5362) 2017-11-10 18:14:08 +04:00
Dan Travison 7a78fec180 Exclude EventResource.resx from SMAResources.Tests.ps1 (#5379)
Fix a test failure.
2017-11-09 07:52:01 -08:00
Ilya c4269cb6be Make SemanticVersion compatible with SemVer 2.0 (#5037)
Made 'SemanticVersion' compatible with SymVer 2.0 http://semver.org/ (p.10)
- Fix comparisons
- Refactor and add more tests
2017-11-09 07:44:58 -08:00
Steve Lee 5f5407595d replace the word hang with something more appropriate (#5358) 2017-11-08 13:47:12 -08:00
James Truher [MSFT] fe3e44f305 Change $OutputEncoding to be utf8 without BOM rather than ASCII (#5369) 2017-11-07 14:49:14 -08:00
Jason Shirk 8391b9e155 Rework passing array literal to native commands (#5301) 2017-11-06 17:05:26 -08:00
Keith Hill c781959232 Display full help with 'help' function (#5195)
Display full help with 'help' function
2017-11-06 10:19:39 -08:00
Chunqing Chen 36b600d1ec Add Jobject serialization support to ConvertTo-Json (#5141) 2017-11-03 11:35:09 -07:00
Raphael c9f83fecfc Add Remove-Alias Command (#5143)
* Add Remove-Alias Command. Add Remove-Alias Test. Add Remove-Alias to .psd1.

* Fix code-formatting. Fix ErrorAction on Remove-Alias instead of preference variable. Remove unnecessary Get-Alias calls. Switch Force parameter to auto property. Add ValueFromPipeline to Remove-Alias Name parameter.

* Remove empty lines. Add Remove-Alias to Unix Module .psd1. Add Remove-Alias to approved Commands test. Remove Try/Catch for SessionstateException. Add WriteError for aliasnotfound exception.

* Add ErrorAction Stop to all Get-Alias and Set-Alias Cmdlets in all tests for consistency. Add Should BeNullOrEmpty to "should throw if alias does not exist" test to verify that foo alias really is not there before removing it.

* Changed Remove-Alias parameter Name to String-Array. Changed Cmdlet Process Logic to work with String Array. Added Alias named "ral". Added test case for Alias "ral". Added "ral" Alias to list of approved Aliases. Replaced foo and bar values in all tests with better names.

* Remove "ral"-alias test as this is covered in DefaultCommands.Tests.ps1. Add test for removing multiple alias at once. Fix wrong curly braces positioning.

* Remove $FullCLR in DefaultCommands.Tests.ps1 for Remove-Alias and "ral" alias.

* Add Alias "ral" to Remove-Alias Cmdlet.

* Remove "ral" alias as this is handled by using the [Alias()] attribute on the Remove-Alias Cmdlet.

* Replace alias names used in Remove-Alias Cmdlet tests with GUIDs to avoid collisions
2017-11-03 12:08:37 +04:00
Dongbo Wang 3771c88da3
Always run test with crossgen'ed assemblies in CI (#5315) 2017-11-02 18:03:34 -07:00
Chunqing Chen 2ae776ae1f Fix 'ExecutionContext.LoadAssembly' to load with name when file cannot be found (#5161) 2017-11-02 17:13:02 -07:00
Dongbo Wang a954f9f98c
Change line ending in Rename-Computer.Tests.ps1 to LF (#5314) 2017-11-02 14:17:45 -07:00
Dongbo Wang decdd1a828 Update powershell to use 2.0.4-servicing dotnet core runtime (#5295) 2017-11-02 14:12:19 -07:00
Jason Shirk 71d5439bbe
Fix dynamic class assembly name (#5292)
Using the assembly name to hint at the source of the classes was
problematic in multiple ways.

This change stores the actual filename in an attribute on the assembly.

So for a given type, one can get the assembly this way:

[SomeType].Assembly.GetCustomAttributes() |
    ? { $_ -is [System.Management.Automation.DynamicClassImplementationAssemblyAttribute] } |
    % { $_.ScriptFile }
2017-11-02 10:29:10 -07:00
Dongbo Wang 532044f27a
Add documentation about how to create libpsl and psrp.windows packages (#5278)
- Add document about creating libpsl and psrp.windows nuget packages
- Clean up and update the existing building docs.
2017-11-01 15:55:46 -07:00
Mark Kraus 57f3c85469 Add Multiple Link Header Support (#5265) 2017-11-01 14:06:30 -07:00
James Truher [MSFT] d43b2cf958 Remove DCOM support from *-Computer cmdlets (#5277)
Since DCOM is not supported in corefx there was a great deal of dead code in the computer cmdlets.
This PR removes all vestiges of DCOM support from:

- Rename-Computer
- Restart-Computer
- Stop-Computer

removing about 4500 lines of dead code. Also, tests are updated to provide more complete coverage.
I also removed test-connection completely to make way for @iSazonov upcoming PR to improve coverage in tests, I created some test hook code which will test the cmdlet code without actually calling the WMI method to restart/rename/stop the system
2017-11-01 10:59:41 -07:00
Jason Shirk 6cbcf5dd3e Glob native command args only when not quoted
Also fix some minor issues with exceptions being raised when resolving
the path - falling back to no glob.

Fix: #3931 #4971
2017-10-31 23:34:50 -07:00
Dongbo Wang 73c6a73752 Fix line endings with LF (#5288) 2017-10-31 16:31:41 -07:00
James Truher [MSFT] 63f55427ec fix sparse-checkout list (#5263)
* fix sparse-checkout list
* Run powershell.exe in OpenCover since it will be in the path.
* If there's an error in Start-CodeCoverageRun be sure to log as much as possible
* Make the directory removal code common
2017-10-31 15:40:23 -07:00
Ilya 1c446c1be4
Fix performance issues in Add-Type (#5243)
* Exclude ReadAllText from OutputError()

* Exclude double ReadAllText() from EndProcessing

* Remove sourceCode initialization

* Add StringBuilder init size and remove unneeded code.

* Set init size StringBuilder in 8192
2017-10-31 19:00:41 +04:00
Jason Shirk b1080860a4 Remove AllScope from most default aliases (#5268)
* Remove AllScope from most default aliases

To speed up scope creation, I removed AllScope from most default
aliases.

This results in a 15-20% speedup for:

    function foo {}
    for ($i = 0; $i -lt 100kb; $i++) { & { foo } }

I left AllScope of a few frequently used aliases because it does
make command lookup faster. If we introduce something like dynamic
sites for command lookup, then we could probably remove the rest
of the AllScope aliases.

This is a low-risk breaking change. One can ask for aliases at
a particular scope:

    Get-Alias -Scope 1 nsn

This could now fail if the scope number doesn't correspond to global
scope.
2017-10-30 20:05:49 -07:00
Steve Lee a384c6ea11 Change to not insert line breaks to output (except for tables) (#5193) 2017-10-30 09:54:44 -07:00
Mathias R. Jessen 9b32c1d039 Add char range overload to DotDot operator (#5026) 2017-10-28 10:47:10 -07:00
Steve Lee 967ed8b664 Fix 'Import-module' to not report a loaded module was not found (#5238)
Missed a 'break' statement after the module was loaded successfully, so the loop continues when it shouldn't.
2017-10-26 14:16:47 -07:00
Steve Lee 7407a9e300 Fix 'get-item -literalpath a*b' to return error if a*b doesn't actually exist (#5197) 2017-10-26 14:14:46 -07:00
Steve Lee 4bc52d2358 Use consistent '(c)' for copyright symbol (#5210)
- Remove the year about copyright
- Fix casing of `All rights reserved`
- Replace Unicode characters representing single quote with a single quote
2017-10-26 14:12:19 -07:00
Steve Lee b1af9ea230 -Verbose should not override $ErrorActionPreference (#5113)
* -Verbose should not override $ErrorActionPreference

* apply same fix to -debug and added test case

* address Aditya's feedback
2017-10-26 13:40:14 -07:00
Roma Marusyk 282deb7ee1 Export-Csv Test Improvements (#5150) 2017-10-26 08:56:07 +04:00
Travis Plunk 00dde3d8f2 Add term rules (#5213)
* Add Terms Rules

* remove offensive term

* Add code owner for compliance files
2017-10-25 15:08:52 -07:00
bergmeister f5f0d3afc5 Add -AsHashtable switch to ConvertFrom-Json for issue #3623 (#5043)
Address #3623.

Implementation symmetric to traditional code path that returns a PSCustomObject. Code is shared on the top level but 2 low level methods were difficult to share, therefore 2 separate but similar methods were created for HashTables.
All existing tests related to this change were adapted to also test against this new switch and were slightly improved.

-AsHashtable is an existing pattern used in Group-Object
2017-10-25 08:57:05 -07:00
Jonas Andersen ca30054761 Added BinPath, Description, UserName and Delayed Auto Start to Get-Service (#4907)
Added the following to the  Get-Service  command:
•BinaryPathName (Was suggested as  ServicePath )
•Description
•UserName (Was suggested as  LogOnAs )
•DelayedAutoStart
•ServiceStartupType

The ServiceStartupType was also added, providing the user access to use services like in  services.msc , having  Automatic ,  Automatic (Delayed Start) ,  Manual  and  Disabled  as options (Also includes  InvalidValue  as an initial value for  ServiceStartupType )
2017-10-24 10:54:07 +04:00
James Truher [MSFT] be700729d6 Unify cmdlets with parameter 'Encoding' to be of type System.Text.Encoding (#5080)
This unifies file encoding across the inbox cmdlets to be UTF-8 without a BOM for all platforms. This is a breaking change as cmdlets on windows have a number of different encodings. This supports better interoperability with tradition Linux shells as we are using the same encoding.

Validate that files are created with UTF-8 encoding without BOM
Update tests to validate Encoding parameter to new type and create new tests for
parameter type validation.

[Breaking Change] The '-Encoding Byte' has been removed from the filesystem provider cmdlets. A new parameter '-AsByteStream' is now added to indicate that a byte stream is required as input, or output will be a stream of bytes.
2017-10-23 19:46:27 -07:00
Steve Lee d85b9a472c Put command discovery before scripts for Unix (#5116)
* put command discovery before scripts for Unix

* remove unnecessary test
2017-10-23 17:54:28 -07:00
Joshua King c98fe394ec Make Get-ChildItem honor Depth parameter with Include/Exclude (#4985)
* Add depth to ProcessPathItems

* Honors capped recursion when using Include or Exclude filters with Get-ChildItem

* Including test cases to test include/exclude recursion

* Swap optional parameter for overload
2017-10-23 12:22:05 -07:00
Andrew e0af4d96d8 Add example of how to create a .net core cmdlet with Visual Studio (#5096) 2017-10-23 09:35:28 -07:00
Aditya Patwardhan df06200be5 Add new Fwlinks for v6 help content (#4978)
Updated fwlinks to pull new help content for PSv6.
Fwlink for Microsoft.PowerShell.Core module is not updated since about_*help.txt is not available yet.
2017-10-23 09:28:17 -07:00
Mark Kraus 9fd600448c Make -NoTypeInformation Default on Export-Csv and ConvertTo-Csv (#5164)
•Sets  -NoTypeInformation  as the default behavior for  Export-Csv  and  ConvertTo-Csv 
•Hides the  -NoTypeInformation  parameter switch
•Adds  -IncludeTypeInformation  switch to  Export-Csv  and  ConvertTo-Csv  to enable legacy behavior
•Provides a terminating error when both  -NoTypeInformation  and  -IncludeTypeInformation  are supplied
•adds tests for the new behavior
•fixes existing tests to align with new behavior

The new behavior will need to be documented.
2017-10-21 13:41:46 +04:00
Dave Wyatt 1c469aaa22 Unwrap 'ValueFromRemainingArguments' if the single element is a collection (#5109)
Unwrapping of 'ValueFromRemainingArguments' was being performed only for 'object[]' arrays (which covers the most common PowerShell binding scenarios) but could be skipped if a collection of any other type were passed to the parameter. This change unwraps 'ValueFromRemainingArguments' if the single element is a collection.
2017-10-19 16:44:26 -07:00
Steve Lee e908b8a607 Enable import-module to be case insensitive (#5097)
Fix #1621 

Enable import-module to be case insensitive as macOS is case insensitive.
2017-10-19 14:44:21 -07:00
Keith Hill ca2630a3de Add document about how to create cmdlet w/dotnet CLI (#5117) 2017-10-19 11:32:40 -07:00