diff options
-rw-r--r-- | cspell.json | 1 | ||||
-rw-r--r-- | lib/chef/resource/hostname.rb | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/cspell.json b/cspell.json index 35f0bd8f24..6fc8582b78 100644 --- a/cspell.json +++ b/cspell.json @@ -1147,6 +1147,7 @@ "Parallelizer", "PARAMCHANGE", "parms", + "PartofDomain", "passstr", "passw", "passwordage", diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index ee5cdd97eb..dfa17e94b6 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -278,8 +278,16 @@ class Chef Rename-Computer -NewName #{new_resource.hostname} } else { - $user = #{new_resource.domain_user} - $secure_password = #{new_resource.domain_password} | Convertto-SecureString -AsPlainText -Force + $temp_user = #{new_resource.domain_user} + $temp_password = #{new_resource.domain_password} + if ([string]::IsNullOrEmpty($temp_user)){ + $temp_user = "Chef" + } + if ([string]::IsNullOrEmpty($temp_password)){ + $temp_user = "P@ssw0rd" + } + $user = $temp_user + $secure_password = $temp_password | Convertto-SecureString -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential -Argumentlist ($user, $secure_password) Rename-Computer -NewName #{new_resource.hostname} -DomainCredential $Credentials } |