Commit graph

146 commits

Author SHA1 Message Date
Paul Higinbotham acf5eb5053 Adding verbose output for experimental implicit remoting batching feature (#8166) 2018-11-05 15:22:46 -08:00
PRASOON KARUNAN V f59353d5d9 Error message enhancement for clear-content cmdlet when targeting a directory (#8134) 2018-11-01 08:56:45 +05:00
Paul Higinbotham 20f3a6a337 Experimental feature: Implicit remoting batching perf improvement (#8038) 2018-10-30 09:55:39 -07:00
Andrew Stanton bf2667352a Fix typo in -icontains description from"incase sensitive" to "case insensitive" (#7840) 2018-10-23 13:32:51 -07:00
Steve Lee b62e152f4d Improve error message on non-Windows when importing clixml with securestring (#7997) 2018-10-12 10:56:35 -07:00
Steve Lee 339abe0609 Fix Enter-PSSession -ContainerId for the latest Windows (#7883)
Hyper-V team changed the type used to get the `runtimeid`. We need to check for new type and fall back to old type.
2018-10-09 14:24:25 -07:00
PRASOON KARUNAN V e6702fe780 Get/Add-Content throws improved error when targeting a container (#7823) 2018-09-28 20:36:13 +05:00
Christoph Bergmeister [MVP] 4bc22d92df Add support for 'cd +' (#7206)
'cd +' adds the ability to revert 'cd -' by having another bounded stack with the same limit for 'redo' actions.
Behaviour is similar to back/forward navigation in explorer.exe
When the location is set to a path and the redo stack is non-empty then the redo stack gets flushed.
When cd + happens, then the redo stack is pushed to as well for a more intuitive way of navigating backwards and forwards.
All the work is done of course on the Set-location cmdlet, which is aliased to cd on all platforms.
2018-09-19 12:50:30 +05:00
Sergey Vasin e66b74f55e Remove extra spaces in error messages in Modules.resx. (#7662) 2018-08-31 09:52:39 +05:00
Dongbo Wang 86469bda33
Handle operations with ByRef-like types gracefully in PowerShell (#7533)
ByRef-like types are supposed to be used on stack only, so we need to fail gracefully when accessing properties, calling methods, or creating objects related to ByRef-like types.
2018-08-26 12:50:58 -07:00
Sergey Vasin fcc519bb08 Fix parameter name in the Get-Variable cmdlet error message. (#7384)
Before the fix when using Get-Variable or Get-Alias cmdlets with the -Scope parameter with wrong value, the error message refers to 'scopeID' parameter instead of 'Scope'.
2018-07-31 08:50:41 +05:00
Robert Holt c94fc31f97 Enforce the 'CompatiblePSEditions' check for modules from the legacy 'System32' module path (#7183)
- Add `%WINDIR%\System32\WindowsPowerShell\v1.0\Modules` (Windows PowerShell $PSHOME) to the end of the default PSCore 6 module path (i.e. the module path as initially set at startup).
- Cause an error to be thrown by `Import-Module` when a module with `CompatiblePSEditions` not containing `"Core"` is being loaded from the 'System32' module path.
- Suppress output of modules listed by `Get-Module -ListAvailable` from Windows PowerShell $PSHOME when `CompatiblePSEditions` does not contain `"Core"`.
- Introduce the `-SkipCompatibilityCheck` switch parameter on both `Import-Module` and `Get-Module` to respectively allow importing incompatible modules and listing incompatible modules.
- Adds a  `PSEdition` column to the `PSModuleInfo` table view format.
- Ensures that completions are not given for incompatible modules on the System32 module path.
2018-07-16 16:58:40 -07:00
Aditya Patwardhan 75ba74cce6
Merge pull request #7242 from daxian-dbw/exp
Add support to experimental features

RFC: https://github.com/PowerShell/PowerShell-RFC/pull/114

Goals:

Allow experimental features to be declared by PowerShell engine and modules.
Allow experimental features to be enabled via powershell.config.json
Allow Function, Cmdlet, parameters and parameter sets to be shown to the user or hiden from the user depending on whether the associated experimetnal feature is on or off.
Allow discover experimental features using cmdlet Get-ExperimentalFeature
2018-07-12 15:52:04 -07:00
Robert Holt 6a66a6e0f0 Add more information to job process failure error (#7251) 2018-07-12 08:06:07 +05:00
Travis Plunk 79d20a1873
Update PowerShell Direct to try pwsh then fallback to powershell (#7241)
Update PowerShell Direct to try pwsh then fallback to powershell

  - Forward port changes from Windows Powershell to fall back
  - change the order from powershell->pwsh to pwsh->powershell

fixes #7237
2018-07-11 15:44:31 -07:00
Dongbo Wang 2c9519ba3b [Feature] Address Feedback: Use better error message and add more tests 2018-07-10 02:14:59 -07:00
Dongbo Wang d8d3344e98 Generate logging resources for Unix platforms 2018-07-06 13:28:20 -07:00
Dongbo Wang dc2d741791 Add logging, formatting, and '$EnabledExperimentalFeatures' 2018-07-06 13:28:19 -07:00
Dongbo Wang 8a5ddbb231 Support experimental feature in modules 2018-07-06 13:28:19 -07:00
Dongbo Wang eed9842534 First batch: Basic experimental feature flag and attributes enforced 2018-07-06 13:28:18 -07:00
Christoph Bergmeister bbd48f60e0 Add location history for Set-Location to enable 'cd -' scenario (issue #2188) (#5051)
* Implement location history feature for Set-Location.
This makes it possible to go back to the last directory using 'cd -',
which is exactly the same syntax as on Linux shells.

* Use an existing stack implementation instead of relying on an environment variable and move logic for 'cd -' into the internal class of SessionState.Path.SetLocation
Keep the (additional) setting of an environment for Unix system in case of mixed usage of cd and Set-Location to provide consistency.

* Use a bounded stack with a limit of 1000 and adapt tests.
Remove setting environment variable on Linux as discussed in PR.

* Fix test: use get-location explicitly to avoid subtle difference in the path string (e.g. an additional slash at the end)
Make syntax to .net call of environment consistent with surrounding code

* Move initialization of _workingLocationHistoryStack into constructor of SessionStateInternal and set the limit to 20 as discussed in PR 5051.

* Make new BoundedStack class in engine utils internal
2018-06-26 12:21:38 +05:00
Bruce Payette 3a4c410499 Fix for #6855 - Measure-Object should handle scriptblock properties. (#6934)
Measure-Object should handle `ScriptBlock` properties. Fixed by renaming `MshExpression` to `PSPropertyExpression` and making it public. Then in `MeasureObjectCommand`, lifting it up to the parameter level. Previously the implementation exposed the Property as a string and
wrapped it internally as a `PSPropertyExpression`. Now the parameter type is `PSPropertyExpression` directly allowing for both wildcard strings and `ScriptBlock`.

`PSPropertyExpression` now lives in a public namespace where it can be used by cmdlet and script authors to easily add the same type of functionality to their commands. I also modified `PSPropertyExpression` to handle hashtables properly as objects so
         @{prop = 3} | measure-object prop
and
         @{prop = 3} | measure-object {$_.prop}
will work the same. (Previously the example using just the property name would fail.)
2018-06-20 00:23:11 -07:00
Hubert Bukowski 9ac701dbee Fix conditions for transcription of Write-Information command. (#6917)
Makes a transcription of Write-Information command consistent with $InfomrationPreference variable.
2018-06-16 21:11:21 +05:00
Dongbo Wang aa0af5ed56
Further improve PSMethod to Delegate conversion (#6851)
Refactor code to make it easier to maintain and a little faster. Changes are as follows:

1. Support finding a matching signature with variance. But make PowerShell prefer exact match over a match with variance.
2. The metadata signatures in `PSMethod<..>` are generated based on the array of method overloads in `MethodCacheEntry.MethodInformationStructures`, in the exact same order. So in `LanguagePrimitive.ConvertViaParseMethod`, when we try to figure out if there is a match using the metadata signatures in `PSMethod<..>`, we can get the index of the matching signature, and the same index should locate the matching method in `MethodCacheEntry.MethodInformationStructures`. Therefore, we don't need to compare signatures again in the actual conversion method, and instead, we can just leverage the index we found when figuring out the conversion in `ConvertViaParseMethod`.
   - This gets rid of the reflection call `GetMethod("Invoke")` and the subsequent signature comparisons in the final conversion method.
   - Also, when comparing signatures using `PSMethod<..>` in `ConvertViaParseMethod`, we can just use the generic argument types of each `Func<..>` metadata type, instead of calling `GetMethod("Invoke")` and then `GetParameters()`. This makes the code for comparing signatures simpler (the type `SignatureComparator`).
   - Move `MatchesPSMethodProjectedType` from `PSMemberInfo.cs` to the type `SignatureComparator` in `LanguagePrimitives.cs`, as it's closely related to the signature comparison. Also, renamed it to `ProjectedTypeMatchesTargetType`.
   - These changes make PSMethod-to-Delegate conversion a little faster, but no big improvement, as the true bottleneck probably is in delegate creation(?). Actually, the performance of this conversion is not critical at all at this moment because this feature should rarely be used in any hot script path. So this exercise is mainly for fun. 
3. Remove `PSEnum<T>`. We can directly use enum types when constructing the metadata type `Func<..>`.
4. Remove the code that generates metadata signatures for generic method definitions (call `MakeGenericMethod` with fake types like `GenericType0`, `GenericType1`). This is because:
   - We don't support convert generic method to delegate today, so may be better not spending time on preparing the metadata signature types for those methods. 
   - When the day comes that we need to support it, it's better to use generic argument types directly to construct the `Func<..>` metadata types. I left comments in `GetMethodGroupType` method in `PSMemberInfo.cs` to explain why that approach is better.
2018-05-15 11:45:04 -07:00
Dan Travison 385cc1b796 Disallow Basic Auth over HTTP on Unix (#6787)
Disallow Basic Auth over HTTP on Unix

Fix: #6779
2018-05-02 14:29:10 -07:00
Dongbo Wang 8aec158519
Clean up uses of CommandTypes.Workflow and WorkflowInfo (#6708)
[breaking change] Clean up code related to the uses of `CommandTypes.Workflow` and `WorkflowInfo` in `System.Management.Automation`. This change mainly affects help provider code.

This PR includes a few minor breaking changes:
- Change the `public` constructors of `WorkflowInfo` to `internal`. We don't support workflow in PSCore, so I think it makes sense to not allow people to create `Workflow` instances.
- Remove the type `System.Management.Automation.DebugSource` since it's only used for workflow debugging.
- Remove the overload of `SetParent` from the abstract class `Debugger` that is only used for workflow debugging.
- Remove the same overload of `SetParent` from the derived class `RemotingJobDebugger`.
2018-04-27 23:02:15 -07:00
Steve Lee 10900e0a24 Update error message that Disconnect is only supported with WSMan (#6689) 2018-04-24 16:29:01 -07:00
Jeffrey Snover 24dafac3f4 Added line break to Acess Denied error message. (#6607) 2018-04-10 07:51:06 +04:00
Staffan Gustafsson b1743dca01 Removing invalid resources to make Visual Studio builds compile. 2018-04-02 18:22:37 -07:00
Dongbo Wang d1cf82ec20 Clean up workflow logic in the module loading component (#6523)
Clean up workflow logic in the module loading component.
Workflow module is not supported in PSCore.
Currently, Import-Module throws a terminating error when seeing .xaml modules. After the change, Import-Module throws a non-terminating error when seeing .xaml modules.
2018-04-02 16:18:56 -07:00
rjmholt faa21c907b Change the 'SaveError' method in Parser to use nameof for error ids (#6498)
Many error messages in PowerShell currently use a LINQ expression to pass both the name of the error and the message through in the error processing. This PR uses the `nameof` feature to carry the error name/ID and gets rid of LINQ expression reflection, hopefully improving performance, especially in editor scenarios.
2018-03-28 16:21:25 -07:00
Dongbo Wang 9df8ea58e9
Throw better parsing error when statements should be put in named block (#6434) 2018-03-21 14:24:20 -07: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
Staffan Gustafsson a9c6292903 Enable conversions from PSMethod to Delegate (#5287)
Underpinnings to make calling of Extension methods /Linq easier from PowerShell.
Enables the following that previously had to be done via reflection.

class M {
  [int] Twice([int] $value) { return 2 * $value }

  [int] DoubleSum([int[]] $values) {
     return [Linq.Enumerable]::Sum($values, [M]::Twice)
  }
}

Each PSMethod is created as with a unique type for the combinations of method signatures in the MethodInfos it represents.

PSMethod<T> where T is a MethodGroup<>, potentially recursive in the last template argument.

This way, we can determine by just looking at the type of a PSMethod if there exists a conversion from the PSMethod to a delegate.
2017-12-01 18:40:35 -08:00
PRASOON KARUNAN V 32286ed22a Added more helpful message for AmbiguousParameterSet exception (#5537) 2017-11-24 18:37:20 +04:00
Paul Higinbotham 1962c273c6 Fix for PowerShell hang on exit (#5356)
CoreCLR doesn't call finalizer on process exit. PowerShell relies on the CLR finalizer to clean up state on exit. In this case, a Runspace pool was not closed or disposed and any pipeline worker threads created to run concurrent scripts won't end, causing the hang. The same thing can happen if any individual Runspace is created to run a concurrent script and is not closed.

We cannot use the `AppDomain.DomainUnload` event because it's not supported by the default load context. The `AppDomain.ProcessExit` event is also not helpful since it is only called during application exit which means threads already have to be cleaned up.

The fix introduces a static property called `PrimaryRunspace` to `Runspace`. When the PrimaryRunspace is closing it means that the PowerShell session is ending and on exit clean should be performed. The static property `PrimaryRunspace` can only be set once per process.
2017-11-14 14:01:11 -08:00
Dan Travison 2670917981 Redirect ETW logging to Syslog on Linux (#5144)
This PR is divided into the following areas:
1. Add/Rename the PowerShell/Windows ETW manifest to the repo and change both the provider id (guid) and name. See #4939.
The manifest is at tools/resxgen/PowerShell-Core-Instrumentation.man

2. Generate a resx file containing the string resources needed for logging ETW events to syslog.
This is accomplished by tools\resxgen\resxgen.psm1 and resxgen.ps1. The tool generates two files

A resx file containing string resources for each message string from the manifest. This is generated in the System.Management.Automation\gen directory.
A C# class (EventResource) that provides the mapping between the integer event id and the associated string resource name. The file is generated in the System.Management.Automation\CoreCLR directory with a compile-time condition of UNIX
NOTE: The EventResource.cs class generated by resgen is explicitly ignored in the csproj file; it is not used.

3. SMA\utils\tracing\PSSysLogProvider.cs
Implements the abstract LogProvider class and is the syslog equivalent of PSEtwLogProvider. The class contains a number of logical methods for logging lifecycle, health, and normal events.

4. SMA\utils\tracing\SysLogProvider.cs
This is the Syslog equivalent of ETW's log provider class and implements a Log method versus ETW's EventWrite. It is also responsible for resolving event ids to resource names and performing the Syslog call. There is a large comment block in the class XML doc that describes the types of log output it produces.

5. SMA\utils\tracing\PSEtwLog.cs
PowerShell's current implementation is tightly coupled to this class; with code calling it directly for all events. To simplify integration of syslog, I updated the class to create an instance of PSSysLogProvider on Linux and removed the Linux-specific stub file.

6. SMA\engine\PropertyAccessor.cs
This class provides a wrapper around PowerShellProperties.json and has been extended to have Unix-specific assessors for configuring logging. Note that the file is expected to be in the $PSHOME directory to ensure SxS.

Currently, there are four configuration properties:

- LogIdentity - the string identifier for the source application. This defaults to 'powershell' and can be configured to enable distinguishing between side-by-side installations.
- LogLevel - configures the tracing level (log level). Informational is the defauilt.
- LogChannels - used to enable operational and analytic logging. Operational is the default.
- LogKeywords - used to configure enabling tracing by keyword. All keywords other than `UseAlwaysAnalytic` are enabled by default.

NOTE: This will likely change. PowerShell sometimes confuses the analytic channel with this keyword and sends logging to the wrong channel. Once this is cleared up, `UseAlwaysAnalytic` and `UseAlwaysOperational` keywords will likely be removed.

Additional Notes:

1. The current implementation writes directly to syslog and writing to a separate log file is still pending.
2. The generated class and resx are not part of the build; instead, it is expected that Resxgen should be run when events are added to the manifest. To fully automate the process, resxgen will need to be updated to generate the other dependent enums such as 'PSChannel', 'PSEventId', 'PSTask', 'PSOpcode', etc. You will see parsing logic in resxgen.psm1 to prepare for that but it is not enabled at this point.
4. Documentation is pending that documents the format of the syslog output as well as associated configuration.
5. As mentioned at the start, tests are pending
2017-11-06 08:32:29 -08:00
Jason Shirk 8234e3cd19
Remove CommandFactory (#5266)
The class CommandFactory served no real purpose in command lookup
other than to unnecessarily add a few frames to the call stack,
introduce an extra indirection, and add a couple of unnecessary
checks that essential instances like ExecutionContext are not null.
2017-10-28 21:01:47 -07:00
James Truher [MSFT] be700729d6 Unify cmdlets with parameter 'Encoding' to be of type System.Text.Encoding (#5080)
This unifies file encoding across the inbox cmdlets to be UTF-8 without a BOM for all platforms. This is a breaking change as cmdlets on windows have a number of different encodings. This supports better interoperability with tradition Linux shells as we are using the same encoding.

Validate that files are created with UTF-8 encoding without BOM
Update tests to validate Encoding parameter to new type and create new tests for
parameter type validation.

[Breaking Change] The '-Encoding Byte' has been removed from the filesystem provider cmdlets. A new parameter '-AsByteStream' is now added to indicate that a byte stream is required as input, or output will be a stream of bytes.
2017-10-23 19:46:27 -07:00
Steve Lee 6177d28410 removed RunspaceConfiguration support (#4942)
For PSCore 6, we are only supporting InitialSessionState. The RunspaceConfiguration APIs were already made internal. This PR removes all the code related to RunspaceConfiguration. This also means that some public APIs have changed. Was deciding between leaving the RunspaceConfiguration parameters and throwing Unsupported, but thought it was better to have it a compile-time error. This should simplify the code base.
2017-10-18 09:12:23 -07:00
Tadas Medišauskas 844bf11dde Get-Verb: add verb descriptions and alias prefixes (#4746)
* Get-Verb: add descriptions and prefixes

* Add description and alias prefix tests

* Make the new classes internal

* Convert alias prefix to static method

* Move verb descriptions to a resource file

* Shorten function name

* Shorten alias prefix function name

* Change tests to look at counts

* Add uniqueness test

* Add missing alias prefixes

* Fix name collision

* Change alias prefix for Compare

* Rename method

* Remove unnecessary string allocation

* Make tests easier to diagnose
2017-10-12 14:40:06 -07:00
Steve Lee 7f94412170 removed leading whitespace (#4991)
Add an optional extended description…
2017-10-04 08:14:26 +04:00
Aditya Patwardhan 1e271ea187 Add Remoting and Job tests (#4928) 2017-10-02 13:43:43 -07:00
Jeffrey Snover d8a075e484 Provide the correct form for foreach when there is an error. (#4950)
* Update ParserStrings.resx

* Provide the proper form for foreach

* added "{...}"
2017-10-02 10:12:52 -07:00
Steve Lee a82f6376ab Change CRLF to LF for files that are already in repository (#4956) 2017-09-29 17:43:57 -07:00
Jeffrey Snover b9845d5ec1 Add a new line to 'CommandNotFoundException' error string (#4934)
We're here at PowerShell Unplugged at Ignite, and this error message could *really* use a new line!
2017-09-29 12:16:05 -07:00
Dongbo Wang db33d90479 First round of workflow cleanup (#4777)
This round of cleanup focuses on the following areas
- Tab completion code
- InitialSessionState
- Compiler/MiscOps
- Utils/SessionStateFunctionAPIs
Changes in the rest affected files are mainly some corresponding changes due to the cleanup work in the above areas.
2017-09-11 08:55:13 -07:00
Ilya 3c597367ba Replace 'Windows PowerShell' with 'PowerShell' in resx files (#4758)
Replace 'Windows PowerShell' with 'PowerShell' in '.resx' files where appropriate.
2017-09-07 12:33:56 -07:00
Kory Gill c14648e7a8 Remove double spaces between words in resx files (#4741) 2017-09-03 20:48:08 +04:00
Mike Richmond 515a999e1c Porting Enable-PSRemoting and its Tests (#2671)
Fixes #1193 for most scenarios. The remaining scenario to be addressed is the Nano Server bring-up scenario. To continue supporting that scenario, I left the Install-PowerShellRemoting script in place.

This change 
1. Ports Enable-PSRemoting and Disable-PSRemoting to PowerShell Core
2. Adds side-by-side PowerShell Core remoting support to the PSSessionConfiguration cmdlets and PSRemoting cmdlets.
3. Ports PSSessionConfiguration tests

This change also introduces a behavioral difference. The PSRemoting and PSSessionConfiguration cmdlets are now context-sensitive and only work for endpoints that match the PowerShell type. For example, Get-PSSessionConfiguration, when running in PowerShell Core, will only return PowerShell Core WinRM endpoints. It will only modify PowerShell Core WinRM endpoints and cannot be used to configure Windows PowerShell endpoints.
2017-08-08 09:36:22 -07:00
David Christian 1a003a8af3 Support Positive/Negative ValidateRange (#4084)
To improve code clarity and give better error messages when using ValidateRange, you can now specify:

```
[ValidateRange(ValidateRangeKind.Positive)]
```

instead of

```
[ValidateRange(1, 2147483647)]
```

Valid kinds are:

Positive
Negative
NonPostiive
NonNegative
2017-08-02 11:24:06 -07:00
Steve Lee cf9f8c8574 Give error instead of crashing if WSMan client lib not available (#4387) 2017-07-31 16:26:24 -07:00
Ilya dc76c86f7a ValidateSetAttribute enhancement: support set values to be dynamically generated from a custom ValidateSetValueGenerator (#3784)
Currently `ValidateSetAttribute` accepts only explicit constants as valid values. This is a significant limitation. Sometimes we need to get valid values dynamically, ex., Azure VMs, logged-on users and so on. The PR add follow possibilities:
- pass a _custom type_ (a valid values generator) implementing `IValidateSetValuesGenerator` interface to get valid values dynamically.
- pass a _custom type_ (a valid values generator) derived from `CachedValidValuesGeneratorBase` abstract class to get valid values dynamically and _cache_ the list to share with other ValidateSetAttribute attributes.
2017-07-13 21:28:32 -07:00
jeffbi 1688703caf Make Get-ChildItem follow symlinks on demand, with checks for link loops (#4020)
Add the dynamic parameter `-FollowSymlink` to `Get-ChildItem`.
Add a mechanism for tracking visited directories.
Add native code to get device/inode information on Unix/Windows.
Add warning when refusing to enter an already-visited directory.
2017-07-06 12:28:27 -07:00
Paul Higinbotham a2922d6ac4 Fix for SSH remoting when SSH client abruptly terminates (#4123)
* Fix for SSH remoting when SSH client abruptly terminates

* Put error message in localizable string resource

* Renamed error string per code review request

* Removed extra error==null check
2017-06-29 11:14:33 -07:00
Keith Hill 27e47f9ee1 Implement Unicode escape parsing (#3958)
* Implement Unicode variable width `u{xxxxxx} escape sequences.
2017-06-27 22:55:57 -07:00
Ilya aa97fe7cd1 Resx - remove trailing white spaces and extra Newline at EOF (#4047) 2017-06-22 13:45:11 -07:00
Ilya f04d2fd2bc Convert tab indentations to spaces in *.resx files (#3576)
* Convert tab indentations to spaces in *.resx files

* Add Newline at EOF

* Remove extra char
2017-06-06 18:18:59 -07:00
Dongbo Wang 8ae6c5bb3b Refactor PowerShell Core to use the default CoreCLR loader instead (#3903)
Remove the code that spins up our own assembly load context. Keep the code that registers our `Resolve` method to the default loader's `Resolving` event, so that we can continue to do special assembly resolution as needed (such as the GAC probing logic needed for consuming FullCLR PS modules).

Essentially, the assembly `Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.dll` is not needed anymore, the remaining code should be moved to S.M.A.dll. However, that will break DSC and other native hosts that are hosting powershell. So this assembly is kept for now.
2017-06-05 20:59:30 -07:00
Aditya Patwardhan 73dd94197b Removed automatically adding year to copyright message (#3804)
Removed automatically adding year to copyright message for file generated by New-ModuleManifest and New-PSRoleCapabilityFile.
2017-05-21 21:19:10 -07:00
Bruce Payette dfb3866c5d Support backgrounding pipelines with ampersand (#3360)
Implements support for backgrounding pipelines with &. Putting & at the end of a pipeline will cause the pipeline
to be run as a PowerShell job. When a pipeline is backgrounded a job object is returned. Once the pipeline is
running as a job, all of the normal job cmdlets can be used to manage the job. Variables (ignoring process-specific
variables) used in the pipeline are automatically copied to the job so
    copy $foo $bar &
just works. The job is also run in the current directory instead of the user's home directory as is the case with Start-Job.Implement
2017-05-18 19:15:19 -07:00
jeffbi 938e13602b Change error message when using New-Item to create a symlink and the item exists (#3703) 2017-05-05 10:09:34 -07:00
Ilya 3d7ef43498 Improve ValidateCount attribute error message (#3656)
Leave only two message for ValidateCount attribute error:
1. Count is not in allowed range.
2. Count is not exactly equal allowed value.
2017-05-02 10:04:52 -07:00
jeffbi f1769fe7a8 Change behavior of Remove-Item on symbolic links (#621) (#3637)
When 'Remove-Item' is used to remove a symbolic link in Windows, only the link itself is removed. The '-Force' switch is no longer required.
If the directory pointed to by the link has child items, the cmdlet no longer prompts the user to remove the child items---those child items are not removed. The '-Recurse' switch, if given, is ignored.
This brings 'Remove-Item' more in line with the behavior of the 'rm' command on Unix.
2017-04-27 17:47:24 -07:00
Paul Higinbotham a16b71bad4 SSH Remoting should handle multi-line error messages from SSH client (#3612)
* Fix to support multi-line error messages from SSH client

* Fixed resx file

* Added null check

* Added Environment.NewLine
2017-04-21 18:01:11 -07:00
Ilya e8ec40069b Improve ValidateCount attribute error message (#3596) 2017-04-21 18:01:04 -07:00
Christopher Ubben b2259f8f70 Update all W3 links in the resource files to use HTTPS instead of HTTP (#3331) 2017-03-17 11:04:00 -07:00
Chunqing Chen 3f274aad9c make transcripts include the configuration name in the transcript header (#2890)
* PowerShell transcripts should include the configuration name in the transcript header
* adding test case for PowerShell transcripts should include the configuration name in the transcript header #2890
2017-03-15 22:06:07 -07:00
Steve Lee 99d696f31f Fix Test-Modulemanifest to normalize paths correctly before validating (#3097)
Changed hard coded Windows directory separator and resolved path so the slashes are correct.
Throw if resolving file path returns more than one result

Fixes #2610
2017-03-01 10:36:02 -08:00
Paul Higinbotham b4cb5e95a2 Implementation for Invoke-Command step-in remote debugging (#3015)
These changes provide the ability to debug remote running scripts started with the Invoke-Command cmdlet. The design is event based and provides new public events that allow subscribers to be notified when an Invoke-Command remote session is ready for debugging. Since Invoke-Command allows running scripts on multiple targets at once (fan-out) the notification event is raised for each remote session as it becomes ready for debugging. The subscriber to these events will be a script debugger implementation (such as PowerShell console, ISE, or VSCode) and will handle all debugging details such as simultaneously debugging multiple remote sessions at once in separate windows.

But these changes also include an internal implementation which is used by default if host debuggers don't want to handle the debugging details. This internal implementation is what PowerShell console, ISE uses so they can have this new behavior without having to modify their debugger implementations. The internal implementation serializes each remote session of Invoke-Command so that they can be debugged one at a time. The remote session debugger is "pushed" onto the internal debugger stack so that debugging transitions to the remote session. Existing debugging commands work so that the "quit" debugging command will stop the current remote session script from running and allow the next remote session to be debugged. Similarly the "continue" debugging command allows the script to continue running outside step mode and again go to the next remote session for debugging. The "stepout" debugging command steps out of all Invoke-Command remote sessions and lets the script continue to run for each remote session in parallel as they are normally run.

The purpose of Invoke-Command step-in remote debugging is allow seamless debugging of a local script that calls Invoke-Command on remote targets. But there is also a new Invoke-Command "-RemoteDebug" parameter that lets you Invoke-Command on the command line and have it drop directly into the debugger.

An example from the PowerShell command line looks like this:
```
PS C:\> C:\TestICM.ps1
Entering debug mode. Use h or ? for help.

Hit Command breakpoint on 'Invoke-Command'

At C:\TestICM.ps1:2 char:1
+ Invoke-Command -cn $computerName,paulhig-3 -File c:\LinuxScript.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[DBG]: PS C:\>> list

    1:  $computerName = "localhost"
    2:* Invoke-Command -cn $computerName,paulhig-3 -File c:\LinuxScript.ps1
    3:  "Test Complete!"

[DBG]: PS C:\>> stepin
At line:1 char:1
+ Write-Output "Running script on Linux!"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[paulhig-3]:[DBG]: [Process:14072]: [Runspace5]: PS C:\Users\paulhi\Documents>
```

Notice that the debugger "stepin" command transitioned from local script debugging to debugging the remote session on computer "paulhig-3", as can be seen by the change in the debugger prompt.

You can also do this from the command line to drop directly into the debugger
```
Invoke-Command -cn localhost -Script  $scriptblock -RemoteDebug
```

These changes also remove an old behavior that was incompatible with this new step-in feature. Previously if a remote session running script hit a break point it would stop in the debugger and go to the "disconnected session" state. This was to allow the user to reconnect using Enter-PSSession and then interactively debug the remote session script. This behavior has been removed and now the user needs to attach a debugger using the newer Debug-Runspace cmdlet.
2017-03-01 10:28:25 -08:00
Jason Shirk 8cf7989b53 Change NestedModule to NestedModules in error message (#3214) 2017-02-27 15:11:12 -08:00
Paul Higinbotham ca12001c8d Implement RoleDefinitions RoleCapabilityFiles keyword (#3067)
* Changes to implement remote endpoint RoleDefinition RoleCapabilityFiles keyword
* Fixed spelling error.  Added back missing resource string
* Updated tests from CR comments
* Simplified error tests per Code Review
* Test change from Code Review
2017-02-14 10:42:17 -08:00
Ilya a16fead0a5 Fix error position reporting on classes (#3103)
Interactive hosts expect an `IncompleteParseException` to signal that more input is expected.

When detecting errors, the parser can report 2 positions:
* where the error should be reported
* where the error was detected

Typically these are the same, so most error reporting methods have a single parameter.
For missing braces, the pattern is supposed to be to report the error after the opening brace, but the error is typically detected at the end of the file.

There were a few places where we were not consistent in reporting such errors, this PR corrects those places.
2017-02-13 16:45:00 -08:00
Paul Higinbotham d2bf6294ab SSH remoting cmdlet parameter set changes based on RFC 0010 (#2710)
* RFC 0010 SSH remoting cmdlet updates.

* Tweaks to SSH remoting cmdlets

* SSHTransport parameter is now optional instead of mandatory.  Aded fix for CoreCLR entry point when hosted in SSH as a subsystem.

* Added tests

* Code review feedback

* Code review comment changes

* Making SSHTransport switch parameter mandatory because otherwise existing Invoke-Command parameter set

* The new SSH parameter set was causing legacy positional based parameters to no longer work. This fix separates the SSH parameter sets from the existing WinRM parameter sets.

* Fixed region name spelling error.
2016-12-02 14:01:08 -08:00
charub 6526968947 Fix Start-Transcript input path validation issues. (#1749) 2016-10-05 16:18:50 -07:00
charub 88d64c243e Fix Start-Transcript input path validation (#1749) 2016-10-05 16:18:50 -07:00
Jason Shirk (POWERSHELL) c7951e13c0 Remove most Maximum* capacity variables
MaximumErrorCount is fixed at 256 (we may want to consider an environment variable to make this bigger)

MaximumAliasCount, MaximumDriveCount, MaximumFunctionCount, and MaximumVariableCount have been removed.
2016-09-26 15:16:35 -07:00
Sergei Vorobev 6992a6479a Merge pull request #2260 from jsoref/spelling-public
Fix spelling in public APIs
2016-09-19 17:33:46 -07:00
Paul Higinbotham 0ba1e2d9d1 Minor improvements to SSH remoting cmdlets (#2249)
* Fix for relative paths for KeyFilePath cmdlet parameter, renamed cmdlet KeyPath parameter to KeyFilePath parameter, and added tests.

* Code review comment update

* Added missing KeyFilePath check

* Test fix from review comment
2016-09-14 15:13:10 -07:00
Dongbo Wang 58a2ba730d Merge pull request #2046 from xiaoyinl/use-https-links
Use HTTPS links for go.microsoft.com
2016-09-01 17:23:09 -07:00
Josh Soref 1ad8dec8d2 spelling: display messages (#2135)
spelling: resource strings (display messages and comments)
2016-08-31 14:35:28 -07:00
Josh Soref ab7b5008e3 spelling: public identifiers in src/System.Management.Automation 2016-09-02 16:21:35 +00:00
xiaoyinl f538eeb416 Use HTTPS links for go.microsoft.com
I replace all occurrences of http://go.microsoft.com with https://go.microsoft.com in text files.
2016-08-23 21:21:31 -04:00
PaulHigin 44ad7f9e3c These changes implement PowerShell remoting over SSH. The changes include feedback from code review comments. 2016-08-12 15:47:46 -07:00
PowerShell Team 0dd425da19 Integrate changes between [SD:717473] and [SD:725290] 2016-07-28 18:02:24 -07:00
Dongbo Wang da7f6ba3b2 Move the most recent changes about the ALC from SD to Github 2016-07-08 14:18:20 -07:00
PowerShell Team 49fea9dac9 Add missing files for OPS [SD:717473] 2016-07-06 13:03:56 -07:00
PowerShell Team 8ee6d6ca43 Update files from Source Depot changeset [SD:715912]
Corresponds to 77eda782aa78ba8b7a36c51ee619629ce6c990f2 in psl-monad.
2016-06-15 18:02:03 -07:00
PowerShell Team b38773eb79 Update files from Source Depot changeset [SD:709766]
Corresponds to 15b1623435d6a195d1e877ba5c43709d991f573a in psl-monad.
2016-05-31 14:12:49 -07:00
Jan Kotas ef9a37df79 Rename PowerShellAssemblyLoadContext to PowerShellAssemblyLoader
PowerShellAssemblyLoadContext does not inherit from AssemblyLoadContext. Rename
it to avoid confusion.
2016-05-24 09:55:04 -07:00
PowerShell Team b8dced8e80 Update files from Source Depot changeset [SD:706766]
Corresponds to e2ce37c87c0ab9795bfac2389edc1aff934bdb9e in psl-monad.
2016-05-23 13:14:28 -07:00
PowerShell Team d9bf6b037f Update files from Source Depot changeset [SD:704605]
Corresponds to 75764b265885c1a346d1b2dbcb281d61b71c5b31 in psl-monad.
2016-05-18 17:41:26 -07:00
PowerShell Team 3998ce06ba Update files from Source Depot changeset [SD:700586]
Corresponds to 84837459913bb00660964d19ea07f5e0c7b4b442 in psl-monad.
2016-04-28 13:53:04 -07:00
Sergei Vorobev 2464d58a51 Fix file casing to enable C# binding generation
Use windows-build\gen\<project> instead of windows-builg\gen\<somename>
2016-04-04 14:18:10 -07:00
PowerShell Team 5386c71bb2 Update files from psl-monad
This commit uses psl-monad branch source-depot cc6afbeb
And corresponds to [SD:692351]
2016-03-31 17:27:44 -07:00
PowerShell Team 60b3b304f2 Move files from psl-monad submodule to super-project
This commit uses psl-monad branch source-depot 7209cb9
And corresponds to [SD:688741]
2016-03-30 17:16:23 -07:00