I'm trying to create a script to completely automate joining the domain to use during a wds image deployment. I don't want to use the WAIK option because the password is stored in plain text in the xml file. So I've found some powershell scripts online that look like they could work.
This is the command I used to create my encrypted file which contains the password.
read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt
Here's the script I'm using.
$domain = "MYDOMAIN.COM" $password = cat C:\securestring.txt | ConvertTo-SecureString -Force $username = "$domain\MYUSERNAME" $credential = New-Object System.Management.Automation.PSCredential($username,$password) Add-Computer -DomainName $domain -Credential $credential
Here's the error I'm getting.
C:\>powershell Windows PowerShell Copyright (C) 2009 Microsoft Corporation. All rights reserved. PS C:\> $domain = "MYDOMAIN.COM" PS C:\> $password = cat C:\securestring.txt | ConvertTo-Secure String -Force ConvertTo-SecureString : Cannot process argument because the value of argument "input" is invalid. Change the value of the "input" argument and run the operat ion again. At line:1 char:66 + $password = cat C:\securestring.txt | ConvertTo-SecureString <<<< -Force + CategoryInfo : InvalidArgument: (:) [ConvertTo-SecureString], P SArgumentException + FullyQualifiedErrorId : ImportSecureString_InvalidArgument,Microsoft.Pow erShell.Commands.ConvertToSecureStringCommand