Quantcast
Viewing all articles
Browse latest Browse all 21975

How do I pass a Set/p variable from a .cmd file to Powershell Command?

I need to join a customer's domain with our computers.  We won't know the domain name or the domain controller name for the user credentials until we arrive on-site.

In my Powershell script I have:

cmd /c set/p FQDN=Type your domain name at the prompt:

cmd /c set/p DCName=Type the Fully Qualified Domain Controller Name:

add-computer -domainname %FQDN% -cred %DCName%\joe -passthru

I am not passing the variable input for set/p.

The error is the specified domain either does not exist or could not be contacted.  -domain %FQDN% -cred %DCName%\Joe -passthru.

I've been searching and have found ways to hard code the input and it works fine.   The problem is that it will change on a daily basis so I would like to have it as a variable so the technician can input on the fly.

Thank you for your time.


Bo


Viewing all articles
Browse latest Browse all 21975

Trending Articles