Commit graph

2385 commits

Author SHA1 Message Date
Ilya 0ad9fc9d70
[breaking-change] Fix range operator (#5732)
Breaking-change:  "0".."9" returns [char] previously in PowerShell Core (6.0.0, 6.0.1), now it returns [int]. After the change, the behavior is the same as in Windows PowerShell.
2018-02-11 14:22:45 +04:00
Chunqing Chen 40eb3b3e13 Get-ChildItem <PATH>/* -file should include <Path> as search directory (#5431)
* get-childitem <PATH>/* -file should include <Path> as search directory

* [Feature] Added check for -Directory and more tests

* [Feature] Added check for the dynamic parameter type
2018-02-07 16:30:14 -08:00
Steve Lee 8b05408b1b Improve table view for Certs and Signatures by adding EnhancedKeyUsageList and StatusMessage (#6123)
* add EnhancedKeyUsageList to default table view of X509Certs
add StatusMessage to default table view of cert signatures

* set fixed width of 20 to Subject so more room for EnhancedKeyUsageList content
change EnhancedKeyUsageList to script to just show the friendly name
2018-02-07 15:29:48 -08:00
Steve Lee 3a81c2b58f Enable setting PSSession Name when using SSHTransport and added Transport property (#5954)
When using New-PSSession -SSHTransport -Name ... the Name parameter wasn't being used when creating the remoterunspace so an automatically generated one was always created.
Fix is to explicitly pass the transport name when generating a runspace name including other transports like VMBus and Container.

Refactor runspace name generation code to produce "RunspaceN" and added a Transport property.

Tests will have to wait until we have the infrastructure for remoting tests and Enable-SSHRemoting work is complete.

Fix #5951
Fix #2426
2018-02-04 13:12:48 -08:00
Dan Travison 0191946fe3 Fix the filtering of analytic events on Unix platforms. (#6086)
- Remove previous `UseAlwaysAnalytic` workaround in `SysLogProvider.Log`
- Update Script Block logging to always log to the operational channel with `UseAlwaysOperational`
- Fix `PSChannel` on Linux to use a bitmask
- Handle `UseAlwaysOperational` and `UseAlwaysAnalytic` keywords but adding to `_keywordFilter` if the associated channels were selected in the configuration
2018-02-02 10:49:09 -08:00
Ilya ca4e4798fb Remove unsupported members from the enum 'Language' in Add-Type (#5829)
[breaking change]
Remove the unsupported members (various versions of CSharp and `JScript`) from the enum 'Language' in Add-Type. After this change, `Add-Type -Language` only supports `CSharp` and `VisualBasic`.
2018-02-01 09:25:20 -08:00
Travis Plunk 1c5c7f5c3a
add comments about where most of the packages are from (#6016) 2018-01-31 12:16:48 -08:00
Daniel Llewellyn 7b27250479 Add Environment Variable override of telemetry (#6063)
Inspired by dotnet cli, and allows for Telemetry opt-out on packaging systems such as AppImage and Snapcraft where the filesystem is immutable.
2018-01-31 10:19:48 -08:00
Ilya 7f2ebd70c9
Resort parameter list in alphabetical order (#6052)
After #5920 we should reorder parameter list (#4989)
2018-01-30 07:56:00 +04:00
Travis Plunk 3a33be87a7 Merge branch '6.0.1' into master
# Conflicts:
#	docker/release/fedora27/Dockerfile
#	docs/installation/linux.md
#	docs/installation/macos.md
#	tools/metadata.json
2018-01-25 16:35:25 -08:00
Mark Kraus 2f1aec1496 Fix .gitignore (#5991)
Use single '*' in file name /src/TypeCatalogGen/powershell*.inc
2018-01-25 15:23:07 +04:00
Dan Travison 43662809c7 Add '-settingsfile' to 'pwsh' to support loading a custom powershell config file. (#5920)
Support loading a custom `powershell.config.json` file via the command-line for use in testing.
This change supports replacing the default `powershell.config.json` file that's usually loaded from the `PSHome` directory with a custom version file.

The primary use-cases for this command-line option are as follows:
1. Allow the CI system to disable settings that impact test run times; such as disabling syslog usage on Linux and MacOS
2. Support testing of syslog and os_log without interfering with normal PowerShell operations during test runs via launching an instance with custom log settings.
2018-01-24 22:12:14 -08:00
Mark Kraus a36d58cf09 Add Simplified multipart/form-data Support to Web Cmdlets Through -Form Parameter (#5972)
- Adds -Form Parameter to Invoke-WebRequest and Invoke-RestMethod.
- Form Accepts any IDictionary.
- Keys are used as multipart/form-data field names (PSObject unwrapped and ConvertTo<String>(Object)).
- FileInfo values are added as StreamContent with application/octet-stream content type and the FileInfo.Name as the file name.
- Strings are treated as StringContent.
- Singe values are converted to string with ConvertTo<String>(Object) and treated as StringContent
- Top level collections are enumerated and converted as above. Nested collections are treated as a single value and converted accordingly.
- Form is mutually exclusive with -Body and -InFile.
- Per PowerShell-Committee decision, -Form makes no assumptions about the HTTP method used. It can theoretically be used with any method. User will need to manually supply -Method POST to post the form.
- ContentType and content related headers supplied to -Headers will be ignored/cleared as MultipartFormDataContent requires control of these headers.
2018-01-25 09:17:55 +04:00
Takuya Shibata f86371e347 Change Microsoft.PowerShell.Commands.SetDateCommand.SystemTime to struct. (#6006)
Change Microsoft.PowerShell.Commands.SetDateCommand.SystemTime class to struct and resolve the error in Set-Date cmdlet - SetLocalTime function is causing a parameter error (error code 0x00000057).
2018-01-25 07:54:27 +04:00
Greg Zimmerman 874f5c1a85 Return better error for 'pwsh -WindowStyle' on unsupported platforms. (#5975) 2018-01-24 14:00:57 -08:00
Paul Higinbotham 27099c3f57 Fix a NullReference exception in Enter-PSHostProcess (#5995) 2018-01-24 13:59:29 -08:00
Aditya Patwardhan 5b5168d72e Revert "Pull PSReadLine from PSGallery" (#5986)
This reverts commit beffdcf94d.
2018-01-22 16:09:35 -08:00
Travis Plunk a603cf3867
Update csproj files to the latest version of the package references (#5961)
* Add function which tells you packages which probably need to be updated
2018-01-22 12:06:50 -08:00
Jason Shirk beffdcf94d Pull PSReadLine from PSGallery (#5759)
Instead of building PSReadLine from this repo, pull it from the gallery using nuget cache.

This pulls v2.0 of PSReadLine which does have documented breaking changes from v1.2, but the risk is small - the features that have changed are typically only used in a profile and aren't used all that often anyway.

Fix #996

Hardcodes version of modules pulled from PSGallery
2018-01-19 18:15:09 -08:00
Dan Travison 65a4002990 Logging: Fix the escaped characters when generating '.resx' file from PowerShell ETW manifest. (#5892) 2018-01-19 08:55:20 -08:00
Mark Kraus bb8d5562c5 Merge and Sort BasicHtmlWebResponseObject and ContentHelper (#5720)
* Merge and Sort BasicHtmlWebResponseObject

* Merge and sort ContentHelper
2018-01-17 16:47:50 -08:00
Steve Lee 7437f3dd3a Encoding for New-ModuleManifest on all platforms should be UTF-8 NoBOM (#5923)
* encoding for new-modulemanifest on all platforms should be utf8nobom
* fix test
2018-01-17 16:37:53 -08:00
Ilya 5674bf37be Remove 'PSv2' only code from 'Types_Ps1Xml.cs' and 'HostUtilities.cs' (#5907) 2018-01-17 09:39:28 -08:00
Steve Lee 7459b54639 Set-Location should use path with wildcard characters if it exists instead of globbing (#5839)
When InitialSessionState initializes it tries to SetLocation to current working directory,
 but if the directory name contains PowerShell wildcard characters, it fails and reverts
 to $PSHOME.
 The change affects Set-Location in that if the path exists (even if containing wildcard characters), just use it. It is a breaking change.
2018-01-17 08:58:55 +04:00
Dan Travison d911bac210 Do not pass ArgumentAst to CreateArgument for -encodedarguments (#5836)
When calling powershell from powershell (called the minishell for historical reasons), the arguments are passed as a base64 encoded string.

The native command parameter binder was trying to match up the ast to the argument value, which in this case, doesn't make sense.

The fix is to ignore the ast during parameter binding for this case of calling powershell from powershell.

Fix #5733
2018-01-12 12:41:17 -08:00
Satoshi Tanda 2ae61c8ce4 Handle path that contains spaces in 'RegisterManifest.ps1' (#5859) 2018-01-11 11:18:24 -08:00
Travis Plunk db10411505
CimDscParser: Add better error message when a file is not found (#5838) 2018-01-10 18:16:41 -08:00
Jason Shirk 8bd53786d1 Fix ValidateSet with generator in a module (#5702)
The symbol resolver was properly resolving the type to the class
definition, but that resolution was ignored at runtime because we used
the string instead of the ITypeName - the ITypeName kept the reference
to the class definition.

Fix #5661
2018-01-09 13:43:54 +04:00
Steve Lee 08c455a4ee Remove sc alias which conflicts with sc.exe (#5827) 2018-01-08 18:09:00 -08:00
Aditya Patwardhan 0687d5a564 Updated Help Uri to point to latest help content for Microsoft.PowerShell.Core module (#5820) 2018-01-08 18:09:00 -08:00
Dongbo Wang 658960e3f9 Move group policy settings and enable policy controlled logging in PowerShell Core (#5791)
Make PowerShell Core reads group policy settings from different registry keys (Windows only) and the configuration files (both Windows and Unix).
- On Windows, move to different GPO registry keys.
- On both Windows and Unix, read GPO related settings from the configuration file `powershell.config.json`.
- On Windows, the policy settings in registry take precedence over the configuration file.
- Enable policy controlled logging and transcription on Unix.
2018-01-08 18:09:00 -08:00
Steve Lee 0d893a59c7 Remove sc alias which conflicts with sc.exe (#5827) 2018-01-08 17:20:00 -08:00
Aditya Patwardhan d6288a3e2f Updated Help Uri to point to latest help content for Microsoft.PowerShell.Core module (#5820) 2018-01-08 16:37:59 -08:00
Dongbo Wang d261e1f166
Move group policy settings and enable policy controlled logging in PowerShell Core (#5791)
Make PowerShell Core reads group policy settings from different registry keys (Windows only) and the configuration files (both Windows and Unix).
- On Windows, move to different GPO registry keys.
- On both Windows and Unix, read GPO related settings from the configuration file `powershell.config.json`.
- On Windows, the policy settings in registry take precedence over the configuration file.
- Enable policy controlled logging and transcription on Unix.
2018-01-08 12:03:23 -08:00
Dongbo Wang 01ecf4b3d3 [Feature] Address Steve's new comments 2018-01-08 09:54:28 -08:00
Dongbo Wang 6ee608ff58 [Feature] Consider a policy is undefined if none of its properties are set 2018-01-07 15:53:07 -08:00
Dan Travison da5d897823 SAL annotation updates & fix warnings (#5617)
Various SAL annotations were either incorrect or not backed up by code. This PR address these issues.

NOTE: By default, Start-BuildNativeWindowsBinaries does not enable code analysis and issues detected by SAL annotations are not reported. To identify these issues, run Start-BuildNativeWindowsBinaries to generate the solution and vcxproj files. Launch a Visual Studio developer prompt, cd to src\powershell-native and run msbuild manually.

> msbuild PowerShellNative.sln /p:RunCodeAnalysis=true /p:Configuration=RelWithDebInfo /p:Platform=x64

The following changes address all code analysis warnings:

- GetRegistryInfo in NativeMsh had incorrect out annotations, remove __opt
- Fix handling of various out parameters - check for non-null and initialize
- Update and Align SAL annotations for GetFormattedErrorMessage overloads
- Allow PluginException to accept NULL message.
2018-01-05 16:53:27 -08:00
Dongbo Wang 3b941735d2 [Feature] Change two methods to use 'private' modifier. 2018-01-05 16:34:13 -08:00
Dongbo Wang 3b5badca04 Rename 'PowerShellProperties.json' to 'powershell.config.json' 2018-01-05 16:06:36 -08:00
Dongbo Wang b4b864f5da Re-enable group policy settings from registry
On windows, group policy settings from registry takes precedence over the configuration file.
If a policy is not defined in GP, then we query from configuration file.
2018-01-05 14:33:37 -08:00
Ilya 6825182a6a
Add ForEach and Where methods to [PSCustomobject] (#5756) 2018-01-05 22:54:31 +04:00
Ilya aaa567cf8c
Show usage (short) help if command line parameter is wrong (#5780)
Show usage (short) help if command line parameter is wrong
Show extended (full) help message with pwsh -h
Split Help message on Usage and Extended
2018-01-05 15:36:45 +04:00
Dongbo Wang 167bbad1d1 Address one of Dan's comments 2018-01-04 21:00:13 -08:00
Dan Travison 63b80945a1 remoting: Handle DLLImport failure of libpsrpclient (#5622)
Issue #4029 exposed two problems when failing to load libpsrpclient.

WSManAPIDataCommon.ctor was not identifying the binary that failed DLLImport; hindering diagnosability
PrioritySendDataCollection.Clear() would throw a NullReferenceException when called from the finalizer after an error path.
This change addresses both of the above:

Guard against null arrays in PrioritySendDataCollection.Clear() - called from finalizer in error paths.

Diagnosability: Log the DllNotFoundException in WSManAPIDataCommon ctor and also include it as the internal exception when throwing PSRemotingTransportException.
2018-01-04 17:17:34 -08:00
Dongbo Wang a6c62bfc58 [Feature] Minor changes to make ScriptBlock logging work with SysLog 2018-01-04 13:40:51 -08:00
Dongbo Wang 41c66dbc26 Refactor GroupPolicy setting related code to use the configuration file 2018-01-04 13:40:50 -08:00
Dongbo Wang 6ab1ad7ea8 Rename file PropertyAccessor.cs to PSConfiguration.cs 2018-01-04 13:40:50 -08:00
Dongbo Wang 263ec24ae3 Rename 'PropertyScope' to 'ConfigScope' 2018-01-04 13:40:50 -08:00
Dongbo Wang 3dd86f5148 Refactor 'PropertyAccessor.cs'
- Remove the unneeded base type;
- Rename 'ConfigPropertyAccessor' to 'PowerShellConfig';
- Move 'PowerShellConfig' to the namespace 'System.Management.Automation.Configuration'
2018-01-04 13:40:50 -08:00
Dongbo Wang 39af334f9f Enable logging on Linux through MshLog 2018-01-04 13:40:34 -08:00