I have the following script:
Add-Computer -DomainName ("a.b.c.d") -Credential (New-Object System.Management.Automation.PsCredential("a.b.c.d\abcdadmin", (ConvertTo-SecureString "1234qwer" -AsPlainText -Force)))
Obviously the domain is not 'a.b.c.d' but it follows that. It has no special characters or anything that would lead me to believe it would cause problems. From the ISE the output:
Add-Computer : Cannot add computer '<removed>' to domain 'a.b.c.d' because it is already in
that domain.
At line:1 char:1
+ Add-Computer -DomainName ("a.b.c.d") -Credential (New-Object System. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (20012UA95009JZ:String) [Add-Computer], InvalidOperationExce
ption
+ FullyQualifiedErrorId : AddComputerToSameDomain,Microsoft.PowerShell.Commands.AddComputerCommand
So it clearly runs fine in the ISE (with the exception that it's already in the domain), but the Command Prompt says otherwise:
At line:1 char:143
+ ... fl.us\abcdadmin, (ConvertTo-SecureString 1234qwer -AsPlainText -Force)))
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingArgument
The biggest limitation is that the script must be one-line.