Commit graph

6202 commits

Author SHA1 Message Date
Ilya c05f1ec3f3
Reduce allocations in TableWriter (#6648)
* [Feature] Reduce allocations in TableWriter
* Revert iterator
ReadOnlySpan is not supported in iterators
* Use columnsThresHold with stackalloc
2018-04-18 19:15:36 +05:00
Paul Higinbotham 80951777cf Port Windows PowerShell AppLocker and DeviceGuard UMCI application white listing support (#6133)
These changes port Windows PowerShell support for Applocker and DeviceGuard User Mode Code Integrity (UMCI) to PSCore6. Windows PowerShell uses public APIs to determine if a system is in locked down mode via AppLocker or DeviceGuard, and automatically runs in constrained language mode. For more information about PowerShell constrained language, see: https://blogs.msdn.microsoft.com/powershell/2017/11/02/powershell-constrained-language-mode/

This support for application whitelisting has mostly existed in PSCore6, but the primary APIs were stubbed out in CorePSStub.cs because they relied on Windows only DeviceGuard (wldp.dll) and AppLocker (Safer APIs) public APIs. These changes re-implement PowerShell lock down APIs on PSCore6 for Windows platforms only. The AppLocker and DeviceGuard public APIs are currently only implemented in Windows OSes and are not supported on Linux or MacOS platforms.

Tests have also been ported to PSCore6 and run only for Windows platforms.
2018-04-17 13:09:17 -07:00
Ilya 62bb0899ac
Reformat Format-Table tests (#6657)
* Convert identations to spaces
* Remove alias tests and extra lines
* Remane extra Describe
* Remove extra parentheses and add spaces
2018-04-17 10:06:39 +05:00
Ilya 2457113c80 Formatting: Use cache for dash padding strings (#6625) 2018-04-14 16:49:01 -07:00
Joey Aiello feb38cff70 Remove extraneous SSH and install docs from the 'demos' folder (#6628) 2018-04-13 15:50:54 -07:00
Dongbo Wang 11631e7412
Clean up 'GetTypeInfo()' calls in engine folder (#6634)
'GetTypeInfo()' were added when porting PowerShell to early version of .NET Core (prior .NET Core 1.0).
Most properties and methods in 'System.Type' were missing at that time. Now the call is not needed anymore and should be removed.
2018-04-13 15:10:10 -07:00
Dongbo Wang f9f1bd29ad
Clean up 'GetTypeInfo()' calls in other engine sub-folders (#6635)
'GetTypeInfo()' were added when porting PowerShell to early version of .NET Core (prior .NET Core 1.0).
Most properties and methods in 'System.Type' were missing at that time. Now the call is not needed anymore and should be removed.
2018-04-13 15:07:35 -07:00
Dongbo Wang 6125c0f456
Clean up 'GetTypeInfo()' calls in 'help', 'cimSupport' and 'DscSupport' folders (#6633)
'GetTypeInfo()' were added when porting PowerShell to early version of .NET Core (prior .NET Core 1.0).
Most properties and methods in 'System.Type' were missing at that time. Now the call is not needed anymore and should be removed.
2018-04-13 15:06:13 -07:00
Travis Plunk 438b0e545f
Add meta properties to mac VSTS yml (#6619)
Add meta properties to mac VSTS YAML
- Add a property to clean the build machine
- Add a property to set the format of the build name
- add a property to set which queue to run the build in
2018-04-13 15:04:22 -07:00
Dongbo Wang da40c6efb7
Clean up 'GetTypeInfo()' calls under engine/parser (#6636)
`GetTypeInfo()` were added when porting PowerShell to early version of .NET Core (prior .NET Core 1.0).
Most properties and methods in `System.Type` were missing at that time. Now the call is not needed anymore and should be removed.
2018-04-13 15:01:41 -07:00
Klaudia Algiz dd8f76b8d5 Fix for the Register-PSSessionConfiguration command (#6630)
Fix for the Register-PSSessionConfiguration command, as some tests were failing in: https://ci.appveyor.com/project/PowerShell/powershell-f975h
Probably because of changes in #6519
2018-04-13 12:27:03 -07:00
Steve Lee f760fde0b7 Remove support for file to opt-out of telemetry, only support env var (#6601)
Since a PR added support to opt out of telemetry via an environment variable, we can remove the,
always intended to be a temporary, solution of deleting a file to opt out of telemetry since the
environment variable can be defined at the system level and exist before even installing PowerShell Core.

Because the variable is defined as opt out, a value of true, yes, or 1 means no telemetry is sent.
2018-04-13 10:29:39 -07:00
Steve Lee c2accff785 Support importing module paths that end in trailing directory separator (#6602) 2018-04-13 08:07:50 +04:00
Ilya f96a928a42
Re-order UFormat options in Get-Date (#6627)
Place in alphabetical order the options
2018-04-12 09:33:52 +04:00
Travis Plunk adce514a0c
fix error about setting readonly variable (#6617) 2018-04-11 11:01:38 -07:00
Sergey Vasin 25dbc68b8e Fix formatting in Add-Content.Tests.ps1 file. (#6591)
* Fix formatting.
* Capitalize TestDrive and add empty strings.
2018-04-11 07:23:30 +04:00
Dongbo Wang 118f771939
Make the 'PSISERemoteSessionOpenFile' a support event (#6582)
Make the `PSISERemoteSessionOpenFile` a support event, so that `Get-EventSubscriber` won't show that subscriber. `Get-EventSubscriber -Force` can still show the support event subscribers. `Unregister-Event -Force` needs to be used to remove a support event subscriber.

The event subscriber for `PSInternalRemoteDebuggerStopEvent` and `PSInternalRemoteDebuggerBreakpointUpdatedEvent` are already made support events. And this PR makes it the same for `PSISERemoteSessionOpenFile`.
2018-04-10 18:43:22 -07:00
Dongbo Wang 7726322589
Engine: Clean up unneeded 'GetTypeInfo()' calls in interpreter code (#6613)
Clean up unneeded `GetTypeInfo()` calls in interpreter code.
The `GetTypeInfo()` calls were added back in the early days of .NET Core, when most of the properties and methods of `System.Type` were removed. Now those properties and methods are back in `System.Type`, so there is no need to keep those calls.
2018-04-10 18:11:06 -07:00
Dongbo Wang 153d677839
Engine: Make some minor cleanup changes (#6609)
- Remove the calls to `GetTypeInfo()` in the generated `.resx` binding C# binding code (change in the tool `ResGen`).
- Remove the unused methods in `SessionState.cs`.
- Remove the calls to `GetTypeInfo()` from `Compiler.cs` and other files in `engine\runtime`.
- Fix typos in `VariableAnalysis.cs` and `ClassOps.cs`.
- Minor perf improvement in `MutableTuple.cs` by using indexing instead of linq extension method `last()`.
2018-04-10 18:03:20 -07:00
Ilya 68b59e3d9b Improve performance of parsing RegexOption for '-split' by using if branches (#6605) 2018-04-10 13:03:41 -07:00
Klaudia Algiz 3cd2308af9 Create the default PSSession configuration, not tied to a specific PowerShell version. (#6519)
Create the default PSSession configuration, not tied to a specific PowerShell version.

When Enable-PSRemoting command is run, it creates 2 sessions configurations:

first, the same as it was before with the name containing the current version expressed as: 'PowerShell.$PSVersionTable.GitCommitId'
second with the default name 'PowerShell.6' so that administrators wouldn't have to guess which specific version is installed on the target.
PR addresses the issue: #6470
2018-04-10 12:21:44 -07:00
Travis Plunk aefc0d89b0
make gem use sudo for macOS (#6610)
gem install requires sudo on official macOS build VMs.
- make bootstrap use sudo for macOS
2018-04-10 12:18:11 -07:00
Mark Kraus 18e6a5c654 Add Missing Start-WebListener to Web Cmdlet Tests (#6604) 2018-04-10 10:12:45 +04:00
Ilya 6bd70bc2d0
Some fixes in Get-Date -UFormat (#6542)
* Use UTC datetime in Get-Date -UFormat %s
Fix %l output from 0..11 to 1..12
Fix %V using Gregorian calendar

* Use a workaround for ISO 8601 week of year (uformat %V)
2018-04-10 08:13:19 +04:00
Jeffrey Snover 24dafac3f4 Added line break to Acess Denied error message. (#6607) 2018-04-10 07:51:06 +04:00
Sergey Vasin 3ec98bbbe8 Fix typos and formatting in Clear-Content.Tests.ps1 (#6592)
* Fix typos and formatting.
* Capitalize function parameters.
2018-04-10 07:47:39 +04:00
Sergey Vasin a3e8929d6a Fix formatting Clear-EventLog.Tests.ps1 (#6594) 2018-04-10 07:17:52 +04:00
Sergey Vasin ca5aacca16 Fix formatting in Clear-Item.Tests.ps1. (#6593) 2018-04-09 16:24:01 +04:00
Sergey Vasin 9d3c2633e7 Fix formatting in Convert-Path.Tests.ps1. (#6595) 2018-04-09 16:22:45 +04:00
Sergey Vasin 1f7b3a65d3 Fix Copy.Item.Tests.ps1 (#6596)
Fix formatting, absent parameter names and use -Throw and -ErrorID parameters with Should function.
2018-04-09 16:21:47 +04:00
Florian Feldhaus 94c8ce007d Added check for existence of Location HTTP header before using it (#6560)
The HTTP RFC (https://tools.ietf.org/html/rfc7231#section-6.4) does not require a Location header to be present for redirects, thus it is required to check if the Location header is returned before using it.
2018-04-08 16:51:17 +04:00
Dongbo Wang 48be625379
Improve PSMethod-to-Delegate conversion (#6570)
Two small improvements:
1. Avoid unnecessary reflection in `ConvertPSMethodInfoToDelegate`. `PSMethod` already has the `MethodInfo` information with its `adapterData` field.
2. Avoid creating the generic `PSMethod<>` type for `PSMethod` that represents constructors, because constructors cannot be converted to a delegate anyways. In case that the `PSMethod` represents constructors, we use a simple `PSMethod` instance instead.

Also, rename the type `Unit` to `VOID` to make it more readable, since that type represents `typeof(void)`.
2018-04-06 17:01:04 -07:00
Darwin 46fa2260a8 Update installpsh-<distrofamily>.sh Installers to Handle "preview" in version number (#6573) 2018-04-06 15:23:11 -07:00
Steve Lee 38c53c50a6 Support 'user@host:port' syntax for SSH Transport (#6558) 2018-04-06 15:04:37 -07:00
Sergey Vasin 4554679a08 Use -Throw and -ErrorId native Pester parameters. (#6574) 2018-04-06 16:15:37 +04:00
Ilya 31085d5737 Use C# latest language in proj files (#6559)
Address #6547

We begin using C# 7.2 features (Span) but .Net Core doesn't seem use "Latest" as default for a language.
So we explicitly set the value.
2018-04-05 17:39:20 -07:00
Dongbo Wang 2a45b48ae2
Remove the FullCLR-only symbol-info related code from 'EventManager.cs' (#6563)
This is because the `AssemblyBuilder` family types do not support emitting symbol information in .NET Core.
2018-04-05 13:57:05 -07:00
Dongbo Wang 6584447025
Engine: Fix several code cleanup issues (#6552) 2018-04-04 14:47:44 -07:00
Dongbo Wang e0b1f1f3af
Fix line ending in 'DefaultCommands.Tests.ps1' from CRLF to LF (#6553) 2018-04-03 13:32:16 -07:00
Dongbo Wang ceac82abc5
Fix running 'pwsh' produced from 'dotnet build' (#6549) 2018-04-03 12:06:14 -07:00
Ilya 24cf020442 Add ported Test-Connection cmdlet (#5328)
The Test-Connection cmdlet works on Windows and Unix.

Implemented:
Ping
Continues Ping
Traceroute
Detect MTU size (seems don't work on Unix because of .Net Core issue)
Connect to TCP port
Not jet implemented:
I'm putting this off for the future.

Detect blackhole routers
PingPath
Additional considerations
As you can see in the tests .Net Core has issues in API implementation. As a result, some tests are skipped on Unix. There is also one issue on Windows. Related comments added to tests.
I'm going to open an issue(s) in CoreFX repo.

I think we should break the feedback into two parts:

scripting functionality
interactive functionality (display output)
Now I have implemented the output to the screen as the progress bar and as text (without ETS) - we have to decide what is best to use.
2018-04-03 11:59:26 -07:00
Travis Plunk a267ca5216
Merge - Get the VisualStudio solution working (#6546)
Changing the project type GUID. This should make the TargetFramework not required to
build in Visual Studio for Windows (works on Mac without the change.)
Add the powershell-unix project so you can choose which one to build.
remove a resource that wasn't used and fails in VS from two resource files.
2018-04-03 11:32:10 -07:00
Takuya Shibata cd1d2d2063 Fix error when 'Format-Wide -AutoSize | Out-String' is called. (#6491)
* Add checking if an output width is specified.

* change _failedToReadConsoleWidth variable to _noConsole bool value. 
This variable is to cache the default console width when failed to get 'Console.WindowWidth' value.
2018-04-03 11:17:05 -07:00
Klaudia Algiz f0b6ef2eb4 Terminate the loop in PsUtils.GetMainModule() which was infinite in case there was no main module. (#6358)
* Terminate the loop in GetMainModule if main module is null.

* Run tests with FileVersionInfo also on non-windows platforms. Add test for process which main module can be null.
2018-04-03 10:58:06 -07:00
Travis Plunk 9b6c9af92a rename solution to powershell 2018-04-03 09:50:09 -07:00
Travis Plunk 78f797a3b8 Add comments about configuration mappings 2018-04-03 09:44:53 -07:00
Travis Plunk b3860452a2 add mappings for unix project 2018-04-03 09:36:46 -07:00
Travis Plunk 4ce9506d32 change project type for unix project 2018-04-03 09:35:10 -07:00
Travis Plunk 4e2089e5d9 add comment about project guids 2018-04-03 09:34:36 -07:00
Steve Lee 5d3456d11b Fix formatting of tables where headers span multiple rows (#6504)
* In cases where the header spans multiple rows, need to correctly calculate whitespace and trim appropriately

* Use System.Span<int> and C# 7.2 language in SMA

* Added new ref assemblies to Files.wxs
refactor tests to remove similar xml content
added single column test case
2018-04-03 07:24:23 +04:00