Commit graph

4891 commits

Author SHA1 Message Date
probonopd 669a34a27b Do not download from external sources (#3211)
This commit removes the external dependencies of the AppImage generation script by instead
downloading them from a known (and owned by Microsoft) location:
psgithub.file.core.windows.net.
2017-03-03 10:37:16 -08:00
Kyle Sferrazza ca874e966b Add Arch Linux installation information (#3215) 2017-03-01 17:38:24 -08:00
PetSerAl c490e36a58 Remove System.Array type data (#3231)
* Rename Types_Ps1Xml.generated.cs
* Remove <auto-generated> header from Types_Ps1Xml.cs
* Remove System.Array type data
* Update `Get-TypeData` tests
2017-03-01 12:58:03 -08:00
Dongbo Wang fc30ae1d87 Port CmsMessage cmdlets and Get-PfxCertificate to powershell core (#3224) 2017-03-01 10:51:19 -08: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
Raghu Shantha [MSFT] 875ea100e3 Updated docker release images to pull powershell package from Microsoft Repo (#3219) 2017-02-28 17:17:04 -08:00
Paul Higinbotham 136213d6b4 Fix for race bug in WSMan command plugin instance close operation (#3203) 2017-02-27 15:15:58 -08:00
Jason Shirk 8cf7989b53 Change NestedModule to NestedModules in error message (#3214) 2017-02-27 15:11:12 -08:00
PetSerAl ae37a9fafe Fix powershell to not crash on converting recursive array to bool (#3208) 2017-02-27 10:54:07 -08:00
Staffan Gustafsson e3b59e0f51 Moving Import-PowerShellDatafile from script to cmdlet (#2750) 2017-02-26 16:50:28 -08:00
Steve Lee c74b2a7670 return HTTP response for error status as part of exception (#3201) 2017-02-24 22:29:11 -08:00
Dongbo Wang 21c8a90cc1 Update a comment in Credential.cs to make it accurate (#3194) 2017-02-24 16:55:50 -08:00
Mike Richmond 254afcba04 Add instructions for installation on Nano Server (Fixes #3151) (#3195) 2017-02-24 15:38:29 -08:00
Kitt Holland d69193e49c Prettier formatting for ConvertTo-Json output. #2736 (#2787)
* Prettier formatting for ConvertTo-Json output. #2736

This change standardizes JSON output to example given, as well as
codemaid and online lint tools.

Sample object used for testing:

@{
foo = @{
first = 'a'
second = 'bbbbbbbb'
}
barbarbarbar = @{
first = 'a'
second = 'bbbbbbbb'
NestedArray = @(
'Test3'
'Test4'
'Test5'
3
4
)
NestedObject = @{
MoreObject = 'AnotherObject'
TestBool = $true
}
}
array = @(
'Thing1'
'Thing2'
)
dan = 15
} | ConvertTo-Json

* Updated CoreCLR implementation to use NewtonSoft Indented Formatting

I did not change the FullCLR behavior, I was not sure if you meant to
revert my changes or to leave it as is in the current pull request.

* Added tests that validate pretty Json output.

Not sure if there is a better thought on how to implement these. The
first two fail against current master, but succeed once this PR is
applied. Third test is successful prior and post this PR.

* Moved tests and removed extraneous file.

Moved pretty/compressed json tests from standalone file into the
existing ConvertTo-Json test file.

* Updated tests for cross-platform support
2017-02-24 14:40:11 -08:00
Dongbo Wang b614906f40 Update the PR template to remove links (#3193) 2017-02-23 16:40:20 -08:00
Jeffrey Snover e80fe743d2 add a timeout to test-connection (#2492) 2017-02-23 13:29:18 -08:00
Dongbo Wang a1edf8fba6 Define roles and their responsibilities in a PR (#3168) 2017-02-23 13:13:06 -08:00
Dongbo Wang 8b8d20d56b Work around the hang issue that happens when running class basic parsing tests (#3191) 2017-02-23 13:05:09 -08:00
James Truher [MSFT] 9e27f4a64c Implement -version parameter in console host (address part of https:/… (#3115)
* Implement -version parameter in console host (address part of https://github.com/PowerShell/PowerShell/issues/1084)

This does not support providing a specific version to run, but
like most other *nix commands, -version will now return the version
of the PowerShell Engine. 'powershell' is prepended to the output to
match other *nix commands. We are using gitcommitid which includes more
info about the build.
2017-02-23 09:36:50 -08:00
Dongbo Wang 16ff1978e1 Fix casting single element array to generic collection (#3170) 2017-02-22 23:10:06 -08:00
jeffbi a557c03570 Provide additional tests for the *-Job cmdlets (#3110) 2017-02-22 08:46:27 -08:00
Steve Lee 152de40852 Merge pull request #2082 from andschwa/appimage
Generate AppImage
2017-02-21 10:41:24 -08:00
noahleigh 69841d5c57 Fixed broken link in create-powershell-scripts.md (#3171)
* Changed broken link to a working blog post

"run-ps" isn't a linkable document, so I changed the "Running PowerShell Scripts Is as Easy as 1-2-3" to link to an external article on Windows IT Pro with the same name.
2017-02-19 17:02:29 -08:00
Ilya e10cbff354 Add ShouldProcess to New-FileCatalog and Test-FileCatalog (#3074)
* Add ShouldProcess to New-FileCatalog and Test-FileCatalog

Close #3068

Add support `-WhatIf` and `-Confirm` to `New-FileCatalog` and add a
test.
`Test-FileCatalog` has a common code base with `New-FileCatalog` so it
automatically get the same. I believe that adding a separate test in
this case doesn't make sense.

* Fiz after code review

Remove  _ShouldProcess
Add var in test
2017-02-17 16:32:58 -08:00
Ilya 88c8be75f2 Get-ComputerInfo - fix typo in property name (#3167) 2017-02-17 13:10:51 -08:00
Andrew Schwartzmeyer db93f411da Add Third Party Notices for AppImage
This license specifically covers the additional libraries that
are bundled inside the AppImage archive.
2017-02-17 11:09:36 -08:00
Andrew Schwartzmeyer 8185fd9350 Add AppImage to CI 2017-02-17 11:09:36 -08:00
probonopd 0c1b11724e Add AppImage documentation 2017-02-17 11:09:36 -08:00
probonopd 0e9d85084f Add AppImage tooling
* Use icon from local repository
  https://github.com/PowerShell/PowerShell/pull/2027#discussion_r75960616

* Use the deb that has been generated in this build

* Copyright and license
  https://github.com/PowerShell/PowerShell/pull/2027#discussion_r75960505

* MIT License for appimage.sh
  https://github.com/PowerShell/PowerShell/pull/2027#discussion_r75960505

* Full text of the MIT License is in license_thirdparty_proprietary.txt

* Clarify license and clean up unused code
  https://github.com/PowerShell/PowerShell/pull/2027#discussion_r76104601

* Mark appimage.sh as executable
2017-02-17 11:07:10 -08:00
Dongbo Wang 5a8fa57278 Fix PSModuleInfo.CaptureLocals to not do ValidateAttribute check when capturing variables from the caller's scope (#3149)
Fix PSModuleInfo.CaptureLocals to not do ValidateAttribute check when capturing variables from the caller's scope
2017-02-16 21:25:23 -08:00
Paul Higinbotham c266c8ebca Fix for duplicate types in TypeTable (#3141)
When a TypeTable is created it includes the types from type files provided along with references to the type files. When the InitialSessionState (ISS) object processes these types it reads the type files again and ends up with duplicate type entries. PowerShell V5.1 ISS type processing was re-written to improve performance and no longer removes duplicate types, so that this scenario (runspace ISS reuse) results in errors causing a regression.

The fix is to copy only type data when a TypeTable is passed to the ISS.
2017-02-16 16:28:29 -08:00
Dongbo Wang d60dc730a4 doc updates for release alpha.16 (#3160)
* doc changes for alpha.16 release

* update spelling ignore file for new release
2017-02-16 09:09:45 -08:00
Ilya 409ab7443f Fix GetType() bad pattern and related issues in tests (#3134)
* Fix GetType() bad pattern and related issues in tests

$var.GetType() can raise an exception in tests so we should check $var
before make the call. A large part of the tests does not make this
check.
I start with searching ".GetType()" but discovered many related issues
in tests (reduntant and unneeded tests, "throw" bad pattens, bugs,
formattings (sorry!) and so on) - I had to fix them too.

* Fix after code review
* Second wave of migration GetType() -> BeOfType
Removed 'GetType().Name' patterns.
2017-02-15 16:40:51 -08:00
James Truher [MSFT] d801b75d35 Remove async tests for parser (#3119)
* Remove async tests for parser
this is a fix for https://github.com/PowerShell/PowerShell/issues/3069
This removes an attempt to work-around the issue of tests hanging on Travis-CI.
* remove unneeded finally block
2017-02-15 16:39:30 -08:00
Ilya fd70adbc90 Improve console cmdlets tests (#3101)
* Improve console cmdlets tests
Main improvements refer to tests of the Write-Host cmdlet.
Original tests:
1. Slow because run external processes
2. Don't test colors and -NoNewLine in fact.

1. The original tests is preserved (deleted one as redundant) but marked
by 'Slow' tag. They is preserved because they actually check the output
on the work, not a test console.
2. Add negative color tests. (Code cover grow!)
3. Add tests based on TestHostCS. This test host has been refined so we
can see colors and a new line in output.
4. Add minor fixes for test modules loads.

Also I add support for Information stream. I originally planned to use
it but not actually used. However, I have left this as a useful addition
for future tests.
I wonder that a Write-Host console output is duplicated in Information
Stream - Is it by design? I left a debug print on this matter in the
test code.

* Fix after code review
* Corrections after code review
Suppress import-module warnings
Rename Describes
Add "-Object" test
Add Stream.Information tests with TestHostCS
* Add checks for Streams.Information and add comments
2017-02-14 11:00:03 -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
Andrew Gaspar ca5fc9c5a8 Fix tab completion of native parameters (#2919)
Native argument completers were not invoked when the argument was a single dash.

The fix is to treat unbound command parameters as command arguments for the purposes of parameter/argument completion.
2017-02-13 16:02:56 -08:00
Steve Lee a042dc1ff1 Fix reference to sshd service restarting (#3138)
Addresses https://github.com/PowerShell/PowerShell/issues/3116
2017-02-13 14:13:13 -08:00
Ilya aa764dd54e Small typo in archive cmdlets tests (#3121)
* Small typo in archive cmdlets tests
* Add  -ErrorAction SilentlyContinue
2017-02-10 13:39:34 -08:00
Sergei Vorobev 39c44b4ffc Don't allow_failures on osx (#3123) 2017-02-09 14:01:54 -08:00
Sergei Vorobev 367b04d909 Use ruby 2.3.1 for fpm on OSX (#3120) 2017-02-09 09:35:34 -08:00
Ilya b22369e2be Make small optimization in parser tests (#3072)
* Make small optimization in parser tests

* Add Clear() for common command
Remove commands from AfterEach

* Refactoring test 'functions are resolved before cmdlets'
2017-02-08 17:42:44 -08:00
jeffbi 7ba3b50d4a Fix #3080 (#3107)
Pass null rather than "localhost" to CimSession.Create
2017-02-08 08:40:56 -08:00
Jason Shirk cc664bc639 Fix lock contention during script compilation (#3064)
In rare cases, it was possible to cause high contention on a lock used
while compiling code to run in the interpreter.

This fixes the problem in a couple different ways:

* Use ConditionalWeakTable which has finer granularity in locking
* Avoid dictionary lookups in the most common cases
  - There really aren't too many real cases, I could have covered them
    all, but keeping the code generic is useful for the future.

Not quite related, but I noticed we didn't cache certain interpreter
instructions and it made sense to add a cache because we generate a lot
of array-init instructions.
2017-02-06 23:09:55 -08:00
James Truher [MSFT] 5871e1ac4b Provide class level coverage data via OpenCover module (#3088) 2017-02-06 23:04:45 -08:00
Ilya 29818062e8 Convert Get-FileHash to a cmdlet (#3024) 2017-02-03 18:11:57 -08:00
Steve Lee 803b70f318 Update KNOWNISSUES.md (#3085)
Added some issue #s for open issues.  Removed some rows from the table that have been fixed.
2017-02-03 17:55:47 -08:00
Francisco Gamino f852e40b3c Enabling crossgen for the assemblies used by Add-Type, which are Microsoft.CodeAnalysis.CSharp.dll, Microsoft.CodeAnalysis.dll, Microsoft.CodeAnalysis.VisualBasic.dll, and Microsoft.CSharp.dll. This speeds up executing Add-Type from ~3 to 0.9 seconds. (#3086) 2017-02-03 15:19:05 -08:00