Commit graph

2271 commits

Author SHA1 Message Date
xtqqczze 7cb8dc48ea Correct case of $HOME special variable 2020-01-13 19:33:43 +00:00
xtqqczze d0f28128f5 Correct case of $ExecutionContext special variable 2020-01-13 19:33:14 +00:00
xtqqczze b700c4631b Correct case of $InformationPreference special variable 2020-01-13 19:31:24 +00:00
xtqqczze ca4edaddd6 Correct case of $VerbosePreference special variable 2020-01-13 19:29:33 +00:00
xtqqczze 6affae574c Correct case of $DebugPreference special variable 2020-01-13 19:28:14 +00:00
xtqqczze 6d97b3a4a4 Correct case of $IsCoreCLR special variable 2020-01-13 19:27:48 +00:00
xtqqczze 94a73caa41 Correct case of $IsWindows special variable 2020-01-13 19:27:21 +00:00
xtqqczze 72d52b7d08 Correct case of $IsMacOS special variable 2020-01-13 19:26:54 +00:00
xtqqczze 17d0e931fa Correct case of $IsLinux special variable 2020-01-13 19:26:28 +00:00
xtqqczze 9e5bb4eee7 Correct case of $PSModuleAutoLoadingPreference special variable 2020-01-13 19:26:01 +00:00
xtqqczze bb58e2aab6 Correct case of $false special variable 2020-01-13 19:25:35 +00:00
xtqqczze 47a3b4e293 Correct case of $true special variable 2020-01-13 19:25:09 +00:00
xtqqczze 6014f4bac3 Correct case of $null special variable 2020-01-13 19:24:42 +00:00
xtqqczze 4a9d70fdcd Correct case of $PWD special variable 2020-01-13 19:24:10 +00:00
xtqqczze 62aee9356a Correct case of $PSScriptRoot special variable 2020-01-13 19:21:53 +00:00
xtqqczze 679702ba05 Correct case of $PSDefaultParameterValues special variable 2020-01-13 19:21:25 +00:00
xtqqczze b6a687bf21 Correct case of $error special variable 2020-01-13 19:19:39 +00:00
xtqqczze 42d50434f8 Correct case of $PSCmdlet special variable 2020-01-13 19:19:12 +00:00
xtqqczze a051666baf Correct case of $input special variable 2020-01-13 19:18:44 +00:00
xtqqczze 66e0f08ec2 Correct case of $this special variable 2020-01-13 19:18:14 +00:00
xtqqczze 6663261238 Correct case of $args special variable 2020-01-13 19:17:48 +00:00
xtqqczze 04b292ab3b Correct case of $LASTEXITCODE special variable 2020-01-13 19:15:45 +00:00
xtqqczze 89e33f5772 Correct case of $Matches special variable 2020-01-13 19:15:17 +00:00
xtqqczze f86f30cf64 Correct case of $NestedPromptLevel special variable 2020-01-13 19:13:53 +00:00
xtqqczze fbe459d480 Correct case of $OFS special variable 2020-01-13 19:05:05 +00:00
xtqqczze d58e1ff13b Correct case of $MyInvocation special variable 2020-01-13 19:04:32 +00:00
xtqqczze 4f5bb46268 Remove BOM, insert newline at EOF 2020-01-13 18:36:47 +00:00
xtqqczze 7d0e9f1299 Avoid variable names that conflict with automatic variables part 2 (#11559) 2020-01-13 20:14:31 +05:00
xtqqczze 743983390e Update pester syntax to v4 (#11544)
* Capitalize 'Should' command and fix whitespace

```powershell
$_ -ireplace '\s?\|\s?should\b',' | Should'
```

* Capitalise and apply hyphen to 'Not' parameter

```powershell
$_ -ireplace '(\| Should) not\b','$1 -Not'
```

* Capitalise and apply hyphen to 'Be' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -?be\b','$1 -Be'
```

* Capitalise and apply hyphen to 'BeExactly' parameter

$_ -ireplace '(\| Should(?: -Not)?) -?beexactly\b','$1 -BeExactly'

* Capitalise and apply hyphen to 'BeGreaterThan' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -?begreaterthan\b','$1 -BeGreaterThan'
```

* Use 'BeTrue' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?true\b','$1 -BeTrue'
```

* Use 'BeFalse' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?false\b','$1 -BeFalse'
```

* Capitalise and apply hyphen to 'Match' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?match\b','$1 -Match'
```

* Capitalise and apply hyphen to 'Throw' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?throw\b','$1 -Throw'
```

* Capitalise and apply hyphen to 'BeNullOrEmpty' parameter

```powershell
$_ -ireplace '(\| Should(?: -Not)?)\s-?benullorempty\b','$1 -BeNullOrEmpty'
```

* Capitalise 'Because' parameter

```powershell
$_ -ireplace '\s-because\b',' -Because'
```

* Fix 'BeNullOrEmpty'
2020-01-11 20:41:59 +05:00
xtqqczze 70d9ed4d55 Remove Unicode BOM from text files (#11546) 2020-01-11 12:15:34 +05:00
Paul Higinbotham b19e2b9d4c Various test fixes for debugger and remoting (#11528) 2020-01-08 16:23:38 -08:00
Aditya Patwardhan 0097802cee
Normalize line endings before comparing string in tests (#11499) 2020-01-08 13:33:28 -08:00
James Truher [MSFT] 57da778205 DSC test fixes for Alpine and Raspbian (#11508) 2020-01-07 16:57:08 -08:00
Paul Higinbotham f22bad1d58 Fix SSH remoting test to work on all platforms (#11500) 2020-01-07 14:01:06 -08:00
Ilya e8d472b65b Ignore headers with null values in web cmdlets (#11424) 2020-01-07 12:25:30 -08:00
Thomas Nieto b25e67e607 Remove RequireLicenseAcceptance default value (#11512) 2020-01-07 11:43:58 -08:00
xtqqczze 88711d4196 Allow error 504 (Gateway Timeout) in markdown-link tests (#11439) 2020-01-06 12:18:20 -08:00
spongemike2 1376d310bb Make web cmdlets skip processing the content headers with a null or empty value for backward compatibility (#11421) 2020-01-06 12:11:55 -08:00
Ilya 99cf9fd859
Re-balance CI tests (#11420) 2020-01-05 13:01:42 +05:00
Ilya b221c2afa2
Correct pwsh run (#11486) 2020-01-05 12:17:41 +05:00
xtqqczze 08d6be9039 Include url in the markdown-links test error message (#11438) 2020-01-03 10:40:27 -08:00
Andrew ea48e07c48 Added setting to disable implicit WinPS module loading (#11332) 2020-01-03 10:32:00 -08:00
xtqqczze ee71081432 Use CIM cmdlets instead of WMI cmdlets in tests (#11423) 2020-01-03 10:24:06 -08:00
Steve Lee 5b42126f7c Don't format exceptions that aren't ErrorRecords (#11415)
* In one of the previous PRs for ConciseView, System.Exception was incorrectly added to the typenames handled by the ErrorRecord formatting. This results in just Exception objects written to the console to not be rendered since the ErrorRecord formatting didn't handle this situation. Fix is to remove the line to add that type putting it back to how it was previously. 

* Also made the handling of ErrorRecord a bit more robust just in case Exception.Message doesn't exist nor a Message property.
2019-12-21 09:45:44 +05:00
Aditya Patwardhan 2dbb5717ce Make null member access tests as string to avoid parsing errors (#11385)
* Make null member access tests as string to avoid parsing errors

* Add PSNullConditionalOperators feature to testmetadata.json

* Add Parsing tests to be skipped

* Add tabcompletion tests
2019-12-21 00:14:07 +00:00
Steve Lee 27e1664e52 Add retry to Enter-PSHostProcess test (#11360) 2019-12-20 15:35:50 -08:00
Aditya Patwardhan ed27f36223
Fix test failing when UnixStat feature is disabled (#11370) 2019-12-20 15:32:50 -08:00
Paul Higinbotham e81bd1dfda Re-add check for Invoke-Command job dispose. (#11388) 2019-12-20 12:13:34 -08:00
xtqqczze 7a7365279c Avoid variable names that conflict with automatic variables (#11392) 2019-12-20 12:09:03 -08:00
Joel Sallow (/u/ta11ow) 7b33cfe847 Test-Connection: Fallback to hop IP Address on -Traceroute without -ResolveDestination (#11335) 2019-12-19 09:51:34 -08:00
Ilya 54e6199bbb Use invariant culture string conversion for -replace operator (#10954) 2019-12-19 09:50:46 -08:00
Aditya Patwardhan a24a5c7c5b Update hosting tests to use the SDK version from the build property (#11368) 2019-12-18 14:08:27 -08:00
Steve Lee 563b1cba83 Add trailing line number to filename for ConciseView (#11391) 2019-12-18 14:05:56 -08:00
Ilya dfb5b047b1
Revert "Update formatter to not write newlines if content is empty (#11193)" (#11342)
This reverts commit 51d2523f5f.
2019-12-18 00:53:19 +05:00
Steve Lee edd3e7680c Move Set-StrictMode to outer scriptblock for ErrorView (#11381) 2019-12-17 23:43:47 +05:00
Tyler James Leonhardt ca202da643 Improvements in breakpoint APIs for remote scenarios (#11312) 2019-12-12 17:23:12 -08:00
Steve Lee 03f10f052d Add -AsPlainText to ConvertFrom-SecureString (#11142) 2019-12-11 15:40:41 -08:00
Dongbo Wang 5605bf4195 Fix a regression in formatting caused by the FirstOrDefault primitive added in 7.0.0-Preview1 (#11258) 2019-12-11 15:37:18 -08:00
Steve Lee ed1f6e3144 Make approved features non-experimental (#11303) 2019-12-10 15:41:43 -08:00
Andrew 0c46e3e71d Added WindowsPS version check for WinCompat (#11148) 2019-12-10 10:40:13 -08:00
Steve Lee 6e4da244c5 Update ConciseView to use TargetObject if applicable (#11075) 2019-12-10 09:50:51 -08:00
Dongbo Wang 25895e34b8 Fix NullReferenceException in CompletionCompleters public methods (#11274) 2019-12-10 09:51:01 +05:00
Steve Lee 20a236b228 Update setting PSModulePath to concatenate the process + machine env var (#11276) 2019-12-09 16:25:08 -08:00
Andrew f8a321ae2b Fix error-reporting in some WinCompat scenarios (#11259) 2019-12-09 15:20:40 -08:00
Ilya 95c472a8c2 Add native binary resolver (#11032) 2019-12-09 12:03:53 -08:00
Ilya 12bf5306e2 Add null host name check in WSMan (#11288) 2019-12-09 10:52:03 -08:00
Steve Lee ee4eba5348 Update calculation of char width to respect CJK chars correctly (#11262) 2019-12-05 08:09:56 +05:00
Aditya Patwardhan 8e76ad00e2 Bump .NET to 3.1.0 (#11260) 2019-12-04 13:17:16 -08:00
Ilya 42f21ae6a0
Cleanups in command discovery (#10815)
* Enable nullable, make minor cleanups, add a test
* Reduce allocations in GetAliasTable()
* Remove searching by extensions on Unix
2019-12-03 11:23:36 +05:00
Travis Plunk 3cdab0d18d
Add Unblock-File for macOS (#11137) 2019-12-02 17:51:36 -08:00
Brendan Burns d38541fdce Add an implementation of Stop-Computer for Linux and macOS (#11151) 2019-12-02 17:29:11 -08:00
M1kep 570ba43a24 Allow CompleteInput to return results from ArgumentCompleter when AST or Script has matching function definition (#10574) 2019-12-02 10:51:13 -08:00
Steve Lee 51d2523f5f Update formatter to not write newlines if content is empty (#11193) 2019-12-02 10:51:02 -08:00
Ilya 2ee1760342 Fix regression in Get-PSCallStack (#11210) 2019-12-02 10:43:35 -08:00
David Smatlak 3923ca1728 Fixes FWLinks for PS7 online help documents (#11071) 2019-12-02 10:25:56 -08:00
Dongbo Wang d46dfc26b7
Do not resolve types from assemblies that are loaded in separate AssemblyLoadContext (#11088) 2019-11-26 12:40:16 -08:00
Travis Plunk b60381f922 Update macOS minimum version (#11163) 2019-11-24 17:41:53 +05:00
Steve Lee a1c2d3c977 Fix detection of $PSHOME in front of $env:PATH (#11141) 2019-11-23 15:17:08 -08:00
Travis Plunk 72780f333e
Make unreliable DSC test pending (#11131) 2019-11-22 14:18:41 -08:00
Steve Lee 2f672538b2 Add Type member to Exceptions containing type of exception for Get-Error (#11076) 2019-11-22 12:57:52 -08:00
Ilya 8d944fdec2
Write an error if argument is a directory in Get-FileHash cmdlet (#11114) 2019-11-21 15:15:19 +05:00
Steve Lee 0aaced35ad Update Get-Error to not modify the original $Error object (#11125) 2019-11-21 15:14:33 +05:00
Steve Lee 9b71696e33 Add OutputType to Get-Error cmdlet and preserve original typenames (#10856)
- Added OutputType attribute. 
- Cmdlet adds the PSExtendedError typename and removes Exception and ErrorRecord typenames so that the formatting is used. The formatter then removes PSExtendedError and puts back the original typename so that $Error should be the same before calling Get-Error. 
- While testing, had to make some changes to how InvocationInfo is retrieved so that ParseException which contains a nested ErrorRecord which as InvocationInfo is handled correctly. 
- Combined Exception and ErrorRecord formatter into one.
2019-11-19 08:54:58 +05:00
Joel Sallow (/u/ta11ow) 440837944a Test-Connection - Improve Logic and Output (#10697) 2019-11-18 11:32:59 -08:00
Andrew b218e6f6cc Support using non-compatible Windows PowerShell modules in PowerShell Core (#10973) 2019-11-18 10:44:55 -08:00
Steve Lee 2e553038c5 Allow pwsh to inherit $env:PSModulePath and enable powershell.exe to start correctly (#11057) 2019-11-15 17:29:04 -08:00
James Truher [MSFT] fe712f8de2 Experimental Feature: Provide Unix stat information in filesystem output (#11042) 2019-11-15 17:26:11 -08:00
Greg Smulko f32ae64b8b Support multi-line code blocks in examples (#10776) 2019-11-15 17:24:16 -08:00
Ilya ff37337f95 Add Culture parameter to Select-String cmdlet (#10943) 2019-11-15 17:07:39 -08:00
Paul Higinbotham bd0e30dec1 Fix Start-Job working directory path with trailing back slash (#11041) 2019-11-15 17:05:27 -08:00
Aditya Patwardhan 2579c00a20 Support null-conditional operators ?. and ?[] in PowerShell language (#10960) 2019-11-15 16:39:53 -08:00
Robert Holt ad12b14517 Stop blindly setting $? to true for ParenExpression, SubExpression and ArrayExpression (#11040) 2019-11-15 11:57:45 -08:00
Ilya fe40fbf6e1 Unload test modules (#11061) 2019-11-14 17:54:48 -08:00
Aditya Patwardhan 8fcd772353 Bump .NET core framework to 3.1-preview.3 (#11079) 2019-11-14 17:06:46 -08:00
Daniel Sturm 9e02343b18 ConvertFrom-Json: Unwrap Collections by default (#10861) 2019-11-14 16:41:00 -08:00
Joel Sallow (/u/ta11ow) 57a4d4c721 Group-Object - Use Case-Sensitive Hashtable for -CaseSensitive -AsHashtable (#11030)
Prior to this change, Group-Object -AsHashtable -CaseSensitive would give a key duplication error when given entries that only differ by casing. This was due to always using a case-insensitive hashtable, despite the request for -CaseSensitive behaviour.
2019-11-13 09:16:45 +05:00
Steve Lee e185f89591 Handle exception if enumerating files fails when rebuilding path to have correct casing (#11014) 2019-11-12 08:53:33 -08:00
Steve Lee 2a45ccc787 Fix ConciseView to show Activity instead of myCommand (#11007)
ConciseView shows MyCommand as the prefix to the error message, but for a scriptblock, MyCommand is the whole scriptblock. Fix is to use CategoryInfo.Activity if available first. Also handle case where it's a script function by seeing if it's a command and showing MyCommand in that case rather than the Activity.
2019-11-10 16:21:10 +05:00
Steve Lee c679536bb8 Increase time between retries of testing URL (#11015) 2019-11-08 20:28:06 +00:00
Vincent Damewood 04a1fc3b74 Allow Web Cmdlets to Ignore HTTP Error Statuses (#10466)
* Add -SkipHttpErrorCheck to web request cmdlets

The -SkipHttpErrorCheck flag causes web request cmdlets
(Invoke-WebRequest and Invoke-RestMethod) to ignore HTTP statuses that
are error statuses and treat them as successful requests. This allows
users to handle the responses using their own error handler and gives
them access to the full, unmodified response body and headers.

* Add -ResponseStatusVariable to Invoke-RestMethod

This allows the user to specify a variable to set to the integer value
of the respons's status code, Analogous to using
-ResponseHeadersVariable to retrieve the headers of the response. This
can be used to distinguish error messages from success messages when
used with -SkipHttpErrorCheck.

* Fix coding-style error

The summary for the SkipHttpErrorCheck property didn't conform
to style guidelines. This changes the summary to start with
"Gets or sets".

* Add tests for -SkipHttpErrorCheck

This flag supresses terminating errors on web cmdlets.
The tests are written to check that it properly
supressed the errors.

* Add test for -StatusCodeVariable

Th -StatusCodeVariable parameter specifies an output
variable for the status code with Invoke-RestMethod.
This test makes sure it functions properly.

* Fix typos and style for -SkipHttpErrorCheck tests

Variables had different cases from each other and some parameter
names were lower case.

* Fix typos and style for -StatusCodeVariable test

Variables had different cases from each other and some parameter
names were lower case.

* Add failure tests when missing -SkipHttpErrorCheck

These tests ensure that Web Cmdlets fail when -SkipHttpErrorCheck
is missing.

* Clean up tests for -SkipHttpErrorCheck

Per discussion on the pull requests. This commit fixes up
style problems with the tests for -SkipHttpErrorCheck.

* Add more status tests for -StatusCodeVariable

Previously, the -StatusCodeVariable flag in Invoke-RestMethod
only had tests for 200 status. This commit adds tests for 404
and 500 statuses and removes -SkipHttpErrorCheck from the 200
check.

* Fix response body in -StatusCodeVariable test

The test was copy/pastes from the 200 status test. The body
indicated success. This commit fixes that so it is also an
error indicator.
2019-11-07 12:38:24 -08:00
Steve Lee ef64321db9 Fix piping more than one CommandInfo to Get-Command (#10929) 2019-11-07 11:59:24 -08:00
Ilya 9851b07b1d Fix style issues (#10998) 2019-11-07 11:49:06 -08:00
Aditya Patwardhan 08e120ca2b
Bump .NET core framework to 3.1-preview.2 (#10993) 2019-11-07 11:45:17 -08:00
Ilya d58a82ad19
Cleanup: use the built-in type alias (#10882) 2019-11-06 08:47:32 +05:00
Steve Lee 7ddfb825e4 Add back Get-Counter cmdlet for Windows (#10933) 2019-11-05 16:48:11 -08:00
Dongbo Wang 518a479909 Make ConvertTo-Json treat [AutomationNull]::Value and [NullString]::Value as $null (#10957) 2019-11-05 14:32:52 -08:00
Steve Lee baf24102ff Fix crash if command sent to pwsh is just whitespace (#10977) 2019-11-04 14:59:52 -08:00
Steve Lee b74a26bb91 Added cross-platform Get-Clipboard and Set-Clipboard (#10340)
Co-Authored-By: Ilya <darpa@yandex.ru>



Co-Authored-By: Ilya <darpa@yandex.ru>
2019-11-04 11:28:58 -08:00
Steve Lee 4b8462766f Fix setting original path of filesystem object to not have extra trailing slash (#10959) 2019-11-02 22:09:08 +05:00
Steve Lee 70ab772da7 Support $null for convertto-json (#10947)
ConvertTo-Json doesn't allow $null to be passed in even though it can be valid resulting json. Fix is to remove the check that the input is not null. NewtonSoft.Json handles it just fine.
2019-11-01 23:54:31 +05:00
Steve Lee 6882ad56fd Add back Out-Printer command (#10906) 2019-11-01 11:27:12 -07:00
Steve Lee 4b9c2b2008 Fix Start-Job -WorkingDirectory with whitespace (#10951) 2019-11-01 11:09:00 -07:00
Dongbo Wang 8749db9b81 Improve processing of the powershell built-in type data from 'types.ps1xml', 'typesV3.ps1xml' and 'GetEvent.types.ps1xml' (#10898) 2019-11-01 10:36:05 -07:00
Steve Lee a3d73d751f Handle IO Exception as non-terminating (#10950) 2019-11-01 10:06:40 -07:00
Steve Lee ca68d9dbc5 Add GraphicalHost assembly to enable Out-GridView, Show-Command, and Get-Help -ShowWindow (#10899) 2019-11-01 10:05:32 -07:00
PRASOON KARUNAN V 5a76137d14 Take ComputerName via Pipeline in Get-HotFix (#10852)
* add process record for Get-hotfix
* update new FWLink
2019-11-01 08:02:19 +05:00
Steve Lee df811929eb Fix tab completion for parameters so that it shows common parameters as available (#10850) 2019-10-31 13:09:37 -07:00
Dongbo Wang 7772418dec Update PSConfiguration.ReadValueFromFile to make it faster and more memory efficient (#10839) 2019-10-30 14:44:34 -07:00
Ilya 46957e54d0 Set working directory to current directory in Start-Job (#10920) 2019-10-30 14:22:45 -07:00
Steve Lee f48a28eff2 Change TabExpansion2 to not require -CursorColumn and treat as $InputScript.Length (#10849)
* FEATURE: Change TabExpansion2 to not require `-CursorColumn` and treat as `$InputScript.Length`

* address Jason's feedback
2019-10-30 20:45:28 +00:00
Steve Lee 0b12ea057a Add back Update-List command (#10922) 2019-10-30 11:05:30 -07:00
romero126 fab1e12fb7 Update tests to accurately describe test actions. (#10928) 2019-10-30 09:13:55 +05:00
Sean Wheeler 0faa60168b Update FWLink Id for Clear-RecycleBin (#10925) 2019-10-29 22:14:09 +05:00
Steve Lee ca1b6fb4c5 Add back Clear-RecycleBin for Windows (#10909) 2019-10-28 08:18:26 +05:00
Steve Lee 4ff9924cbf Add $env:__SuppressAnsiEscapeSequences to control whether to… (#10814) 2019-10-24 12:45:26 -07:00
Travis Plunk 09b5ed3fd0
Merge branch 'release/v7.0.0-preview.5' into master 2019-10-23 12:26:23 -07:00
Ilya be54be4162
Add limit check in Get-WinEvent (#10648)
ReadEvent() returns the error if our query contains number of logs more then 256.
So add the limit check and issue user-friendly error message.
2019-10-23 22:28:59 +05:00
Steve Lee 90fb1ea41d Fix stringdata test to correctly validate keys of hashtables (#10810) 2019-10-23 10:37:48 +05:00
Steve Lee 26c380de6e Fix command runtime so StopUpstreamCommandsException doesn't get populated in -ErrorVariable (#10840) 2019-10-22 16:38:32 -07:00
Andrew Menagarishvili 327dfd7e07 Merged PR 10295: Updating PackageReference for PS SDK to preview.5
Updating PackageReference for PS SDK to preview.5
2019-10-21 19:26:13 +00:00
Steve Lee 13f8ba284f Set the output encoding to [Console]::OutputEncoding for native commands (#10824) 2019-10-19 10:09:44 +05:00
Aditya Patwardhan 74eaf1980f
Move to .NET Core 3.1 preview 1 (#10798) 2019-10-18 16:49:25 -07:00
Robert Holt 2f4ed146ae Fix pure expressions setting $? in pipeline chains (#10836) 2019-10-18 14:57:56 -07:00
Dongbo Wang e1203aa31b
Skip the flaky test 'TestAppDomainProcessExitEvenHandlerNotLeaking' for now (#10827) 2019-10-17 17:39:14 -07:00
Robert Holt 2a518fcfe2 Support the pipeline chain operators && and || in PowerShell language (#9849) 2019-10-17 14:43:46 -07:00
Aditya Patwardhan 425bc36a6f Implement Null Coalescing and Null Coalescing assignment operators (#10636) 2019-10-17 10:21:24 -07:00
Dongbo Wang 48db3de03e
Make the event handler leaking test stable (#10790) 2019-10-16 09:55:41 -07:00
Steve Lee d8d32d79c2 Implement Get-Error cmdlet as Experimental Feature (#10727) 2019-10-15 14:32:14 -07:00
Joel Sallow (/u/ta11ow) 2e951793af Format-Hex: Improve mixed-collection piped input and piped streams of input (#8674) 2019-10-15 11:04:45 -07:00
Patrick Meinecke beb8b44420 Use type conversion in SSHConnection hashtables when value doesn't match expected type (#10720)
Before the change if the hashtable value does not match the expected type exactly, an exception is thrown stating that the value was null.
2019-10-15 22:16:49 +05:00
Eugene Samoylov d528bf5d3d Fix for Get-Content -ReadCount 0 behavior when -TotalCount is set (#10749) 2019-10-14 17:32:37 -07:00
Steve Lee 0842fe8b8d Enable tab completion for variable assignment that is enum (#10646) 2019-10-14 09:53:11 -07:00
Stephen Valdinger 6a807a2a1c Add -Delimiter to ConvertFrom-StringData (#10665)
@steviecoaster Thank you!
2019-10-11 14:03:02 -07:00
Dongbo Wang 60a930c9ba Add test for the even handler leaking fix (#10768)
Add a test for the even handler leaking fix addressed in #10626 https://github.com/PowerShell/PowerShell/pull/10626
The test is added to verify that PowerShell unregister the 'AppDomain.ProcessExit' event handler when a Runspace closes.
2019-10-11 23:34:53 +05:00
Steve Lee 1fa73e360f Add back Get-HotFix cmdlet (#10740) 2019-10-11 22:51:43 +05:00
Marco Schmid 0f9ca32d6d Adding positional parameter for ScriptBlock when using Invoke-Command with SSH (#10721) 2019-10-10 11:29:31 -07:00
Derek Xia 4a4dc4c751 Adds emphasis to Select-String default formatter (#8963) 2019-10-08 16:11:10 -07:00
Travis Plunk bf91246029 Replace CR and new line with a 0x23CE character (#10616) 2019-10-07 11:42:23 -07:00
Ilya 6a36bb4b7d
$PSCulture follows CurrentThread.CurrentCulture (#10138) 2019-10-07 14:17:11 +05:00
Dongbo Wang ec105da3f1 Some code cleanup work (#10698)
* Move Utils.GetUserConfigurationDirectory to Platform.ConfigDirectory
* Unify the use of Platform.ConfigDirectory and Platform.CacheDirectory
2019-10-07 14:15:01 +05:00
Steve Lee 8cf9c01800 Add ConciseView for $ErrorView (#10641) 2019-10-04 16:52:57 -07:00
Paul Higinbotham adfbac0c9d Set current working directory of each ForEach-Object -Parallel running script to the same location as the calling script. (#10672) 2019-10-04 10:04:04 -07:00
Ilya d7458c45b2 Add Get-ChildItem test (#10507) 2019-10-03 17:15:41 -07:00
PRASOON KARUNAN V 768e79a999 Adding -SecurityDescriptorSDDL parameter to New-Service (#10483) 2019-10-03 17:12:17 -07:00
romero126 0e90120b9a Replace Ambiguous language for tests from switch to parameter for accuracy (#10666) 2019-10-03 20:54:08 +05:00
Ilya 91bf34679c
Read special reparse points without accessing it (#10662)
* Enhance enum FileDesiredAccess with zero value GenericZero
* Use the GenericZero as desired access mode to read reparse point without access it

From docs:
If desired access is zero, the application can query certain metadata such as file, directory, or device attributes without accessing that file or device, even if GENERIC_READ access would have been denied
2019-10-03 19:41:18 +05:00
Ilya 950e4ba082
Direct Clear-Host output to terminal (#10681)
Clear-Host on Unix calls clear command which issues escapes. Before the change we write them to PowerShell output stream and it could be unwantedly intercepted. After the change we write the escapes directly to console.
2019-10-03 08:51:07 +05:00
Steve Lee 77ddec1614 Add back newline for grouping with Format-Table and -Property (#10653) 2019-10-02 12:11:55 -07:00
Steve Lee d8eca6a729 Remove [ValidateNotNullOrEmpty] from -InputObject on Get-Random to allow empty string (#10644)
* Remove [ValidateNotNullOrEmpty] from -InputObject on Get-Random

* address feedback to allow $null for -InputObject

* address Ilya's feedback

* address CodeFactor issues
2019-10-01 04:32:43 +00:00
Dongbo Wang 74517923cf Make Add-Type usable in application that hosts PowerShell (#10587) 2019-09-25 16:26:19 -07:00
dependabot-preview[bot] 83453d1e5c Bump PSDesiredStateConfiguration from 2.0.3 to 2.0.4 (#10603) 2019-09-23 15:42:39 -07:00
Christoph Bergmeister [MVP] 3b93fd285e Update to .Net Core 3.0 RTM (#10604) 2019-09-23 13:10:58 -07:00
Christoph Bergmeister [MVP] 6bf5c7656b Upgrade .Net Core 3.0 version from Preview 9 to RC1 (#10552) 2019-09-16 15:14:21 -07:00
Travis Plunk 60ffea59e3
Update PSDesiredStateConfiguration to 2.0.3 and bring new test… (#10516) 2019-09-12 14:39:11 -07:00
Andrew ed29ad1506 Adding PSCore group policy definitions (#10468) 2019-09-12 13:41:59 -07:00
Sotiris Nanopoulos f69f30ba49 Add working directory parameter to Start-Job (#10324) 2019-09-11 10:51:32 -07:00
Kirk Munro 096a78fbe3 Remove the event handler that was causing breakpoint changes to be erroneously replicated to the host runspace debugger (#10503)
* fix #10167

* Update test/powershell/SDK/Breakpoint.Tests.ps1

Co-Authored-By: Ilya <darpa@yandex.ru>
2019-09-10 22:47:50 +00:00
Kirk Munro 139cd942b2 Transition ActionPreference.Suspend enumeration value into a non-supported, reserved state, and remove restriction on using ActionPreference.Ignore in preference variables (#10317) 2019-09-07 23:45:36 +05:00
Christoph Bergmeister [MVP] 5a66306c71 Upgrade to Netcoreapp3.0 preview9 (#10484) 2019-09-06 12:15:49 -07:00
Kirk Munro cc0fed479a Add APIs for breakpoint management in runspaces and enable attach to process without BreakAll for PSES (#10338) 2019-09-05 11:30:25 -07:00
Dongbo Wang f6c220cdd9
Revert the PR "Make ForEach-Object faster for its commonly used scenarios" (#10485)
It turns out this optimization brings in a breaking change: `$MyInvocation` is different comparing to before the optimization change. I tried to fix the breaking change, but couldn't without introducing more hacky code. Given that, that PR should be reverted.
2019-09-04 22:12:30 -07:00
Dongbo Wang 5069c7d6a6 Support ternary operator in PowerShell language (#10367) 2019-09-04 13:22:33 -07:00
PRASOON KARUNAN V f6877022c3 Fix wrong output for New-Service in variable assignment and -OutVariable (#10444) 2019-09-03 11:11:14 -07:00
Dongbo Wang ff29282713 Make ForEach-Object faster for its commonly used scenarios (#10454) 2019-08-30 12:09:19 -07:00
James Truher [MSFT] 3943f18c28 Alpine validation changes (#10428) 2019-08-24 11:35:34 -07:00
Kirk Munro 8b9f4124ce Add support to ActionPreference.Break to break into debugger (#8205) 2019-08-23 10:34:10 -07:00
Dongbo Wang b77228906d Skip auto-loading PSReadLine on Windows if the NVDA screen reader is active (#10385) 2019-08-23 09:09:34 +05:00
Steve Lee 82e3480bbf Increase built-with-PowerShell module versions to 7.0.0.0 (#10356) 2019-08-22 15:33:30 -07:00
Ilya 356355c325
Block type update in Add-Type cmdlet (#9609) 2019-08-22 09:35:36 +05:00
Kirk Munro 8128803f2e Add experimental check for ForEach-Object -Parallel tests (#10354) 2019-08-19 14:02:19 -07:00
Steve Lee 00949ab352 .CPL should be added to PATHEXT (#9828) 2019-08-17 22:45:13 +05:00
Dan Thompson fb333fac99 Formatting: Handle XTPUSHSGR and XTPOPSGR control sequences (#10208) 2019-08-16 13:37:01 -07:00
James Truher [MSFT] fe2cc6aca8 Additional Telemetry - Implementation of RFC0036 (#10336) 2019-08-15 16:13:53 -07:00
Kirk Munro c8e72d1e66 Fix minor breakpoint re-hydration bug (#10339) 2019-08-15 14:55:45 -07:00
Kirk Munro eb81fb749a Mark -parallel and -throttlelimit reserved for foreach and switch statements (#10328) 2019-08-15 14:41:41 -07:00
Steve Lee 4220271e0e Move to .NET Core 3.0 preview.8 (#10351) 2019-08-15 13:42:17 -07:00
Kirk Munro ca86d75754 Deprecate workflow debugging code (#10321) 2019-08-15 08:29:18 +05:00
Robert Holt 14960b5772 pwsh -Login support (#10050) 2019-08-14 13:18:43 -07:00
Steve Lee 5974afaa8d Add support for AppX reparse points (#10331) 2019-08-13 17:45:41 -07:00
Paul Higinbotham fbfc57a00c Implement ForEach-Object -Parallel feature (#10229) 2019-08-13 13:40:58 -07:00
Ben Gelens ccc791c0a3 Fix #requires -version for pwsh 7 to include 6.1 and 6.2 in PSCompatibleVersions (#9943) 2019-08-12 15:25:28 -07:00
Travis Plunk 11d8cd3230 Make module name matching for get-module -FullyQualifiedName… (#10329) 2019-08-12 14:45:08 -07:00
Steve Lee 882cbf367f Enable Experimental Features by default on Preview builds (#10228) 2019-08-08 11:37:25 -07:00
Dongbo Wang 0d817aa547 Update 'Microsoft.PowerShell.CoreCLR.Eventing' to resolve conflict with 'System.Diagnostics.EventLog' (#10305)
* Update 'Microsoft.PowerShell.CoreCLR.Eventing' to resolve conflicts
* Add reference to 'System.Diagnostics.EventLog' to build Microsoft.PowerShell.Commands.Diagnostics on Unix
* Stop compiling Get/New-WinEvent on Unix
2019-08-08 17:44:54 +05:00
Ilya cf7699b4b9 Add tests for WildcardPattern.Escape() and Unescape() (#10090) 2019-08-07 13:25:10 -07:00
Paul Higinbotham 7034c8ba55 Fix debugger disable performance regression (#10269) 2019-08-05 13:27:49 -07:00
Christoph Bergmeister [MVP] 7af38294db Update PowerShell to build against .NET Core 3.0-preview7 (#10227) 2019-08-05 09:56:29 -07:00
Dongbo Wang d2e81dbc13 Special case the posix locale in WildcardPattern (#10186) 2019-07-26 10:58:37 -07:00
Steve Lee 2ed9abc99b Enable -sta and -mta switches for pwsh (#10061) 2019-07-25 12:38:52 -07:00
Jos Koelewijn 48c7e112db Add -Raw switch to Select-String for convenience (#9901) 2019-07-19 13:21:39 -07:00
Travis Plunk 6f0dacddc1
Merge branch 'release/v7.0.0-preview.2' into master
# Conflicts:
#	test/nanoserver/nanoserver.tests.ps1
2019-07-17 14:30:34 -07:00
Dongbo Wang df9d9043bb
Add the license header to nanoserver.tests.ps1 (#10171) 2019-07-16 12:56:55 -07:00
Aditya Patwardhan 7dfcff9287 Merged PR 9168: Disable Enter-PSHostProcess cmdlet when system in lock down mode
This is based on an issue, where Enter-PSHostProcess on a locked down (WDAC enforced) machine allows any admin to connect to any another local hosted PowerShell process and execute commands as that user. This amounts to privilege escalation on the policy locked down machine and something we want to prevent.

Fix is to check for system lock down and disable Enter-PSHostProcess cmdlet with an error message.
2019-07-16 00:49:24 +00:00
Aditya Patwardhan aeb8f37822 Merged PR 9185: Update PowerShell SDK version for hosting tests
Update PowerShell SDK version for hosting tests
2019-07-16 00:37:27 +00:00
Dongbo Wang 60da027342
Skip JumpList on NanoServer and IoT (#10164) 2019-07-15 17:04:54 -07:00
Dongbo Wang a4e397697c Skip JumpList on NanoServer and IoT (#10164) 2019-07-15 17:02:18 -07:00
Travis Plunk c64a28eaf1 Merged PR 5767: Fix RegEx DoS issues
Fix RegEx DoS issues
2019-07-15 19:52:01 +00:00
Travis Plunk 20e8ceee76
Remove markdownlint tests due to security issues (#10163) 2019-07-15 12:21:45 -07:00
Travis Plunk 5ef258ef68
Remove markdownlint tests due to security issues (#10163) 2019-07-15 12:20:39 -07:00
Ilya 0ae7d50d5c
Remove 'kill' alias for Stop-Process cmdlet on Unix (#10098) 2019-07-15 08:12:26 +05:00
Aditya Patwardhan ea4895c849
Mark Set-Service tests with password as Pending (#10146) 2019-07-12 16:50:58 -07:00
Steve Lee 431ef0372a Fix test password generation rule to meet Windows complexity requirements (#10143) 2019-07-12 12:11:45 -07:00
Ilya 18ff2b6b1d
Cleanup workflow - remove PSProxyJob (#10083) 2019-07-12 07:56:27 +05:00
PRASOON KARUNAN V ffb1549aa9 Add -SecurityDescriptorSddl parameter to Set-Service (#8626) 2019-07-11 13:23:57 -07:00
Christoph Bergmeister [MVP] fe56f9d902 Upgrade .Net Core 3 SDK from preview5 to preview6 and related out of band Nuget packages from 2.1 to 3.0-preview6 (#9888) 2019-07-09 14:35:08 -07:00
Ilya 5d98b901be
Cleanup workflow code (#9638)
* Remove WorkFlowInfo type

* Remove condition for UseSharedProcess

* Remove PSWorkflowJob condition

* Remove workflow from ValidateSet

* Remove workflow from CommandTypes enum

* Remove workflow from EventManager

* Remove workflow from Get-Help

* Remove WorkflowFileExtension ".xaml" from ModuleIntrinsics

* Remove WorkflowFileExtension ".xaml" from ModuleCmdletBase

* Remove workflow from PSModuleInfo

* Remove workflow from CustomShellCommands

* Remove workflow from InitialSessionStateProvider

* Remove WriteWorkflowDebugNotSupportedError()

* Remove unneeded resource strings from Module.cs

* Remove xaml from valid extension list
2019-07-07 01:03:03 +05:00
Reece Dunham 2a80ed728f Indent fix in markdown-link.tests.ps1 (#10049) 2019-07-04 08:08:52 +05:00
xtqqczze 0d55a7249b Suppress PossibleIncorrectUsageOfAssignmentOperator rule violation by adding extra parenthesis (#9460) 2019-07-02 13:23:58 -07:00
Mark Kraus 2285ece613 Set request headers when request body is empty in Web Cmdlets (#10034) 2019-07-02 12:01:06 -07:00
Joel Sallow (/u/ta11ow) b34e331d63 Consider DBNull.Value and NullString.Value the same as $null when comparing with $null and casting to bool (#9794)
- Adds `LanguagePrimitives.IsNullLike()` method to account for `DBNull.Value` and `NullString.Value` so that they can be considered the same as a null value where sensible in PowerShell.
- Updates `-ne` and `-eq` binders to treat `DBNull.Value` and `NullString.Value` as equal to null/AutomationNull.
- Update code paths for comparing objects in LanguagePrimitives to ensure consistency with how the `-eq` and `-ne` binders work when calling LanguagePrimitives methods to do the comparisons.
- Make `LanguagePrimitives.IsNull()` and `LanguagePrimitives.IsNullLike()` public methods.
- Added tests for null behaviours in `NullRepresentatives.Tests.ps1`
2019-06-28 11:39:34 -07:00
Amit Saraf 7bce46bc5b Download latest version (6.2.0) of PSDesiredStateConfiguration nuget package. (#9932) 2019-06-27 10:22:32 -07:00
Joel Sallow (/u/ta11ow) 86a1697da9 Allow methods to be named after keywords (#9812) 2019-06-25 11:04:00 -07:00
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