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


i need join customer's domain our computers.  won't know domain name or domain controller name the user credentials until arrive on-site.

in powershell script have:

cmd /c set/p fqdn=type domain name @ prompt:

cmd /c set/p dcname=type qualified domain controller name:

add-computer -domainname %fqdn% -cred %dcname%\joe -passthru

i not passing variable input set/p.

the error specified domain either not exist or not contacted.  -domain %fqdn% -cred %dcname%\joe -passthru.

i've been searching , have found ways hard code input , works fine.   problem change on daily basis have variable technician can input on fly.

thank time.


bo

import-module activedirectory $fqdn = read-host "type domain name: " $dcname = read-host "type qualified domain controller name: " add-computer -domainname $fqdn -cred "$dcname\joe" -passthru
issue mixing powershell , batch file commands, try above script run in powershell

if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful.




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

directory stack

PowerShell List

Dns access list