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

win_dsc: unable to invoke RemoteDesktopAdmin of ComputerManagementDsc #329

Closed
LordPhwa opened this issue Jan 11, 2022 · 4 comments
Closed

Comments

@LordPhwa
Copy link

SUMMARY

In my playbook, i would like to enable RDP for a windows 10 host.

The Resource RemoteDesktopAdmin is part of ComputerManagementDsc

While researching i stumbled upon #15 , maybe these are related?
While retracing i found that the exact error happens in Line 50 in the call
$resource = Get-CimClass -ClassName $ClassName -Namespace root\Microsoft\Windows\DesiredStateConfiguration
with $ClassName (if i am not mistaken) having the content DSC_RemoteDesktopAdmin.

I could reproduce the error message when manually issuing this command.

I also found #83 and my device is a german windows version, maybe that can have an impact as well.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_dsc module

ANSIBLE VERSION
ansible [core 2.12.1]
COLLECTION VERSION
Collection      Version
--------------- -------
ansible.windows 1.9.0
OS / ENVIRONMENT

Target Host is a Windows 10 Enterprise LSTC Host

STEPS TO REPRODUCE
- name: Check for ComputerManagementDsc Powershell module
   win_psmodule:
     name: ComputerManagementDsc
     state: present

- name: Enable Remote Desktop
  win_dsc:
    resource_name: RemoteDesktopAdmin
    Ensure: Present
    UserAuthentication: Secure
EXPECTED RESULTS

RDP is enabled

ACTUAL RESULTS
Nicht gefunden
In Zeile:50 Zeichen:17
+ ... $resource = Get-CimClass -ClassName $ClassName -Namespace root\Micros ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (root\Microsoft\...oteDesktopAdmin:String) [Get-CimClass], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041002,Microsoft.Management.Infrastructure.CimCmdlets.GetCimClassCommand

ScriptStackTrace:
bei Get-DscCimClassProperty, <Keine Datei>: Zeile 50
bei Get-OptionSpec, <Keine Datei>: Zeile 159
bei <ScriptBlock>, <Keine Datei>: Zeile 480
@jborean93
Copy link
Collaborator

I'm unsure if this is related to the linked problems, one was around failing to import the DSC module due to locale problems and the other is failing to serialize CimInstance properties. This error indicates the CIM class in RemoteDesktopAdmin was not available for some reason.

I'm not sure what this could be but I'll have to try and replicate it myself to try and figure out what's happening here.

@jborean93
Copy link
Collaborator

Sorry for the delay here, I'm unable to replicate the problem on a Server 2019 host.

TASK [Enable Remote Desktop] ********************************************************************************************
task path: /home/jborean/dev/ansible-tester/main.yml:9
redirecting (type: modules) ansible.builtin.win_dsc to ansible.windows.win_dsc
Using module file /home/jborean/dev/ansible_collections/ansible/windows/plugins/modules/win_dsc.ps1
Pipelining is enabled.
<server2019.domain.test> ESTABLISH PSRP CONNECTION FOR USER: [email protected] ON PORT 5985 TO server2019.domain.test
PSRP: EXEC (via pipeline wrapper)
ok: [2019] => changed=false
  invocation:
    module_args:
      DependsOn: null
      Ensure: Present
      IsSingleInstance: 'Yes'
      PsDscRunAsCredential_password: null
      PsDscRunAsCredential_username: null
      UserAuthentication: Secure
      module_version: latest
      resource_name: RemoteDesktopAdmin
  module_version: 8.5.0
  reboot_required: false
  verbose_test:
  - Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ResourceTest,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
  - An LCM method call arrived from computer SERVER2019 with user sid S-1-5-21-2608867424-1000906047-3513714156-1104.
  - '[SERVER2019]: LCM:  [ Start  Test     ]  [[RemoteDesktopAdmin]DirectResourceAccess]'
  - '[SERVER2019]:                            [[RemoteDesktopAdmin]DirectResourceAccess] Getting Remote Desktop Admin settings.'
  - '[SERVER2019]: LCM:  [ End    Test     ]  [[RemoteDesktopAdmin]DirectResourceAccess] True in 0.0470 seconds.'
  - '[SERVER2019]: LCM:  [ End    Set      ]    in  0.0940 seconds.'
  - Operation 'Invoke CimMethod' complete.
  - Time taken for configuration job to complete is 0.176 seconds
META: ran handlers
META: ran handlers

I had to add IsSingleInstance to the module options as it seems like the version I had installed required this to be set. Can you share what version of ComputerManagementDsc is installed at and if updating the module to the latest fixes the problem for you?

@jborean93
Copy link
Collaborator

Closing as per the above, if you can provide more information I'm happy to look into it again but I'm unable to replicate this myself.

@LordPhwa
Copy link
Author

Hello,

sorry for the delay, i had to tend to other things...

Get-DscResource on the host tells me it runs ComputerManagementDSC version 8.5.0, which seems to be the latest release according to github.

Output of Get-CimClass -Namespace root\Microsoft\Windows\DesiredStateConfiguration also does not provide any CimClasses named "DSC_*", Classnames containing DSC in this namespace are:

  • MSFT_DSCResource
  • MSFT_DSCConfigurationStatus
  • MSFT_DSCConfigurationOutputResult
  • MSFT_DSCConfigurationOutputWriteMessage
  • MSFT_DSCConfigurationOutputWriteArray
  • MSFT_DSCConfigurationOutputWriteProgress
  • MSFT_DSCMethodInvoked
  • MSFT_DSCMetaConfiguration

I also only encountered the issue on windows 10 hosts, maybe this is the reason you couldn't reproduce on windows server 2019.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants