ChefDK PowerShell DSC xComputerManager and ps_credential


#1

Sorry for the questions, hopefully be able to start helping out and answering some soon.

I’m using the PowerShell DSC resource xComputerManagement
https://www.powershellgallery.com/packages/xComputerManagement/1.8.0.0 and
https://github.com/PowerShell/xComputerManagement

When I pass my credentials using ps_credential, the conversion of my password ‘vagrant’ to a secure string appears to be changing the password and is not able to be used.

Please see below code and errors.

This is working correctly.
powershell_script ‘Install-Module xComputerManagement’ do
code 'install-module xComputerManagement -Force’
guard_interpreter :powershell_script
not_if '((get-package -Name xComputerManagement).name -eq “xComputerManagement”)'
end

Below ps_credential isn’t being passed correctly.
dsc_resource ‘joindomain’ do
resource :xComputer
property :Name, node[‘hostname’]
property :DomainName, 'contoso.com
property :JoinOU, 'OU=Exchange,OU=Servers,DC=Contoso,DC=Com’
property :Credential, ps_credential(‘vagrant’, ‘vagrant’)
end

Kitchen converge output below.

       Resource Declaration:
       ---------------------
        In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/av-windows-exchange20

16-server/recipes/joindomain.rb

        26: dsc_resource 'joindomain' do
        27:   resource :xComputer
        28:   property :Name, node['hostname']
        29:   property :DomainName, 'contoso.com'
        30:   property :JoinOU, 'OU=Exchange,OU=Servers,DC=Contoso,DC=Com'
        31:   property :Credential, ps_credential('vagrant', 'vagrant')
        32: end
        33: 
   
       Compiled Resource:
       ------------------
        Declared in C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/av-windows-e

xchange2016-server/recipes/joindomain.rb:26:in `from_file’

       dsc_resource("joindomain") do
         action [:run]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         properties {Name=>"exhc1", DomainName=>"contoso.com", JoinOU=>"OU=Exchange,OU=Server

s,DC=Contoso,DC=Com", Credential=>New-Object System.Management.Automation.PSCredential(‘vagrant’,
(‘01000000d08c9ddf0115d1118c7a00c04fc297eb01000000dcc42fe35496f94f8fde948df49a5180040000000200000
00000106600000001000020000000e54453335aed331329412cc4f9edfd6578157fd455685f6bc4ee9fd040db0d980000
00000e8000000002000020000000b85e6b04551d1c848227a0bf25ed7af4ef88001c049d9fd26fb2165e504468d320000
0009ef22c99d8f1b546c5cbb04ec0311ae120faa8b4ae1c7448e2c4b45c047fe7e740000000d07a182ca17dc646d3bf1b
15c496522a72690be191096baa1cf4342dbf300f903f67d21b614f6531e0d77cf608bb4c760dea0ee66ce54224ff9ffb7
62c332412’ | ConvertTo-SecureString))}
resource :xComputer
reboot_action :nothing
declared_type :dsc_resource
cookbook_name "av-windows-exchange2016-server"
recipe_name "joindomain"
end

Powershell Cmdlet failed: Invoke-DscResource : Computer ‘exhc1’ failed to join domain ‘contoso.com’ from its current workgroup ‘WORKGROUP’ with following error message: Unable to update the password. The value provided as the current password is incorrect.

Is anyone else having this error with ps_credential when passing username and password.

Sorry for the formatting errors.

Thanks, Tim.