# ChefDK PowerShell DSC xComputerManager and ps\_credential

**URL:** <https://discourse.chef.io/t/chefdk-powershell-dsc-xcomputermanager-and-ps-credential/9567>\
**Category:** Chef Infra (archive)\
**Created:** [October 3, 2016, 7:34am UTC](https://discourse.chef.io/t/chefdk-powershell-dsc-xcomputermanager-and-ps-credential/9567 "2016-10-03T07:34:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![timhaintz](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@timhaintz](https://discourse.chef.io/u/timhaintz)\
**Post date:** [October 3, 2016, 7:34am UTC](https://discourse.chef.io/t/chefdk-powershell-dsc-xcomputermanager-and-ps-credential/9567/1 "2016-10-03T07:34:05Z")

</div>

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](https://www.powershellgallery.com/packages/xComputerManagement/1.8.0.0) and  
[https://github.com/PowerShell/xComputerManagement](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](http://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](http://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.
