I'm working on a Windows 7 image that will join the computer to the domain automatically. I'm trying to accomplish this through a Powershell script. While logged in as Administrator, I set the execution policy to remotesigned. Then I use Get-Credential to Store Passwords “securely” in a file (see http://bsonposh.com/archives/338
). I create a script with the following commands:
$password = Get-Content c:\windows\system32\window
sword.txt | ConvertTo-SecureString
$credential = New-Object System.Management.Automati
add-computer -domainname Domain -credential $credential af.org -passthru
I save the script in c:\windows\system32\window
l\v1.0\ and I place the run script command in the Administrator's runonce registry entry.
1. It appears that Powershell reverts back to "Restricted" mode after running sysprep thereby not allowing scripts to run automatically.
2. It seems that the Administrator account seems to change because I get an error when trying to access the encrypted password file. I have to start running the Powershell cmdlets from scratch in order for it to work which defeats the automated process, but does join the domain.
I should note that my unattend.xml file changes the Administrator password. (Don't know if that has anything to do with it).