Commit graph

146 commits

Author SHA1 Message Date
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