Hello Experts,
Need some help. I'm building a Windows 7 image and need to run a Powershell script to automatically join the domain. I first wanted to store the credential password to join the domain (see CTcharger's comments at
https://www.experts-exchange.com/questions/25218688/how-to-add-windows-7-computer-to-domain-using-comand-line-Powershell.html?sfQueryTermInfo=1+10+30+7+domain+join+powershel+window). But when trying to actually join the computer to the domain I get as error that states "The format of the specified domain name is invalid". Here are the steps I've taken in powershell:
#Set-myCredential.ps1
$Credential = Get-Credential (I type in the credentials it asks me for)
$credential.Password | ConvertFrom-SecureString | Set-Content c:\windows\system32\window
spowershel
l\v1.0\pas
sword.txt
#Get-myCredential.ps1
$password = Get-Content c:\windows\system32\window
spowershel
l\v1.0\scr
iptpass.tx
t | ConvertTo-SecureString
$credential = New-Object System.Management.Automati
on.PsCrede
ntial "CachedUser",$password
After that I try to join it to the domain by typing in:
add-computer -domainname af.org -credential $credential -passthru
And that's when I get this error:
Add-Computer : This command cannot be executed on target computer ('ComputerName') due to the following error: The format of the specified domain name in invalid.
At line:1 char:13
If I type in the add-computer command manually putting in the credentials, it will join. But cannot do it with the stored passwords. What's up with that???
“Correct” way to programatically join a Windows 7 machine to the domain
http://serverfault.com/questions/154397/correct-way-to-programatically-join-a-windows-7-machine-to-the-domain