Commit graph

1157 commits

Author SHA1 Message Date
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
Mark Kraus b4e8e9d06b Replace HttpBin.org/response-headers Tests with WebListener (#5058) 2017-10-18 12:24:02 -07:00
Dongbo Wang 2ceec725f6 Fetch resource string correctly (#5114) 2017-10-18 11:36:25 -07:00
Chunqing Chen dd5fba3313 Exclude PSHostProcess cmdlets from Unix platforms (#5105)
- Exclude 'Get-PSHostProcessInfo', 'Enter-PSHostProcess' and 'Exit-PSHostProcess' from Unix platforms.
- Update tests and add additional cmdlets need to be excluded
2017-10-18 09:26:24 -07:00
Steve Lee 6177d28410 removed RunspaceConfiguration support (#4942)
For PSCore 6, we are only supporting InitialSessionState. The RunspaceConfiguration APIs were already made internal. This PR removes all the code related to RunspaceConfiguration. This also means that some public APIs have changed. Was deciding between leaving the RunspaceConfiguration parameters and throwing Unsupported, but thought it was better to have it a compile-time error. This should simplify the code base.
2017-10-18 09:12:23 -07:00
Mark Kraus 7c9bddfa3d Add Authentication Parameter to Web Cmdlets for Basic and OAuth (#5052)
Closes #4274

Adds an -Authentication parameter to Invoke-RestMethod and Invoke-WebRequest
Adds an -Token parameter to Invoke-RestMethod and Invoke-WebRequest
Adds an -AllowUnencryptedAuthentication parameter to Invoke-RestMethod and Invoke-WebRequest
Adds tests for various -Authorization uses
-Authentication Parameter has 3 options: Basic, OAuth, and Bearer
Basic requires -Credential and provides RFC-7617 Basic Authorization credentials to the remote server
OAuth and Bearer require the -Token which is a SecureString containing the bearer token to send to the remote server
If any authentication is provided for any transport scheme other than HTTPS, the request will result in an error. A user may use the -AllowUnencryptedAuthentication switch to bypass this behavior and send their secrets unencrypted at their own risk.
-Authentication does not work with -UseDefaultCredentials and will result in an error.
The existing behavior with -Credential is left untouched. When not supplying -Authentication, A user will not receive an error when using -Credential over unencrypted connections.

Code design choice is meant to accommodate more Authentication types in the future.

Documentation Needed

The 3 new parameters will need to be added to the Invoke-RestMethod and Invoke-WebRequest documentation along with examples. Syntax will need to be updated.
2017-10-17 19:08:06 -07:00
Steve Lee 2cc091115b Rename powershell.exe to pwsh.exe (#5101)
- Rename powershell.exe to pwsh.exe
- Fixe appveyor.psm1
- Update MSI to include 'pwsh' in path and app paths
- Revert change for hyper-v powershell direct
- Update names in packaging.psm1.
- Fix check for SxS
2017-10-17 17:25:11 -07:00
Mark Kraus 17731cf6e9 Add Get-WebListenerUrl Based Examples to WebListener README.md (#4981)
- Add Get-WebListenerUrl Based Examples to WebListener README.md
- Fix Cert test example
2017-10-17 16:18:54 -07:00
James Truher [MSFT] d5445ff691 Make sure that there's a statement separator after we update the path, otherwise the built script will not run (#5137) 2017-10-17 13:32:21 -07:00
Aditya Patwardhan 486fb97123 Test fixes and code coverage automation fixes. (#5046)
* Test fixes and updates to code coverage automation
* Fixed UpdatableHelpSystem tests and tab completion tests
* Fixed tab completion tests to better disambiguate root/interop namespace.
* Skip SSH test if ssh.exe is not present
2017-10-13 13:54:43 -07:00
Dongbo Wang f2eaeb8b8e Remove '-ComputerName' from 'Get/Set/Remove-Service' (#5094) 2017-10-13 22:06:46 +04:00
Chunqing Chen 07d3b1806c Get-Content -Raw should not neglects to read the last character, if it is a LF (#5076) 2017-10-13 11:05:51 +04:00
Tadas Medišauskas 844bf11dde Get-Verb: add verb descriptions and alias prefixes (#4746)
* Get-Verb: add descriptions and prefixes

* Add description and alias prefix tests

* Make the new classes internal

* Convert alias prefix to static method

* Move verb descriptions to a resource file

* Shorten function name

* Shorten alias prefix function name

* Change tests to look at counts

* Add uniqueness test

* Add missing alias prefixes

* Fix name collision

* Change alias prefix for Compare

* Rename method

* Remove unnecessary string allocation

* Make tests easier to diagnose
2017-10-12 14:40:06 -07:00
Dave Wyatt 94a71b05d4 Fix ValueFromRemainingArguments to have consistent behavior between script and C# (#2038) 2017-10-11 17:09:59 -07:00
Indhu Sivaramakrishnan 2a9cd7211f Add tests for Dsc configuration compilation on Windows (#5011) 2017-10-11 10:49:35 -07:00
Steve Lee 59311d03e1 Properly escape trailing backslash so that it doesn't end up escaping the quotes (#4965)
The native command receives the arg ".\test 1" as  .\test 1"  as the last  \"  is treated as escaping the quotes. Fix is to add an extra backslash to escape the last enclosing quote.
2017-10-11 18:01:09 +04:00
Raghav S 7dd36c9e34 Add NoNewLine switch for Out-String cmdlet (#5056) 2017-10-11 17:44:57 +04:00
Dongbo Wang f7bab36f5d Fix the prerequisite check of MSI package (#5070)
* Skip check 'vsruntime140.dll' on Win10

* Make the precheck accurate

* Update windows installation prerequisites

* Change 'higher' to 'above'

* Address comments

* Address more comments

* Address some more comments

* [Feature] Update the installer test
2017-10-10 16:40:07 -07:00
David Weber aea561f08d Add better error message for empty and null -UFormat arg (#5055)
Add better error message for empty and null -UFormat arg
2017-10-10 07:19:02 +04:00
Steve Lee 90165fc17c enable using filesystem from a UNC location (#4998)
* enable using filesystem from a UNC location

* [feature]
address PR feedback

* [feature]
removed changed in NavigationProviderBase and made change in FileSystemProvider where it should belong

* added variations of tests for set-location and push-location
no need to run [feature] anymore since it passed previously and the test case added is CI

* [feature]
move code to reproduce UNC path to GetParentPath()
2017-10-09 14:05:16 -07:00
Steve Lee ff59be3c61 fix detection of whether -LiteralPath was used to suppress wildcardexpansion for navigation cmdlets (#5038)
* [feature]
fix detection of whether `-LiteralPath` was used to suppress wildcardexpansion

* [feature]
skip -literalpath test with asterisk in filename as that's not valid on Windows

* [feature]
added more variations of tests
2017-10-09 09:33:22 -07:00
Travis Kinney 1d5c310897 SetServiceCommand: Add positional parameter attribute (#5017)
* SetServiceCommand: Add positional parameter attribute

Added a positional parameter attribute to the InputObject parameter,
giving Set-Service behavior similar to the other *-Service cmdlets.

* Add test for positional InputObjects [Feature]

Added a test to Set-Service validating InputObjects passed positionally.
2017-10-09 09:30:50 -07:00
Lucas Spits e1a0cafee8 User Agent now reports the OS platform (#4937)
Also include '<major>.<minor>' in UserAgent on windows platform.
2017-10-06 13:59:31 -07:00
Steve Lee 50607b9751 Enable support of folders and files with colon in name on Unix (#4959)
* [feature]
support folders and files with colon in name

* [feature]
only check separator in relation to colon if a colon is found

* [feature]
added comment to clarify algorithm

* added more tests
2017-10-06 11:27:15 -07:00
Mark Kraus 97ee17ccf4 Fix Delay Test Race Condition (#5035) 2017-10-06 11:17:52 -07:00