The Wayback Machine - https://web.archive.org/web/20200905184941/https://github.com/PowerShell/WindowsCompatibility/issues/37
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with DnsServer module and CimSession (de)serialization #37

Open
rmbolger opened this issue Jun 12, 2018 · 2 comments
Open

Problem with DnsServer module and CimSession (de)serialization #37

rmbolger opened this issue Jun 12, 2018 · 2 comments

Comments

@rmbolger
Copy link

@rmbolger rmbolger commented Jun 12, 2018

First off, thank you all for trying to solve this usability gap while we wait for all of the Win modules we depend on to get ported to Core. Fantastic effort!

I have a module that has a plugin system for interacting with various DNS servers/services. The Windows DNS plugin relies on the DnsServer module that doesn't have a Core compatible version yet. So I figured I'd try to add support for it on Core via this lovely module.

I've got WindowsCompatibility installed and functional which is to say I can run Import-WinModule DnsServer successfully. But I'm running into problems with DnsServer's dependence on CimSession objects.

The plugin code appears to create a New-CimSession against the DNS server successfully. But when I try to run a function and reference the CimSession object, I get the following error.

Cannot process argument transformation on parameter 'CimSession'. Cannot convert the "CimSession: ns.example.com" value of type "Deserialized.Microsoft.Management.Infrastructure.CimSession" to type "Microsoft.Management.Infrastructure.CimSession[]".
At C:\Users\myuser\AppData\Local\Temp\remoteIpMoProxy_DnsServer_2.0.0.0_localhost_754d59ca-b5e1-4372-ba73-762704d969b8\remoteIpMoProxy_DnsServer_2.0.0.0_localhost_754d59ca-b5e1-4372-ba73-762704d969b8.psm1:7297 char:9
+         $steppablePipeline.End()
+         ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Get-DnsServerZone], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DnsServerZone
+ PSComputerName        : localhost

At first, I thought this might be because Core has its own version of CimCmdlets and sending the locally created CimSession object through the implicit remoting connection was screwing things up. So I tried explicitly loading the Windows CimCmdlets module via Import-WinModule as well. But that ended up with a different error when calling New-CimSession.

Cannot bind parameter 'SessionOption'. Cannot convert value "Microsoft.Management.Infrastructure.Options.WSManSessionOptions" to type "Microsoft.Management.Infrastructure.Options.CimSessionOptions". Error: "Cannot convert the "Microsoft.Management.Infrastructure.Options.WSManSessionOptions" value of type "Deserialized.Microsoft.Management.Infrastructure.Options.WSManSessionOptions" to type "Microsoft.Management.Infrastructure.Options.CimSessionOptions"."
+ CategoryInfo          : InvalidArgument: (:) [New-CimSession], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Management.Infrastructure.CimCmdlets.NewCimSessionCommand
+ PSComputerName        : localhost

I'm running this all from Win 10 1803. Here's the output of my Win PS and PS Core $PSVersionTable variables.

Name                           Value
----                           -----
PSVersion                      5.1.17134.48
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.48
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Name                           Value
----                           -----
PSVersion                      6.0.0
PSEdition                      Core
GitCommitId                    v6.0.0
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@markekraus
Copy link
Collaborator

@markekraus markekraus commented Jun 20, 2018

Hi @rmbolger Do you have some code we can use to reproduce the problem?

@rmbolger
Copy link
Author

@rmbolger rmbolger commented Jun 20, 2018

I just pushed my WIP branch of the module up to Github here. You should be able to just dot source the Windows.ps1 plugin file directly rather than futzing with the rest of the module. I can also try putting together a smaller repro if you'd like.

Here's an example command that works for me from Windows PS, but gets the serialization error from PS Core (since upgraded to 6.0.2). The DNS server in this case is remote and standalone, but using a valid cert for WinRM. Explicit credentials and -WinUseSSL may not be necessary if client and server are in the same AD domain.

Add-DnsTxtWindows 'test.example.com' 'myvalue' 'dns-server.example.com' (Get-Credential) -WinUseSSL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.