Commit graph

1999 commits

Author SHA1 Message Date
robdy aa07eef187 Add test for New-Item -Force (#9971) 2019-06-25 11:03:07 -07:00
Reece Dunham 0f46b25c99 Fix gulp versions (#9916) 2019-06-25 10:42:52 -07:00
Joel Sallow (/u/ta11ow) 17b2cec163 Cleanup Parser tests (#9792)
Co-Authored-By: Ilya <darpa@yandex.ru>
2019-06-24 11:22:54 -07:00
nbkalex 358d12ea93 Display com method signature with argument names (#9858) 2019-06-20 13:22:30 -07:00
Dongbo Wang c684902fba Use the original precision (prior-dotnet-core-3) for double/fload-to-string conversion (#9893)
.NET Core changes to return "shortest roundtrippable string" by default for the ToString() method of double and float types. This results in ToString() for double/float values sometimes return a string in 17-digit/9-digit precision format. This PR updated the double/float-to-string conversion in PowerShell to continue using the old precision specifier before the change in .NET Core 3.0.
2019-06-19 08:56:43 +05:00
Reece Dunham b17b6bd361 Use yarn to install global tools (#9904) 2019-06-17 12:10:55 -07:00
Steve Lee 981c990d74 Make UseAbbreviationExpansion and TempDrive official features (#9872) 2019-06-13 13:05:37 -07:00
Kirk Munro aac4c6ff21 Add module to support Pester tests for automating debugger commands (stepInto, stepOut, etc.), along with basic tests (#9825) 2019-06-13 07:19:13 -07:00
Steve Lee 89db7505d6 Have console host not enter command prompt mode when using Read-Host -Prompt (#9743)
`Read-Host` calls into `$Host.UI.Prompt()`.  However, this method is also used when the host prompts for mandatory parameters that aren't provided.  The method expects to be called when given a `FieldDescription` and if the input starts with `!` it enters `CommandPromptMode`.  In this mode, you can type `!?` to request help, for example.  However this mode is not something you can use via `Read-Host` (only if calling `$Host.UI.Prompt()` directly passing in a well constructed `FieldDescription`).  When using `Read-Host -Prompt`, the cmdlet creates a `FieldDescription` where the name is the prompt and the rest of the properties are empty.

The fix is that if `Label` is empty, we can assume it's being called from `Read-Host` rather than being called to prompt for a mandatory parameter and thus not enter `CommandPromptMode`.
2019-06-09 07:55:11 -07:00
Amit Saraf 689434e535 Support DSC compilation on Linux. (#9834) 2019-06-07 11:50:14 -07:00
Ilya 7e423e7451
Fix minor style issues come from last commits (#9640) 2019-06-07 08:35:33 +05:00
Joel Sallow (/u/ta11ow) f5e3de036e Improve whitespace for Parser tests (#9806) 2019-06-05 10:09:45 +05:00
Steve Lee b4e2423fab Fix use of Start-Process http://bing.com (#9793) 2019-06-04 14:36:12 -07:00
Jacob Scott f222a686c5 Support negative numbers in -split operator (#8960) 2019-06-03 16:33:54 -07:00
dependabot-preview[bot] c2cedccfbd Build(deps): Bump Microsoft.ApplicationInsights from 2.9.1 to 2.10.0 (#9757) 2019-05-31 11:43:47 -07:00
kwkam f0133bed8e Fix Get-ChildItem -Path with wildcard char (#9257)
Unescape non-literal, non-glob path before existence checking.
2019-05-31 10:14:39 -07:00
Aditya Patwardhan 8ea15c9f13 Merged PR 8529: Add cleanup before building test package
Add cleanup before building test package
2019-05-29 00:31:14 +00:00
Aditya Patwardhan ed1b991b6f Merged PR 8512: Update version for SDK tests and Microsoft.PowerShell.Native package
Update version for SDK tests and Microsoft.PowerShell.Native package
2019-05-24 20:17:45 +00:00
Travis Plunk bb726da6fd
Disable the debugger when in system lock-down mode (#9645)
Disable the debugger when in system lock-down mode

Fixing master for CVE-2019-0733
2019-05-22 15:19:23 -07:00
Steve Lee 29e21470d9 Port PowerShell to .NET Core 3.0 (#9597) 2019-05-21 13:43:51 +08:00
Travis Plunk 1d94e8c947 Make sure we always return an object in command searcher (#9623) 2019-05-20 11:22:34 -07:00
Kirk Munro 112401ed37 Support line continuance with pipe at the start of a line (#8938)
Expands line continuance for pipelines to allow lines to continue automatically without backticks with the pipe symbol at the start of a line.
This adds to the existing functionality where pipes can be used to continue lines by placing them at the end of a line.
2019-05-13 22:57:57 -07:00
Steve Lee a96b4c0404 Update use of "PowerShell Core" to just "PowerShell" (#9513) 2019-05-10 15:34:27 -07:00
Aditya Patwardhan ade85b4faa
Multiple test fixes and improved logging for fragile tests (#9569) 2019-05-10 10:56:12 -07:00
dependabot[bot] 72db71b76b Build(deps): Bump gulp from 4.0.1 to 4.0.2 in /test/common/markdown (#9544) 2019-05-10 10:07:22 -07:00
Chris Dent 374e0cf54d Add support for ValidateRangeKind to ParameterMetadata.GetProxyAttributeData (#9059) 2019-05-07 12:15:38 -07:00
Andrew e3e37a8e35
Merge pull request #9528 from SteveL-MSFT/login-shell
Add support for `-l` to pwsh so that it is compatible with POSIX shell expectations
2019-05-07 11:55:45 -07:00
Ilya 2be3db8ab8
Cleanup unused pinvokes on unix (#9531)
* Remove TemporaryDirectory()
* Remove GetUserName()
* Use Environment.UserName on Unix
* Remove old comment
* Use Environment.UserName on Windows too
2019-05-07 10:22:01 +05:00
Steve Lee 346ab8c9d4 Change MatchType for EnumerationOptions to be Win32 (#9529) 2019-05-06 17:20:08 -07:00
Mark Kraus 935e164a6d Add Support for Null Usernames in Web Cmdlet Basic Auth (#9536) 2019-05-06 17:15:04 -07:00
Steve Lee 592f897d21 allow test to work in cases where you can't create $profile 2019-05-04 07:44:30 -07:00
Steve Lee 3b5663ee97 correctly delete $profile in all cases 2019-05-04 07:12:53 -07:00
Steve Lee 0c1274011c fix creation of profile 2019-05-04 06:45:43 -07:00
Aditya Patwardhan 2737e74d86 Fix null reference when Microsoft.PowerShell.Utility is loaded as a snapin in hosting scenarios (#9404) 2019-05-03 15:16:41 -07:00
Steve Lee a69b20be3e add test 2019-05-03 11:12:46 -07:00
Steve Lee 3bfca6d0fa Update use of Windows PowerShell to just PowerShell (#9508) 2019-05-03 15:38:06 +05:00
ThreeFive-O 0735c95c3f Add unit and feature tests for Send-MailMessage (#9213) 2019-05-02 10:37:50 -07:00
xtqqczze a702f68974 Ensure Wait-UntilTrue returns $true in Pester tests (#9458) 2019-05-01 17:03:43 -07:00
Steve Lee d318e7727e Allow passing just a dash as an arg to a file via pwsh (#9479) 2019-04-27 11:20:33 -07:00
Dongbo Wang 687697bc90 Fix the failed test and update 'Publish-TestResults' to make AzDO fail the task when any tests failed (#9457) 2019-04-25 14:01:05 -07:00
Andrew 095be4655e
Return correct casing of filesystem path during normalization (#9250)
* return correct casing of filesystem path during normalization

* handle UNC case

* handle case to add trailing separator back

* add support for NTFS streams syntax

* add case-sensitive test

* only apply correct casing to directories

* handle 8.3 path syntax

* fix short path processing
2019-04-23 13:31:43 -07:00
Steve Lee 5e58e30d20 Move warning message to EndProcessing so it only shows up once (#9385) 2019-04-23 13:31:20 -07:00
dependabot[bot] 600a93750e Build(deps): Bump gulp from 4.0.0 to 4.0.1 in /test/common/markdown (#9441) 2019-04-23 11:06:39 -07:00
pougetat 0bd93777fc Adding tests for Remove-Module (#9276) 2019-04-22 10:49:58 -07:00
Tyler James Leonhardt 9140e421ec Add wildcard back to end of tab completion command lookup (#9383)
Re-add wildcard when searching AST + Missed test case.

## PR Context

In #8109, we removed the line that added a wildcard to the end of the command that was used to match commands in the script AST. This readds that line closer to where it is used.
2019-04-18 11:42:49 -07:00
Travis Plunk cee1e54e75
Add ability to cross compile (#9374)
`-CrossGen` won`t work, but this gives basic ability to build for another platform.
This also means you cannot really package for another platform.
2019-04-16 14:14:29 -07:00
Tyler James Leonhardt 13fd3af810 New New-PSBreakpoint cmdlet & new -Breakpoint parameter for Debug-Runspace (#8923)
This PR does 4 things:

* Adds a new cmdlet `New-PSBreakpoint` which creates new `Breakpoint` objects and writes them to the pipeline
* Adds a `-Breakpoint` parameter to `Debug-Runspace` which will receive `Breakpoint` objects
* Makes the constructors for `*Breakpoint` public for use with the API
* Makes `Debugger.GetBreakpoint(string id)` and `Debugger.GetBreakpoints()` public since `SetBreakpoints` is public

Note: `New-PSBreakpoint` and `Set-PSBreakpoint` (which already exists) are similar... but `Set-PSBreakpoint` also sets the breakpoints in the _current_ runspace. This is not ideal if we want to set breakpoints in a _different runspace than the current one_.

## PR Context  

The "Attach to process" debugging experience in the PowerShell extension for VSCode is _ok_ but it's not great.

The reason it's not great is due to the `BreakAll` feature of PowerShell debugging which, when you run `Debug-Runspace`, will break at the first piece of code that gets run. This is not ideal when you "Attach to process" _and then_ run your code in the other runspace.

Today, the experience drops you in `PSReadLine`'s psm1 if PSRL is available or in the vscode PowerShell helper psm1.

It's unexpected for the user and not ideal.

This PR will allow the extension to pass in the breakpoints that need to be set initially with `BreakAll` turned off for none of this silly behavior.

### Silly behavior example

If you want a repro, try this:

PowerShell instance 1:
```
Enter-PSHostProcess -Id $otherprocesspid
Debug-Runspace 1
```

PowerShell instance 2:
```
./runfoo.ps1
```

Note that you end up NOT `runfoo.ps1`
2019-04-13 19:14:53 -07:00
Travis Plunk 5913c88aaf
Mark tests in macOS CI which use applescript as pending/inconclusive (#9352)
Mark tests in macOS CI which use applescript as pending/inconclusive
2019-04-12 18:12:29 -07:00
James Truher [MSFT] 1006db647b Reduce time for stack overflow test (#9302)
Create a small class to do the work.
I saw 100x performance improvement in this test.
2019-04-12 14:21:33 -07:00
Sytze Andringa 4884317d00 Added more tests for import-alias by file regarding parsing difficult aliases strings (#9247) 2019-04-11 10:40:24 -07:00
Reece Dunham 2d87948d8e Move from npm to Yarn for markdown tests (#9312)
Yarn is better because...
* it validates package checksums
* it has emojis 🤟
* it is faster and employs better caching
2019-04-10 14:16:22 -07:00
Dongbo Wang e299a30128 Fixing test run crash by not passing script block to the callback (#9298) 2019-04-08 11:06:27 -07:00
Travis Plunk 98b2e147c1
Only search for functions in Constrained Language help tests (#9301)
Only search for functions in Constrained Language help tests

## PR Context

Searching for only functions is faster
2019-04-08 11:01:33 -07:00
Steve Lee b63696572f Fix skipping of tests in RemoteSession.Basic.Tests.ps1 (#9304)
Moved check if able to write to $PSHome as way to skip test to `BeforeAll` which already contained a check if running on Windows.

## PR Context

As part https://github.com/PowerShell/PowerShell/pull/9279, tests were updated to be skipped if the test requires writing to `$PSHome` but is not able to.  However, these tests already had a skip mechanism in place so the additional check caused the test to run when it should have skipped.

Co-authored-by: Travis Plunk <github@ez13.net>
2019-04-05 17:00:41 -07:00
Ilya b927c46eb4
Add QuoteFields parameter to ConvertTo-Csv and Export-Csv (#9132) 2019-04-05 22:19:01 +05:00
Steve Lee b8317de469 Update tests to account for when $PSHOME is readonly (#9279)
Co-Authored-By: SteveL-MSFT <slee@microsoft.com>


Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
2019-04-04 23:01:01 -07:00
Staffan Gustafsson 4ec36a0d4a Fixing progress for Get-ComputerInfo (#9236) 2019-04-04 16:15:43 -07:00
Joel Sallow (/u/ta11ow) 3f52adb0ae Add Binary Parsing Support & Refactor TryGetNumberValue & ScanNumberHelper (#7993)
Fixes #7557 

* Adds support for binary parsing in format echoing hex: `0b11010110`
  * Works with all existing type suffixes and multipliers.
  * Supports arbitrary length parsing with `n` suffix using BigInteger; details below.
* Adds `NumberFormat` enum to specify hex/binary/base 10 for the tokenizer, replacing old `bool hex`.
* Adds `n` suffix for all numeric literals to support returning value as a `BigInteger` if requested. This bypasses the issue of large literals losing accuracy when they cast through `double`.
* Adds tests for all new behaviours.

---

### Binary / Hex Parsing Implementation

* Mimics old sign bit behaviour for int and long types. Sign bits accepted for 8 or 16-bit Hex parsing, and 8, 16, 32, 64 for binary.
  * i.e., `0xFFFFFFFF -eq ([int]-1)` and `0xFFFFFFFFFFFFFFFF -eq ([long]-1)`, but suffixing `u` creates `int.MaxValue` and `long.MaxValue`, respectively, instead.
* Sign bits higher than this are accepted for bigint-suffixed numerals:
    * Hex: Bigint-suffixed hex treats the high bit of any literal with a length multiple of 8 as the sign bit
    * Binary: Bigint-suffixed binary accepts sign bits at 96 and 128 chars, and from there on every 8 characters.
    * Prefixing the literal with a 0 will bypass this and be treated as unsigned, e.g. `0b011111111`
* Specifying an `u`nsigned suffix (or combination suffix that includes `u`) ignores sign bits, similar to how parsing a hex string using `[Convert]::ToUint32()` would do so.
* Supports negating literals using `-` prefix. This can result in positive numbers due to sign bits being permitted, just like hex literals.

---

### Refactored numeric tokenizer parsing

**New flow:**

1. Check for `real` (`.01`, `0.0`, or `0e0` syntaxes)
    1. If the decimal suffix is present, TryParse directly into decimal. If the TryParse fails, TryGetNumberValue returns `false`.
    2. TryParse as `Double`, and apply multiplier to value. If the TryParse fails, TryGetNumberValue returns `false`.
        1. Check type suffixes and attempt to cast into appropriate type. This will return `false` if the value exceeds the specified type's bounds.
        2. Default to parsing as `double` where no suffix has been applied.
2. Check number format.
    * If binary, manually parse into BigInteger using optimized helper function to directly construct the BigInteger bytes from the string.
    * If hex, TryParse into `BigInteger` using some special casing to retain original behaviours in int/long ranges.
    * If neither binary nor hex, TryParse normally as a `BigInteger`.
3. Apply multiplier value before attempting any casts to ensure type bounds can be appropriately checked without overflows.
4. Check type suffixes.
    * If a specific type suffix is used, check type bounds and attempt to parse into that type.
      * If the value exceeds the type's available values, the parse fails. Otherwise, a straight cast is performed.
5. If no suffix is used, the following types are bounds-checked, in order, resulting in the first successful test determining the type of the number. 
    * `int`
    * `long`
    * `decimal` (base-10 literals only)
    * `double` (base-10 literals only)
    * ~~`BigInteger` for binary or hex literals.~~ If the value is outside `long` range (for hex and binary) or `double` range (for base 10), the parse will fail; higher values must be explicitly requested using the `n`/`N` BigInteger suffix.

---

*This is a breaking change* as binary literals are now read as numbers instead of generic tokens which could potentially have been used as function / cmdlet names or file names.

Notes:
* Binary literal support was approved by the committee in #7557 
* ~~The same issue is still under further discussion for underscore support in numeric literals and whether BigInteger parsing ought to be exposed to the user at all.~~
    * ~~Supporting underscore literals is a further breaking change causing some generic tokens like `1_000_000` to be read as numerals instead.~~ Per @SteveL-MSFT's [comment](https://github.com/PowerShell/PowerShell/pull/7993#issuecomment-442651543) this proposal was rejected.
    * ~~Removing underscore support or preventing standard parsing from accepting BigInteger ranges is a relatively trivial matter. It is my personal opinion that there is no particular reason *not* to hand the user a BigInteger when they enter a sufficiently large literal, but I will defer to the PowerShell Committee's judgement on this.~~
2019-04-03 15:10:02 -07:00
Travis Plunk 5e4b4d1351 Make command searcher not use wildcard search for execution (#9202) 2019-04-02 11:54:11 -07:00
Rene Hernandez 75da390d1e Add ItemSeparator and AltItemSeparator properties in ProviderInfo (#8587)
Add two properties in `ProviderInfo` class: `ItemSeparator` and `AltItemSeparator`.
On windows, the default values for those two properties are `ItemSeparator = '\'` and `AltItemSeparator = '/'`.
On unix, the default values for those two properties are `ItemSeparator = '/'` and `AltItemSeparator = '\'`.

Registry provider is the only exception, both properties for it have the value `\`.
2019-04-02 09:59:36 -07:00
Steve Lee (POWERSHELL) 882e94f1cb add case-sensitive test 2019-03-30 09:40:14 -07:00
pougetat 0ee5278b40 Fix Get-Module -FullyQualifiedName option to work with paths (#9101) 2019-03-29 15:27:09 -07:00
Steve Lee 6bc2b55fdf return correct casing of filesystem path during normalization 2019-03-29 13:22:52 -07:00
pougetat e553aef0fb Implement Get-Random -Count without specifying an InputObject list (#9111) 2019-03-26 16:50:20 +05:00
Steve Lee 3255d84627 Enable SecureString cmdlets for non-Windows (#9199)
On Unix systems, fallback to plaintext manipulation instead of using the DPAPI which is not available.

## PR Context

Currently, existing scripts that use SecureString cmdlets fail with an error complaining about crypt32.dll not being available.  This change allows these cmdlets to be used, but there is no encryption of the string.
.Net already [states](https://docs.microsoft.com/en-us/dotnet/api/system.security.securestring?view=netcore-2.1#remarks) that the contents of a SecureString are not encrypted on .Net Core.

Fix https://github.com/PowerShell/PowerShell/issues/1654

Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
2019-03-23 10:11:05 -07:00
Ilya cc6540b614
Cleanup style issues in CoreAdapter and MshObject (#9190) 2019-03-23 09:52:30 +05:00
Travis Plunk 94616f1789
Add Obsolete message to Send-MailMessage (#9178)
Add Obsolete message to Send-MailMessage

## PR Context

See https://github.com/PowerShell/PowerShell-RFC/pull/160

Co-authored-by: Steve Lee <slee@microsoft.com>
Co-authored-by: Ilya <darpa@yandex.ru>
2019-03-22 12:52:41 -07:00
Travis Plunk 185f20e3bd
Add tests for command globbing (#9180)
Add tests for command globbing
  - Also, add `-noprofile` to places where `pwsh` is launched so they don't fail locally.
2019-03-21 13:49:57 -07:00
Staffan Gustafsson 42c289fc8e Improve formatting performance by having better primitives on PSObject (#8785)
By not doing excessive amounts of extra work, formatting can be sped up quite significantly (about 8x faster).
The main change comes from adding new, more efficient, primitive to query an object for the existence of an instance member.
The formatting system has been checking for if an object has properties other than some decorated properties added by PS remoting, and it doesn't this by retrieving all properties which results in heavy allocations and wasted cycles.
By adding `GetFirstOrDefault` to `PSObject` and similar primitives to the underlying Adapters, we are able to return early, without having to get all properties back.
2019-03-20 18:43:52 -07:00
Patrick Meinecke b4ebf63335 Improve type inference of array literals and foreach statement variables (#8100)
Improve type inference for foreach statement variables by:

Inferring strongly typed arrays from explicit array and array literal expressions when elements are of the same inferred type

Fix detection of foreach variable declaration. The previous logic was to check if the variable expression's start offset was after the end offset of the foreach statement, which will never be true in the body

Improve inference of what type the "Condition" of a foreach statement will enumerate as
2019-03-19 13:36:27 -07:00
Dongbo Wang 24d3152f00 Make Start-Job throw terminating exception when -RunAs32 is specified in 64-bit pwsh (#9143) 2019-03-18 10:23:29 -07:00
Staffan Gustafsson e91d6dcf56 Adding CmdletsToExport and AliasesToExport to test module manifests. (#9108) 2019-03-18 11:09:05 +05:00
Jacob Scott 8f6982cc8a Made -Subject parameter of SendMail command no longer mandatory. (#8961) 2019-03-18 08:24:57 +05:00
pougetat 5277c79d67 Clean up Get-Random cmdlet (#9133) 2019-03-16 13:54:35 +05:00
Dongbo Wang cdb28a1067 Make 'Start-Job' throw terminating error when PowerShell is being hosted (#9128) 2019-03-13 17:57:42 -07:00
Reece Dunham 78f4ba5ec1 Update AppVeyor comments in Implicit.Remoting.Tests.ps1 (#9020) 2019-03-13 12:52:35 -07:00
pougetat a79ed1ef0f Make New-ModuleManifest consistent with Update-ModuleManifest (#9104) 2019-03-13 12:01:42 -07:00
Joel Sallow (/u/ta11ow) 18d5037ad2 Fix -NoEnumerate behaviour in Write-Output (#9069)
Fix is to preserve input collection type in output.
The regression was caused by #2038
2019-03-13 13:54:12 +05:00
Ilya e75bd1482f
Add support empty NoteProperty in Group-Object (#9109) 2019-03-13 11:22:05 +05:00
Staffan Gustafsson 9983297254 Removing Hardlink from Mode property in default file system format (#8789) 2019-03-12 15:49:16 -07:00
James Truher [MSFT] e605fbdea7 Fix tab completion test to handle multiple matches (#8891) 2019-03-11 14:51:22 -07:00
Staffan Gustafsson 0ebbdc1cc4 Fixing issue with help progress with Get-Help not calling Completed (#8788) 2019-03-11 11:26:01 -07:00
Tyler James Leonhardt a26d639a47 Fix Enter-PSHostProcess tests flakiness (#9007) 2019-03-11 10:41:06 -07:00
pougetat e3829cb60f Allow Test-ModuleManifest to work when RootModule has no file extension (#8687) 2019-03-10 14:57:19 -07:00
Reece Dunham 43487b4068 Update markdown test dependencies (#9075) 2019-03-09 08:30:14 +05:00
Dongbo Wang 50f3e7f10e
Update the task-based async APIs added to PowerShell to return a Task object directly (#9079)
Update the task-based async APIs added to PowerShell to not use the `aysnc/await` keywords, but to return a `Task` object directly.
There is nothing to continue on after the `Task.Factory.FromAsync` call in those methods, so there is not need to use `aysnc` and `await` keywords, which turns the method into a state machine class unnecessarily.
2019-03-07 11:24:31 -08:00
Aditya Patwardhan 0752a5502a
Add source for install-package to install netDumbster (#9081) 2019-03-06 16:21:03 -08:00
Ilya 2953959dc5 Add UseQuotes parameter (#8951) 2019-03-06 11:59:15 -08:00
Kirk Munro 45aba2acb5 Add 5 'InvokeAsync' overloads and 'StopAsync' to the 'PowerShell' type (#8056) 2019-03-06 10:06:11 -08:00
ThreeFive-O d56e50152a Style fixes for Select-Xml tests (#9037) 2019-03-05 15:07:00 -08:00
ThreeFive-O a2c9482194 Enable cross-platform Send-MailMessage tests for CI (#8859) 2019-03-05 14:29:48 -08:00
Reece Dunham da4930f2dc Added RequireSudoOnUnix tags to PowerShellGet tests and unmark as pending (#8954) 2019-03-05 11:55:20 -08:00
ThreeFive-O 6e383de251 Style fixes for ConvertTo-Xml tests (#9036) 2019-03-05 11:39:58 -08:00
dependabot[bot] 98506db714 Build(deps): Bump SelfSignedCertificate in /test/tools/Modules (#9055) 2019-03-05 11:32:40 -08:00
ThreeFive-O 017e472961 Align name schemes for test files (#9034) 2019-03-05 10:47:04 -08:00
Aditya Patwardhan 7062297e4e
Update version for PowerShell.Native and hosting tests (#8983) 2019-03-04 11:08:19 -08:00
Gaurav Kamath f31b33863c Refactor Shuffle in Get-Random to save a full iteration of the objects. (#8969) 2019-03-01 17:11:37 +05:00
Ilya 18f9a36f2a Pending NamedPipeConnectionInfo test (#9003)
Related #8971. Pending the test until we fix a root case of failure.
2019-02-27 14:51:36 -08:00
mjanko5 7e0411fcd9 Add test for -WhatIf for New-FileCatalog (#8966) 2019-02-27 10:53:08 +05:00
Dongbo Wang 5d54f1aa38
Make xUnit tests run sequentially to avoid race conditions caused by manipulating 'powershell.config.json' in tests (#8945) 2019-02-22 11:57:10 -08:00
Tyler James Leonhardt 23eccfd641 [feature] Add -CustomPipeName to pwsh and Enter-PSHostProcess (#8889)
This allows a user to start PowerShell up with the name of the named pipe that is used for cross process communication (I.e. Enter-PSHostProcess).
2019-02-22 23:40:03 +05:00
Andrea Spadaccini af86157855 Fix typo: aganist ➜ against (#8943) 2019-02-22 18:46:31 +05:00
Ilya 778920bbc4
Use verbatim string literals for paths (#8937) 2019-02-22 11:35:32 +05:00
Travis Plunk 57aeca428e
Port Security bypass fixes from 6.1.3 (#8915) 2019-02-21 13:44:08 -08:00
Travis Plunk 2c488fb4e5
Fix Markdown lint issues (#8929)
#8896 Broke the static analysis CI.  Fixing so CI passes
2019-02-20 13:24:26 -08:00
Steve Lee b06ad6aa61 Enable discovering modules that have names same as a culture (e.g. Az) (#8777)
Here are the major changes:
- Add logic to skip checking for possible resource directories for the first set of sub directories from the top level.
- There was an additional skip if the folder is hidden, rather than doing an explicit attribute check, change the `EnumerationOption` to skip hidden folders.
- Since the `IsPossibleModuleDirectory()` helper now only checks to see if the name matches a culture, renamed to `IsPossibleResourceDirectory()`
- When getting the default modules, we don't search recursively into individual module folders, so removed additional check for possible resource directory.
2019-02-20 12:23:27 -08:00
Reece Dunham 4de3a72142 Fix code-of-conduct linting (#8896) 2019-02-20 11:57:31 +05:00
Adam Gauthier caf8ac6a6a Add configurable maximum depth in ConvertFrom-Json with -Depth (#8199)
Adds an optional -Depth parameter to the cmdlet which lets the user to specify a maximum depth allowed for deserialization, which will overwrite the default maximum of 1024.
2019-02-20 10:37:37 +05:00
Mathias R. Jessen 0a570211df Flatten interface hierarchy when generating properties that implement interface properties (#8382)
`TypeBuilder.GetInterfaces()` returns only the interfaces that was explicitly passed to its constructor, so we need to flatten the interface hierarchy in order to properly support inherited interfaces.
2019-02-19 15:02:34 -08:00
Reece Dunham c14d5dd67f Remove some of the last AppVeyor references (#8867)
This removes some of the last mentions of the AppVeyor name.  Don't change the title, we don't want the word to appear in the CLs
Also problem: the last references are in the changelogs but I don't want to modify them without committee approval.  

## PR Context  

it was removed, #8686
2019-02-19 12:44:00 -08:00
Travis Plunk 60ab54d737
Port DotNet fixes from 6.1.3 (#8914)
Addresses CVE-2019-0657
2019-02-19 10:45:40 -08:00
Reece Dunham 6cab2b474d Remove yet another appveyor reference (#8854) 2019-02-11 10:28:41 -08:00
Reece Dunham 3ab7e2ec4d Remove extra AppVeyor environment check (#8709)
Removes a check for AppVeyor env

## PR Context  
AppVeyor removed (#8686  extension)
2019-02-08 10:57:41 -08:00
Steve Lee 26a58670c1 Enable creating relative symlinks on Windows with New-Item (#8783) 2019-02-07 11:44:23 -08:00
Bruce Payette 6bc6257a55 Allow .exe files to be used as IL binary modules (#7281)
Fix for #6741 Allow .exe files to be used as binary modules. Basically anywhere a .dll could be used with modules, you can now use a .exe file. Also did a little clean up, replacing constant strings with the StringLiteral values instead.
2019-02-07 11:24:06 -08:00
Joel Sallow (/u/ta11ow) 130298bfae Parse numeric strings as numbers again during conversions (#8681) 2019-02-04 12:22:05 -08:00
Travis Plunk 003a141f31
Remove directory causing static analysis failure (#8812)
Remove directory causing static analysis failure
2019-02-01 18:03:12 -08:00
Steve Lee 313c8c06a1 Enable Write-Information to accept $null (#8774) 2019-01-31 13:16:34 -08:00
Reece Dunham 9e4e50a84e Remove appveyor functions from New-DockerTestBuild.psm1 (#8756) 2019-01-31 11:15:31 -08:00
Joshua T c935bce1ac Adding parameter "ReplyTo" to Send-MailMessage (#8727) 2019-01-30 16:33:15 -08:00
Paul Higinbotham f3efcab91e Change xUnit RunspaceTests to run sequentially (#8796) 2019-01-30 14:12:26 -08:00
pougetat 1d7651f233 Fix Get-Help PSTypeName issue with -Parameter when only one parameter is declared (#8754) 2019-01-30 08:55:33 -08:00
Ilya 5097e2ae1f Fix cleanup config files for the csharp xUnit tests (#8761) 2019-01-29 17:24:18 -08:00
Reece Dunham 5581c0a0ed Update some info in md-link-checks (#8757) 2019-01-29 08:54:23 +05:00
Travis Plunk b779b88c79
Merge `release-v6.2.0-preview.4'
# Conflicts:
#	test/Test.Common.props
#	tools/packaging/packaging.psm1
2019-01-28 13:50:00 -08:00
Joel Sallow (/u/ta11ow) db1b309800 Correctly Report impact level when SupportsShouldProcess is not set to 'true' (#8209)
Major changes are:
- Make all commands return 'ConfirmImpact.None' if `SupportsShouldProcess` is not set to `true`.
- Update some cmdlets to explicitly use `ConfirmImpact.Low`.
- Update `DefaultCommands.Tests.ps1` to test for 'ConfirmImpact' level.
2019-01-26 03:12:00 -08:00
Mark Kraus ff83206e1c Fix Request Charset Issues in Web Cmdlets (#8742)
Instantiating a new MediaTypeHeaderValue object fails when the -ContentType parameter includes a charset such as application/json; charset=utf-8. This makes it impossible to set the content encoding on web requests. Moving to Parse() ensures we actually get a proper MediaTypeHeaderValue when the charset is present, thus allowing users to set their request encoding via proper -ContentType values.
2019-01-26 12:48:47 +05:00
Aditya Patwardhan 6ccbebda27 Improve check for developer mode by checking minimum required build number (#8749)
* Improve check for developer mode by checking minimum required build number

The test would fail if the developer mode is enabled but the machine has an older build than the minimum required build.
The change adds a check for the build version in the test.

* Update test/powershell/Modules/Microsoft.PowerShell.Management/New-Item.Tests.ps1
2019-01-25 13:14:29 -08:00
Sergey Vasin a9841d98fa Make Join-String -InputObject 1,2,3 result equal to 1,2,3 | Join-String result (#8611)
Make `Join-String -InputObject 1,2,3` result equal to `1,2,3 | Join-String` result.

Fix #8610
2019-01-24 12:53:37 -08:00
xtqqczze 863528881f Use https in URLs where available (#8622)
Use https in URLS across the repository where the domain serves content by https.
2019-01-24 12:50:11 -08:00
dependabot[bot] 60edeb2c76 Build(deps): Bump XunitXml.TestLogger from 2.0.0 to 2.1.26 (#8731) 2019-01-24 11:01:24 -08:00
Steve Lee 3a8205018e Fix Enter-PSHostProcess test to wait until runspace is ready before attempting to enter (#8725)
This fixes CI test failure in Windows build.
2019-01-23 15:07:34 -08:00
Steve Lee 7e2cd7954f Add the experimental feature for creating 'Temp:\' drive when FileSystemProvider initializes (#8696)
Adds Experimental Feature called `PSTempDrive` that, if enabled, creates a PSDrive called `Temp:` that maps to `[System.IO.Path]::GetTempPath()`.
2019-01-23 13:53:04 -08:00
Dongbo Wang 9ceddc0dfe
Refactor ConvertTo-Json to expose JsonObject.ConvertToJson as a public API (#8682)
We have the public API `JsonObject.ConvertFromJson` to convert from JSON string in the PowerShell context. It would be good to have a public API for conversion to JSON. This PR refactors the `ConvertTo-Json` cmdlet to move the core implementation to `JsonObject.ConvertToJson`, and make `ConvertTo-Json` call that public method.

This would help the Azure Function PowerShell worker. Currently, we depends on [calling the cmdlet](729710d259/src/PowerShell/PowerShellManager.cs (L198-L205)) to convert object to JSON which is expensive. Once we have the public method `JsonObject.ConvertToJson` exposed, we can call the API directly to avoid a command invocation.

# Conflicts:
#	test/Test.Common.props
2019-01-23 10:41:19 -08:00
Dongbo Wang c606b1ca37 Refactor ConvertTo-Json to expose JsonObject.ConvertToJson as a public API (#8682)
We have the public API `JsonObject.ConvertFromJson` to convert from JSON string in the PowerShell context. It would be good to have a public API for conversion to JSON. This PR refactors the `ConvertTo-Json` cmdlet to move the core implementation to `JsonObject.ConvertToJson`, and make `ConvertTo-Json` call that public method.

This would help the Azure Function PowerShell worker. Currently, we depends on [calling the cmdlet](729710d259/src/PowerShell/PowerShellManager.cs (L198-L205)) to convert object to JSON which is expensive. Once we have the public method `JsonObject.ConvertToJson` exposed, we can call the API directly to avoid a command invocation.
2019-01-23 10:39:12 -08:00
Travis Plunk c4b2105a73 Merged PR 6648: Bump SDK and Runtime Versions
Bump SDK and Runtime Versions
  - Also, fix alpine docker file
  - Also, fix extra files being added to some Modules after these changes
2019-01-23 02:18:44 +00:00
Aditya Patwardhan 9e8f5bde33 Merged PR 6644: Update hosting tests and metadata.json for 6.2.0-preview.4 release
Update hosting tests and metadata.json for 6.2.0-preview.4 release
2019-01-22 21:43:47 +00:00
xtqqczze 1df96c7ed5 Remove broken HelpUri from CimTest (#8688) 2019-01-22 11:21:45 -08:00
Mark Kraus 2dd549e34b Fix Code Page Parsing Isssue in Invoke-RestMethod (#8694) 2019-01-22 10:45:40 -08:00
Mark Kraus 67004aa224 Fix expect 100-continue Issue with Web Cmdlets (#8679)
Web Cmdlets will no longer forcibly remove Expect: 100-continue from web requests.
This was a legacy setting that needed to be there because of platform differences that have since been resolved in CoreFX.
2019-01-19 11:16:18 +05:00
Michael Klement 20919ee793 Allow 'name' as an alias key for 'label' in ConvertTo-Html, allow the 'width' entry to be an integer (#8426) 2019-01-18 11:02:22 -08:00
Mathias R. Jessen 59a3696f70 Allow user-specified underlying type for enums (#8329)
Fix #8028 

This change adds support for specifying the underlying type for an enum:

```powershell
enum MyEnum : long 
{
  A = 0x0FFFFFFFFFFFFFFF
  B
}
# or
enum MyByte : byte 
{
  A = 0x01
  B = 0x02
  C = 0x03
  D
}
```
2019-01-17 14:22:10 -08:00
Reece Dunham f29a04c1bd Remove appveyor environment checks (#8669) 2019-01-17 12:33:35 -08:00
Reece Dunham 41e63f6546 Create Support File (#8618) 2019-01-17 12:25:07 -08:00
Reece Dunham 9eb6fc927d docs(contributing): add link check information (#8659) 2019-01-16 15:30:55 -08:00
pougetat 4858afb613 Resolve :PAGER' if its path contains spaces (#8571) 2019-01-16 15:14:44 -08:00
PRASOON KARUNAN V 6b3e06893a Adding tests for PSDiagnostics Module (#8431) 2019-01-16 14:59:35 -08:00
Travis Plunk 03cd3a2548
Increase diagnosability of Link Checker failures (#8667)
Also use ThreadJobs for better perf
2019-01-16 14:28:10 -08:00
Ilya 782ef99465
Add support enum and char types in Format-Hex cmdlet (#8191) 2019-01-16 16:58:22 +05:00
Kirk Munro 41d9667307 Add -Stable to Sort-Object and related tests (#7862) 2019-01-15 17:14:39 -08:00
Sergey Vasin 279993bf39 Change Get-Help cmdlet -Parameter parameter so it accepts string arrays. (#8454) 2019-01-15 16:25:49 -08:00
Dongbo Wang c2dfae8ccb Fix 'FixupFileName' to not load resolved assembly during module discovery (#8634) 2019-01-15 16:22:25 -08:00
Travis Plunk 7bf4641444
Fix broken urls (#8653)
Fix broken URL
  - Also, move other static analysis tests into that CI.
  - Also, make the link analysis a pester test (partly to make sure the step fails in case of an error)
2019-01-15 16:20:45 -08:00
xtqqczze 6126624b63 Revise use of Start-Sleep cmdlet (#8633)
* Avoid use of sleep alias (follow-up to #8546)
* Specify default parameter name
* Shorten overly specific comments
2019-01-15 12:31:52 +05:00
Steve Lee c3cb6df809 Update 'CommandNotFound' fuzzy suggestion to only return unique results (#8640) 2019-01-14 14:28:15 -08:00
Jani 812456f84c Improve Start-Sleep cmdlet to accept fractional seconds (#8537) 2019-01-14 10:04:44 -08:00
Steve Lee 6fa5195589 Update fuzzy test to fix daily build (#8629) 2019-01-11 16:45:49 -08:00
Steve Lee 71e58f9439 Add the experimental feature 'PSUseAbbreviationExpansion' to support tab completion on abbreviated command names (#8109) 2019-01-10 16:11:43 -08:00
Steve Lee b87cd1c0a3 Add support to show suggestions on CommandNotFound exception (#8458)
* support fuzzy matching with get-command and on CommandNotFound exception, show suggestion
* fix CodeFactor issues
* change algorithm to use Damerau-Levenshtein Distance which is more useful in finding close matches
2019-01-10 13:35:30 -08:00
Steve Lee 9793ed2c68 Change hashtable to use OrdinalIgnoreCase to be case-insensitive in all Cultures (#8566)
Ubuntu18.04 seems to default to C.UTF-8 for LANG (representing InvariantCulture) which results in a case-sensitive hashtable since CurrentCultureIgnoreCase doesn't work for that culture. Fix is to use OrdinalIgnoreCase instead.
2019-01-10 09:11:43 +05:00
Kirk Munro 1729a682ee Make S.M.A.PowerShell.GetSteppablePipeline method public (#8055)
* make GetSteppablePipeline method public
* updated PowerShell member count
2019-01-09 15:31:09 -08:00
Ilya 6647b29f41
Fix LiteralPath in Import-Csv to bind to Get-ChildItem output (#8277)
Added new tests.
2019-01-09 18:49:15 +05:00
Michael Klement 73716e9792 Make scriptblock-based calculated properties work again in ConvertTo-Html (#8427) 2019-01-09 13:55:03 +05:00
Sergey Vasin 6f071f0ba5 Fix Join-String cmdlet FormatString parameter logic (#8449) 2019-01-09 11:06:20 +05:00
Steve Lee d6000fdea8 Allow Windows users in developer mode to create symlinks without elevation (#8534) 2019-01-08 10:43:24 -08:00
Steve Lee 64fcddcb53 Help function should only pass content to pager if content was found (#8528) 2019-01-08 09:56:56 -08:00
Steve Lee 031cbf0f16 Change clear-host to simply called [console]::clear and remove clear alias from Unix (#8603)
Based on @PowerShell/powershell-committee decision, standardizing on [Console]::Clear() on all platforms and removing clear alias on non-Windows.
2019-01-08 22:38:56 +05:00
Dongbo Wang 4a63201139 Remove 'en-us' from our doc links (#8602) 2019-01-07 17:11:17 -08:00
Steve Lee d51b5fdc30 help function shouldn't use pager for AliasHelpInfo (#8552) 2019-01-07 13:39:57 -08:00
Kirk Munro 23f6e8ff40 Add S.M.A.PowerShell.Create method overload with Runspace argument (#8057) 2019-01-07 11:04:42 -08:00
Ilya b8f9532b41 Style: Use the type alias 'string' instead of 'String' in places that are appropriate (#8573) 2019-01-07 10:46:00 -08:00
xtqqczze 379cbb60cd Correctly capitalize the ForEach operator in *.ps1 (#8583) 2019-01-06 17:00:56 +05:00
xtqqczze f0f301bc5e Avoid use of mkdir alias in *.ps1 and *.psm1 (#8582) 2019-01-04 14:31:24 +05:00
xtqqczze 1a3aadfc4e Regularize redirection operator spacing in *.ps1 and *.ps1m (#8581)
Add space after redirection operator.
2019-01-03 12:59:14 +05:00
Ilya dfd2f69369
Style: Change 'String.' to 'string.' (#8568) 2018-12-31 20:44:16 +05:00
Ilya f31750c0d1
Fix typo in AMSI test (#8561) 2018-12-29 18:16:50 +05:00
xtqqczze 70de294fea Remove use of cmdlet aliases from .\test\powershell (#8546) 2018-12-28 13:48:23 +05:00
xtqqczze b850d57c78 Style: Remove preceding spaces from C# preprocessor-type keywords (#8540) 2018-12-26 11:59:10 +05:00
Ilya d8af22c33b
Style: Change 'Byte{}' to 'byte[]' (#8525) 2018-12-24 11:23:18 +05:00
Steve Lee 4af3068566 Code cleanup: Add space after closing brace where needed (#8530)
* Update TestService

* Update WebListener

* Update Controllers

* Update ExpTest

* Update MyApp

* Update Logic

* Update Logic

* Update MyApp

* Update Microsoft.Management.Infrastructure.CimCmdlets

* Update Microsoft.PowerShell.Commands.Diagnostics

* Update Microsoft.PowerShell.ScheduledJob

* Update Microsoft.WSMan.Management

* Update Microsoft.WSMan.Runtime

* Update ResGen

* Update TypeCatalogGen

* Update commands

* Update Eventing

* Update Reader

* Update utility

* Update ShowCommand

* Update trace

* Update WebCmdlet

* Update Common

* Update CoreCLR

* Update common

* Update format-object

* Update format-wide

* Update out-file

* Update out-printer

* Update out-string

* Update OutGridView

* Update LocalAccounts

* Update Commands

* Update security

* Update CoreCLR

* Update DscSupport

* Update engine

* Update help

* Update logging

* Update namespaces

* Update security

* Update utils

* Update config

* Update perfCounters

* Update tracing

* Update cmdletization

* Update other

* Update cim

* Update xml

* Update CoreCLR

* Update common

* Update DefaultFormatters

* Update out-console

* Update out-textInterface

* Update DisplayDatabase

* Update Utilities

* Update COM

* Update ComInterop

* Update CommandCompletion

* Update debugger

* Update ExperimentalFeature

* Update hostifaces

* Update interpreter

* Update lang

* Update Modules

* Update parser

* Update runtime

* Update client

* Update commands

* Update common

* Update fanin

* Update server

* Update WireDataFormat

* Update Binding

* Update Operations

* Update interface

* Update cmdletization

* Update cim

* Update management

* Update WindowsTaskbarJumpList

* Update msh
2018-12-24 11:20:06 +05:00
Mathias R. Jessen 0e971a42bf Fix xml nesting bug in CustomSerializer.WriteMemberInfoCollection() (#8476)
WriteMemberInfoCollection() calls WriteEndElement() at most once, even if WriteStartElement() has been called more than once. This commit moves the WriteEndElement() call up immediately after the elements text value has been written.
2018-12-22 22:50:11 +05:00
Steve Lee 2eb7ca8309 Fix formatting of header of table when center aligned (#8497) 2018-12-22 12:57:44 +05:00
Dongbo Wang 2bfbcd4f07 Remove empty lines; correct space on closing square brackets, negative signs, and generic brackets (#8508) 2018-12-21 12:23:04 +05:00
Luke Jeremy 56fc426f8b Add -UseMinimalHeader to Start-Transcript to minimize transcript header (#8402) 2018-12-20 11:12:14 -08:00
Steve Lee 110f78b818 Add -RepeatHeader to Format-Table to enable repeating header for each screen full (#8481)
When using a screen reader or just getting the output of a table with lots of rows, the header is no longer on the screen and the columns may no longer make sense without the context.  This change adds a `-RepeatHeader` switch to `Format-Table` to enable re-outputting the header after every screen full (minus 1 row).  Expectation is that the user is piping the output to a pager (e.g. less) which uses the bottom row for pager information.  I followed the `AutoSize` parameter as the way to get the parameter from the cmdlet into the deep formatting object where it's needed.
2018-12-20 11:05:34 -08:00
Joel Sallow (/u/ta11ow) 64bbdbe61c Add Tests for ConfirmImpact Ratings (#8214) 2018-12-20 23:15:42 +05:00
Ilya c857392c34
Fix style issues in xUnit tests (#8465) 2018-12-18 21:11:21 +05:00
Ilya a9f106da58 Move xUnit tests in new folder (#8356)
## Motivation

I have a PR where there are many new xUnit tests.
It would also be useful to create new xUnit tests for public APIs.
The number of xUnit tests will increase and their ordering is required.

## PR Summary

- Move C# xUnit tests in new folder. This allows to put new xUnit tests in directory structure in accordance with directory structure where cs files are.
- Use an xUnit TestCaseOrderer attribute to sequentially process tests for `powershell.config.json`.
- Update README.md
- A race condition was fixed which allowed  to run all XUnit tests in single batch job.
2018-12-13 14:22:07 -08:00
Aditya Patwardhan 551ed10b36 Fix EnvironmentVariable test and add missing null check in CommandHelpProvider (#8408)
* Disable NewItemUnauthorizedAccessError tests.
* Added expected value for $env:HOMEPATH for user with temporary profile.
* Added a missing null check in CommandHelpProvider.cs
2018-12-11 14:20:22 -08:00
Aditya Patwardhan ee5fc080e2 Remove dotnet dependency to start WebListener (#8390)
WebListener.exe (which was already being built) is sufficient to start web listener. Remove the dependency on `dotnet` being present to start the web listener.

Use `Start-Process` instead of `Start-Job` to launch the WebListener.
2018-12-11 14:15:32 -08:00
Steve Lee f17601298b Reset output attributes if column had ESC char when using Format-Table; Replace ... with unicode ellipsis (#8326)
change ellipsis when truncating to single unicode character
reset console output if previous column contains ESC
update existing format-table tests

If content included a VT100 ESC sequence (like changing color), this affected all output after that cell in the table.  Fix is to detect that a cell contained ESC and reset the console after it.  Also, change the 3 character ellipsis `...` to use the single unicode character `…` so that more text is available.

Fix https://github.com/PowerShell/PowerShell/issues/7767
2018-12-11 13:56:46 -08:00
Aditya Patwardhan 1d32d05157 Merged PR 6201: Update docs and csproj version
Update docs and csproj version
2018-12-07 18:24:07 +00:00
Dongbo Wang 2dcf52f3fc
Update folder path for storing optimization profile and add test to validate loaded assemblies and libraries on startup (#8406)
- Update folder path for storing optimization profile file.
- Add test to validate loaded assemblies and libraries on startup.
2018-12-06 14:26:09 -08:00
Dongbo Wang c1e171622a
More changes and cleanup to reduce the startup time (#8396)
Major changes are:
- Rename `s_wasSystemPolicyDebugPolicy` to `s_allowDebugOverridePolicy` to make it less confusing. Also slightly refactor `HelperSecurity.psm1` and `ConstrainedLanguageDebugger.Tests.ps1` to remove unneeded code. There is no functional change in this commit.
- Remove the unneeded static property `IsInbox`, as PowerShell Core won't be shipped in-box with Windows in the foreseeable feature. Even if we do in future, we won't be needing it because Windows PowerShell will probably be gone by that time.
- Update 'BindRunspace' to avoid getting all commands and unneeded method calls.
- Avoid creating a `IsSafeValueVisitor` every time when `IsScriptBlockInFactASafeHashtable` runs.
2018-12-05 18:29:50 -08:00
Steve Lee 52aef57ab6 Add Enable-ExperimentalFeature and Disable-ExperimentalFeature cmdlets (#8318)
[breaking change]
Major changes are as follows:
- Add `Enable-ExperimentalFeature` and `Disable-ExperimentalFeature` cmdlets.
- Remove `-ListAvailable` from `Get-ExperimentalFeature`.
- Add `ArgumentCompleter` for `Get-ExperimentalFeature` cmdlet.
- Refactor some existing Experimental Feature tests.
- Make `ConfigScope` public and renamed `SystemWide` to `AllUsers`. Also update experimental feature code to prefer the current user config over the all user config.
2018-12-05 12:20:58 -08:00
Travis Plunk 142814c12a
Fix an intermittent failure in macOS logging tests (#8385)
Fix an intermittent failure in macOS logging tests
  - make tests wait for the correct number of log entries
  - make tests not fail with an `Index was outside the bounds of the array.` error
2018-12-03 14:29:49 -08:00
Aditya Patwardhan a62eb62701 Remove all reference to AppVeyor and Travis CI from docs (#8376) 2018-12-03 10:14:11 -08:00
Dongbo Wang a11810bf33
Improve powershell startup time (#8341)
Major changes are as follows:
- Avoid `SecuritySupport.IsProductBinary` and unnecessary AMSI/suspicious code scan at startup time
   - Update `CompiledScriptBlockData.IsProductCode` to avoid unnecessary calls to `IsProductBinary`, which attempts to retrieve catalog signature of the target file.
   - Update `PerformSecurityChecks` to skip AMSI and suspicious code scan for the `.psd1` file that contains a safe `HashtableAst` only.
- Use customized `ReadOnlyBag` instead of `ImmutableHashSet` so that we can avoid loading the `System.Collections.Immutable.dll` completely.
- Replace `SHA1` with `CRC32` when generating module analysis cache file name
   - This remove the loading of `System.Security.Cryptography.Algorithms.dll` at startup
- Move `ConvertFrom-SddlString` to C# to remove the `Utility.psm1` file.
- Crossgen `Microsoft.ApplicationInsights.dll` and enable tiered compilation
   - Even pwsh with crossgen assemblies spends a lot time in jitting at the startup, about `191.6ms` comparing with `24.7ms` for Windows PowerShell.
   - Jitting `Microsoft.ApplicationInsights.dll` takes about `51.6ms`.
   - By crossgen `Microsoft.ApplicationInsights.dll` and enable tiered compilation, the jitting time drops to about `98.9ms`.
2018-12-02 12:52:39 -08:00
Travis Plunk 2a469b7d0f
Revert "Remove workaround for fixed invalid json array deserializing bug (#8346)" (#8375)
Revert "Remove workaround for fixed invalid json array deserializing bug (#8346)"

This reverts commit 60a4e2f346.

This change caused the test which verified the functionality this workaround enabled, to start failing
2018-11-30 14:32:11 -08:00
Aditya Patwardhan 3794a5e39f
Created a csproj to pin test modules and updated build.psm1 accordingly (#8350) 2018-11-30 11:49:38 -08:00
Paul Higinbotham 743a964392 Fix Export-ModuleMember bug for scriptblocks having no context (#8363)
Export-ModuleMember cmdlet throws an exception if module functions are exported across language boundaries (Windows only).  But a scriptblock LanguageMode property can be null if the scriptblock is created without a PowerShell context, and this can happen through the PowerShell API called from C#.  In this case Export-ModuleMember throws erroneously when no language mode restrictions are in play.

Fix is to check if LanguageMode is null before comparing context and scriptblock language modes.
2018-11-30 11:45:33 -08:00
Aditya Patwardhan 13e2559392
Fix Get-Help for advanced functions with MAML help content (#8353) 2018-11-30 09:49:32 -08:00
Kirk Munro e721f7bbc3 Debug parameter now sets debugpreference to continue (#8195)
With this commit, users who invoke a command with -Debug will no longer be presented with a prompt asking them if they want to enter a nested prompt, continue execution, or halt execution entirely. Instead, any messages sent to the debug stream will simply be sent to the debug stream and the script will continue execution.
2018-11-30 19:46:51 +05:00
Adam Gauthier 60a4e2f346 Remove workaround for fixed invalid json array deserializing bug (#8346) 2018-11-30 16:49:33 +05:00
Mathias R. Jessen 950377faab Conditionally mark getter/setter implementations virtual in generated classes (#8303)
When implementing interfaces, PowerShell incorrectly produces non-virtual get/set methods for interface-defined properties.
This commit adds a lookup method for interface-defined properties and marks get/set methods for properties with matching signatures virtual.
2018-11-30 16:48:27 +05:00
PRASOON KARUNAN V 6e523f21eb Fix for PSDrive creation with a UNC path with a trailing backslash or forward slash when combined with -Persist (#8305) 2018-11-30 08:49:22 +05:00
Aditya Patwardhan 8c3de33ae1
Update help content for TabCompletion tests only if it does not exist (#8355) 2018-11-29 16:16:36 -08:00
Luke Jeremy 0cc1f06be4 Remove Persist parameter from New-PSDrive on non-Windows platform (#8291) 2018-11-29 19:02:08 +05:00
Paul Higinbotham 06571637e4 Add SkipCA and SkipCN check requirement to WinRM/OMI HTTPS connection (#8279) 2018-11-27 16:16:00 -08:00
Paul Higinbotham 6a388f0b7d Add fix for Start-Job initialization script should not be executed as trusted in system lockdown (#8284) 2018-11-26 10:38:13 -08:00
Joel Sallow (/u/ta11ow) 775552c0f5 Test-Path: Return $false when given an empty or $null -Path/-LiteralPath value (#8080) 2018-11-21 10:08:31 +05:00
Hubert Bukowski a8627b83e5 Token calculation fix for Get-Help executed on ScriptBlock for comment help. (#8238) 2018-11-20 11:11:17 -08:00
Aditya Patwardhan f27dfea065
Skip Enter-PSHostProcess tests on Appveyor due to PSReadline issue (#8317) 2018-11-20 10:17:33 -08:00
Aditya Patwardhan 82091d6a45
Merge release-v6.2.0-preview.2 to master
Merge Release-v6.2.0-preview.2
2018-11-15 17:59:42 -08:00
Steve Lee c5dd3bd2c9 Support 'Get-PSHostProcessInfo' and 'Enter-PSHostProcess' on Unix platforms (#8232)
There a some differences in support of named pipes for Windows and non-Windows.  Named pipes on Unix have a 104 character path limit.  On macOS, the `$env:TMPDIR` (on my system) is already 49 characters; corefx adds 12 more.  Since AppDomainName isn't really used, changed it from `DefaultAppDomain` to `None` to shorten the name.  Need to keep it since Windows PowerShell expects it.  Changed `starttime` part of pipe name to 8 hex characters which is to provide uniqueness to the pipe name.
2018-11-15 12:50:04 -08:00
Staffan Gustafsson 877b9a9fbf Add cmdlet 'Join-String' for creating text from pipeline input (#7660)
The cmdlet syntax is as follows:
```
Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]

Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-SingleQuote] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]

Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-DoubleQuote] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]

Join-String [[-Property] <pspropertyexpression>] [[-Separator] <string>] [-OutputPrefix <string>] [-OutputSuffix <string>] [-FormatString <string>] [-UseCulture] [-InputObject <psobject>] [<CommonParameters>]
```
2018-11-14 13:52:44 -08:00
Steve Lee 43e0394d51 Remove extra newlines from formatting which resulted in necessary double newlines (#8247) 2018-11-14 08:28:05 +05:00
Aditya Patwardhan 20497d19c2 Merged PR 5822: Update version for dependencies
Update version for dependencies
2018-11-14 01:56:28 +00:00
Travis Plunk 79f21b41de
Consolidation of all Windows PowerShell work ported to PSCore6 (#8257)
Consolidation of all Windows PowerShell work ported to PSCore6

* Added ps1 file import restriction.  Refactored InvokeLanguageModeTestingSupportCmdlet to HelpersSecurity module
* JEA loop back fix.  Debugger running commands in CL mode.
* Support for new AMSI codes.  Changed to use AMSI buffer API.  Unhandled exception fix.
* Fixes for module bugs while running in ConstrainedLanguage mode
* Untrusted input tracking work
* Configuration keyword bug fix, PSRP protocol version check for reconstruct reconnect, Sharing InitialSessionState in runspace pool.
* Restricted remote session in UMCI, Applocker detection collision, Help command exposing functions, Null reference exception fix.
* Added mitigation for debugger function exposure
2018-11-13 16:16:29 -08:00
Robert Holt aa76c6846d Fix incorrect name check when autoloading required modules (#8218) 2018-11-13 14:56:07 -08:00
Travis Plunk 18a181fc30
Fix CVE-2018-8415 (#8253)
If there is a null character in a scriptblock, translate it to a null replacement character before logging with scriptblock logging.
2018-11-13 11:30:48 -08:00
Travis Plunk db60f0614a Revert "Ignoring backspace for empty lines on stdin/stdout mode (#8196)" (#8239)
This reverts commit b525b1f0bd.
2018-11-12 13:14:04 -08:00
bugale b525b1f0bd Ignoring backspace for empty lines on stdin/stdout mode (#8196) 2018-11-10 18:55:28 +05:00
Paul Higinbotham d4bf5c87bc Fix tests running in Azure DevOps (#8220) 2018-11-09 15:11:02 -08:00
kwkam caad7ed471 Fix Rename-Item -Path with wildcard char (#7398) 2018-11-09 11:08:26 -08:00
Kevin Marquette 75fa6af9c0 Add test coverage for additional Get-Module parameters (#8137) 2018-11-07 17:16:53 +05:00
Paal Braathen 2e89efa1bc When using Start-Transcript and file exists, empty file rather than deleting (#8131) 2018-11-07 08:34:42 +05:00
Travis Plunk 5e47c73e27
Fix static secret in code (#8186) 2018-11-05 18:29:04 -08:00
Aditya Patwardhan b5ab2ddd40 Load assembly from module base path before trying to load from GAC (#8073)
[Breaking Change]
When a binary module has the module assembly in GAC, we load the assembly from GAC before trying to load it from module base path.

This change attempts to load it from module base path before looking up in GAC.
2018-11-05 10:41:53 -08:00
Andrew Schwartzmeyer 54874180ce Remove build and doc references to Git submodules (#8177)
As of #7892, the PowerShell repository no longer uses Git submodules.
This is fantastic from a workflow standpoint, and so all the notes about
how to deal with submodules (and all the build steps explicitly
initializing and updating submodules) can be safely removed.
2018-11-05 10:39:29 -08:00
Robert Holt 5d06fba366 Refactor module version/GUID comparison logic (#7125) 2018-11-01 13:41:51 -07:00
Travis Plunk c6910a12fa Fix conflict with Get-AdlStoreChildItem from az module in tab completion tests (#8167) 2018-11-01 12:03:03 -07:00
PRASOON KARUNAN V f59353d5d9 Error message enhancement for clear-content cmdlet when targeting a directory (#8134) 2018-11-01 08:56:45 +05:00
Steve Lee 1eec123f48 Create $PROFILE if it does not exist for -WorkingDirectory processing test (#8152) 2018-10-30 22:06:19 -07:00
Paul Higinbotham 20f3a6a337 Experimental feature: Implicit remoting batching perf improvement (#8038) 2018-10-30 09:55:39 -07:00
Steve Lee 1aa5bb3576 Honor -OutputFormat if specified in noninteractive, redirected, encoded command used with pwsh (#8115)
[Breaking Change]

There is specific code that sets the `OutputFormat` to xml if pwsh is run non-interactive, with redirected output, and the command was encoded.  However, it ignored whether OutputFormat was specified.  Fix is to track whether `-OutputFormat` was used and respect that value rather than defaulting to xml.

Fix https://github.com/PowerShell/PowerShell/issues/5912
2018-10-29 17:51:21 -07:00
Steve Lee b1e2745b53 move processing of -WorkingDirectory before processing of profiles (#8079) 2018-10-29 13:56:13 -07:00
dependabot[bot] b3f315eb15 Bump xunit from 2.4.0 to 2.4.1 (#8140) 2018-10-29 13:28:02 -07:00
dependabot[bot] cbfe2c8fe8 Bump xunit.runner.visualstudio from 2.4.0 to 2.4.1 (#8139) 2018-10-29 13:27:25 -07:00
Steve Lee b27380dc51 Enable case-insensitive tab completion for files and folders on case-sensitive filesystem (#8128) 2018-10-28 09:48:49 +05:00
Steve Lee 9141b11c5e Enable Set-Location -LiteralPath to work with folders named "-" and "+" (#8089) 2018-10-24 09:37:59 +05:00
Steve Lee 082c3b0bae Enable Add-Content to share read access to other tools while writing content (#8091) 2018-10-23 16:27:53 -07:00
Patrick Meinecke 57bf508fec Fix static method invocation type inference (#8018)
Fixes type inference for static method invocations (e.g. [powershell]::Create()).
2018-10-23 16:58:31 +05:00
Steve Lee 3ceb1c17ef Fix logic to not rely on build number to determine whether to output formatdata (#8063) 2018-10-19 12:45:03 -07:00
Steve Lee 4e5e3900f6 Allow dynamic parameter to be returned even if path matches nothing (#7957) 2018-10-18 11:44:08 -07:00
Ilya f1e2136a2b
Add -Name, -NoUserOverrides and -ListAvailable parameters to Get-Culture cmdlet (#7702)
Add new parameters in Get-Culture cmdlet:
-Name - to allow retrieving a specific culture
-NoUserOverrides - ignore user changes for current culture
-ListAvalable - to allow retrieving all cultures supported on the platform
2018-10-18 17:34:34 +05:00
Ilya 745e305ac5
Add new Offset and Count parameters to Format-Hex and refactor the cmdlet (#7877)
- Add new Offset and Count parameters.
- Modify ByteCollection class to support offsets up to UInt64.MaxValue size.
- Hide/obsolete Raw parameter because the behavior is by default.
- Optimize conversion to bytes to reduce allocations for large input data.
2018-10-18 10:03:59 +05:00
Joel Sallow 33f2f0faaf Add Type Inference for $_ / $PSItem in catch{ } blocks (#8020) 2018-10-18 09:42:16 +05:00
Aditya Patwardhan d99afc46df Merged PR 5382: Add missing dependency
Add missing dependency
2018-10-16 21:28:42 +00:00
Aditya Patwardhan 1e31e707c8 Merged PR 5363: Version and doc changes
Version and doc changes
2018-10-15 20:24:00 +00:00