Preface
Not sure if this is the right place or if my problem is an issue or by design. We are currently looking alternatives for a self developed scripting engine.
Our partners know Powershell, however one of our requirements is independence on any "installed" software, so Windows Powershell, even though it should be available on every Windows 7+, can not be considered.
We are looking at Powershell Core because as far as we understand we should be able to provide everything that is necessary to run a script by simple copy-deployement.
Furthermore, we want to have control over which Cmdlets can be executed ("sandboxing"), so we want to use runspaces and host the powershell scripts ourselves.
I was tryint to setup a simple powershell core host with a runspace using these two examples:
https://github.com/PowerShell/PowerShell/tree/master/docs/host-powershell/sample-dotnet2.0-powershell.beta.3
https://docs.microsoft.com/en-us/powershell/developer/hosting/creating-a-constrained-runspace
In the second link, a runspace is created and the "Get-Process" Cmdlet should be made available by using
SessionStateCmdletEntry ssce1 = new SessionStateCmdletEntry(
"get-process",
typeof(GetProcessCommand),
null);
However, when I use the first link as base, getting the powershell core sdk using nuget, GetProcessCommand is not known. The reasons seems to be that GetProcessCommand is available in Micrososft.Powershell.Commands.Management, however the nutget Package has a "ref" dll (System.Management.Automation) that does not expose GetProcessCommand.
Is this an oversight or by design, maybe because Get-Process is not available on all platforms? Can we work around this problem by refering to Microsoft.Powershell.Commands.Managment assembly directly or are we going down a dangerous path? If this behaviour is intentional, is there a list on which cmdlets implementatios are platform dependant or not immediately available in the Powershell Core SDK?
We are currently not intending to target anything else but Windows.
Steps to reproduce
- Use https://github.com/PowerShell/PowerShell/tree/master/docs/host-powershell/sample-dotnet2.0-powershell.beta.3 as base
- Try to do
SessionStateCmdletEntry ssce1 = new SessionStateCmdletEntry(
"get-process",
typeof(GetProcessCommand),
null);
Expected behavior
compiles
Actual behavior
does not compile
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0```
Preface
Not sure if this is the right place or if my problem is an issue or by design. We are currently looking alternatives for a self developed scripting engine.
Our partners know Powershell, however one of our requirements is independence on any "installed" software, so Windows Powershell, even though it should be available on every Windows 7+, can not be considered.
We are looking at Powershell Core because as far as we understand we should be able to provide everything that is necessary to run a script by simple copy-deployement.
Furthermore, we want to have control over which Cmdlets can be executed ("sandboxing"), so we want to use runspaces and host the powershell scripts ourselves.
I was tryint to setup a simple powershell core host with a runspace using these two examples:
https://github.com/PowerShell/PowerShell/tree/master/docs/host-powershell/sample-dotnet2.0-powershell.beta.3
https://docs.microsoft.com/en-us/powershell/developer/hosting/creating-a-constrained-runspace
In the second link, a runspace is created and the "Get-Process" Cmdlet should be made available by using
However, when I use the first link as base, getting the powershell core sdk using nuget,
GetProcessCommandis not known. The reasons seems to be thatGetProcessCommandis available in Micrososft.Powershell.Commands.Management, however the nutget Package has a "ref" dll (System.Management.Automation) that does not exposeGetProcessCommand.Is this an oversight or by design, maybe because
Get-Processis not available on all platforms? Can we work around this problem by refering to Microsoft.Powershell.Commands.Managment assembly directly or are we going down a dangerous path? If this behaviour is intentional, is there a list on which cmdlets implementatios are platform dependant or not immediately available in the Powershell Core SDK?We are currently not intending to target anything else but Windows.
Steps to reproduce
Expected behavior
compiles
Actual behavior
does not compile