Commit graph

6020 commits

Author SHA1 Message Date
Dongbo Wang c5415d31a6
Change line ending from CRLF to LF in Microsoft.PowerShell.Management.psd1 (#6758) 2018-04-27 11:05:24 -07:00
Travis Plunk 768cfc4adf
Add script to create a container manifest (#6735)
Add script to create a container manifest
2018-04-26 10:03:53 -07:00
Ilya ffa7e4bac0 Enhance and refactor Add-Type cmdlet (#6141)
- Can compile a source from strings (TypeDefinition and MemberDefinition).
- Can compile from files.
- Can compile only to a file (without loading the produced assembly).
- Do not recompile and don't reload if the sources have not changed.
- Implement `-IgnoreWarnings` to not treat warnings as errors. By default, the cmdlet considers warnings as errors.
- Add VisualBasic support.
- Add new `-CompilerOptions` parameter to allow setting Roslyn command line parameters including:
    - Parser options.
    - Compile options.
    - Emit options.

**ATTENTION:** The `CompilerOptions` can be specified along with other options like `-OutputAssembly`, `-Language` and `-IgnoreWarnings`. The explicit setting parameters will take precedence over the same settings specified in `-CompileOptions`.

See docs about the compiler options:
https://github.com/dotnet/roslyn/blob/master/docs/compilers/CSharp/CommandLine.md
https://github.com/dotnet/roslyn/blob/master/docs/compilers/Visual%20Basic/CommandLine.md

**ATTENTION:** `-OutputType` default is `Library`. If `-OutputType` is absent the `-OutputType` default overlaps a value in `CompileOptions`. In other words output type ("target" ot "t" in command line) is always ignored in `CompileOptions`. We have to use `-OutputType` to set an output type.
2018-04-25 22:40:26 -07:00
Robert Holt 63c0d8d783 Add error handling for interactive #requires (#6469) 2018-04-25 18:04:04 -07:00
Klaudia Algiz 4b149e4191 Use new Pester syntax for Pester tests in module PSDesiredStateConfiguration (#6622) 2018-04-25 17:29:40 -07:00
Klaudia Algiz 045e036205 Update documentation on how to write tests verifying errors conditions (#6687) 2018-04-25 17:26:24 -07:00
Dan Travison 9a2382b67c Update PSRP/Linux NuGet package version to 1.4.2-* (#6711) 2018-04-25 15:48:38 -07:00
Matthew Bobke 35d8de927b Fix New-Item to work correctly when given path is drive root and $PWD is a sub folder of the drive root. (#6600) 2018-04-25 14:32:57 -07:00
Ilya a9781dedc2
Add some optimizations in formatting subsystem (#6678)
Use safe pattern 'columns <= columnsThresHold ? stackalloc int[columns] : new int[columns];'
Remove duplicate code.
Use common 'columnsThresHold' constant.
2018-04-25 13:23:28 +05:00
Christoph Bergmeister fa3305534f Use '-WorkingDirectory' parameter to handle context menu when path contains single quotes. (#6660)
Use new '-WorkingDirectory' parameter on pwsh.exe to be able to use context menu when path contains single quotes.
2018-04-24 17:03:14 -07:00
Steve Lee 10900e0a24 Update error message that Disconnect is only supported with WSMan (#6689) 2018-04-24 16:29:01 -07:00
Steve Lee a9d10dda42 Fix two tests that are failing on nightly run (#6723)
- For ConsoleHosts tests, the test is validating error condition, but did not redirect stderr to stdout so the output isn't captured and thus an empty string failing the assertion.
- For SSHConnectionInfo API tests, it's calling a constructor that got overwritten with a new parameter. Fix is to put back that public API and overload it with a new one.
2018-04-24 16:25:55 -07:00
Steve Lee c80cecf35f Enable specifying sshd subsystem to use via -Subsystem (#6603)
The current implementation of PSRP over SSH only enables remoting to one version of PowerShell Core 6.
sshd_config allows specifying multiple subsystems that can start different versions of PowerShell Core 6 (or same versions with different parameters).
Enable use of a new -Subsystem parameter to specify the subsystem to use with ssh.
2018-04-24 12:51:56 -07:00
Ilya 313a8596bb
Pretty print Export-FormatData XML output (#6691)
Pretty print Export-FormatData XML output by default.
Refactor Export-FormatData tests, remove test duplications.
2018-04-24 10:04:42 +05:00
Steve Lee 942c68e796 Add '-WorkingDirectory' parameter to pwsh (#6612)
Add `-WorkingDirectory` parameter to `pwsh` to allow starting in right working directory.
2018-04-23 14:27:47 -07:00
Gabriel Sroka 84a3c9cdc7 Correct a typo in comment for 'Invoke-WebRequest' (#6700) 2018-04-23 14:21:50 -07:00
Ilya 2da7576736
Add tests for Format-Table -Wrap (#6670) 2018-04-23 12:45:14 +05:00
Ilya 5a326135ec
Add new reliable tests for Get-Date -UFormat (#6614) 2018-04-19 13:58:29 +05:00
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