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/OS/Microsoft_Operating_Systems/Q_25218688.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:
$Credential = Get-Credential (I type in the credentials it asks me for)
$credential.Password | ConvertFrom-SecureString | Set-Content c:\windows\system32\window
$password = Get-Content c:\windows\system32\window
t | ConvertTo-SecureString
$credential = New-Object System.Management.Automati
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???