Repository navigation
Closed
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
This issue is mostly due to the fact that windows desktop has powershell workflow remote endpoint PSSessionConfiguration by default. PowerShell workflow is not supported in PS Core, and thus processing the workflow endpoint causes this issue.
This issue is related to #1798, and they may have the same root cause.
Steps to reproduce
$sessionConfigurationDll = [IO.Path]::Combine([IO.Path]::GetTempPath(), "ImplicitRemotingRestrictedConfiguration$(Get-Random).dll")
Add-Type -OutputAssembly $sessionConfigurationDll -TypeDefinition @"
using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Remoting;
namespace MySessionConfiguration
{
public class MySessionConfiguration : PSSessionConfiguration
{
public override InitialSessionState GetInitialSessionState(PSSenderInfo senderInfo)
{
//System.Diagnostics.Debugger.Launch();
//System.Diagnostics.Debugger.Break();
InitialSessionState iss = InitialSessionState.CreateRestricted(System.Management.Automation.SessionCapabilities.RemoteServer);
// add Out-String for testing stuff
iss.Commands["Out-String"][0].Visibility = SessionStateEntryVisibility.Public;
// remove all commands that are not public
List<string> commandsToRemove = new List<string>();
foreach (SessionStateCommandEntry entry in iss.Commands)
{
List<SessionStateCommandEntry> sameNameEntries = new List<SessionStateCommandEntry>(iss.Commands[entry.Name]);
if (!sameNameEntries.Exists(delegate(SessionStateCommandEntry e) { return e.Visibility == SessionStateEntryVisibility.Public; }))
{
commandsToRemove.Add(entry.Name);
}
}
foreach (string commandToRemove in commandsToRemove)
{
iss.Commands.Remove(commandToRemove, null /* all types */);
}
return iss;
}
}
}
"@
Get-PSSessionConfiguration ImplicitRemotingRestrictedConfiguration* | Unregister-PSSessionConfiguration -Force
$myConfiguration = Register-PSSessionConfiguration `
-Name ImplicitRemotingRestrictedConfiguration `
-ApplicationBase (Split-Path $sessionConfigurationDll) `
-AssemblyName (Split-Path $sessionConfigurationDll -Leaf) `
-ConfigurationTypeName "MySessionConfiguration.MySessionConfiguration" `
-ForceExpected behavior
Register-PSSessionConfiguration runs successfully
Actual behavior
Exception calling "Load" with "1" argument(s): "Could not load file or assembly
'Microsoft.Powershell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The
system cannot find the file specified."
At line:33 char:9
+ $serviceCore = [Reflection.Assembly]::Load("Microsoft.Powersh ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
Environment data
> $PSVersionTable
PS C:\> $PSVersionTable
Name Value
---- -----
GitCommitId v6.0.0-alpha.11-51-ga0dbd11bc2fdd5f4b090b534043f582325535b2a-dirty
PSVersion 6.0.0-alpha
CLRVersion
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.3
BuildVersion 3.0.0.0
WSManStackVersion 3.0Metadata
Metadata
Assignees
Labels
Resolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Activity
daxian-dbw commentedon Oct 29, 2016
The implicit remoting tests "Implicit remoting on restricted ISS" are skipped due to this bug. So for whoever works on this bug, please update the tests accordingly when you resolve this bug.
[-]Register-PSSessionConfiguration throws error when running in PS Core on windows desktop[/-][+]Register-PSSessionConfiguration throws error when running in PS Core on Windows desktop[/+]joeyaiello commentedon May 22, 2017
Per conversation with Hemant Mahawar (@HemantMahawar) and Steve Lee (@SteveL-MSFT), anyone using
GetInitialSessionStateto create restricted endpoints is broken (including Exchange). Leaving in 6.0.0 for now (especially if we decide to shipGetInitialSessionStatein "PowerShell Standard" /cc Jason Shirk (@lzybkr)).joeyaiello commentedon Sep 19, 2017
This doesn't repro anymore in Beta.7 (possibly earlier):