1
我在具有两个域的环境中工作。实验室域(脱机)和生产域(在线)。实验室网络位于非军事区,并已纳入生产领域。两个域之间没有AD信任。批处理文件在不信任域的情况下添加打印机
我在实验室域上管理的打印机可以从生产域访问。我希望生产域中的用户能够运行批处理文件以将这些打印机添加到生产计算机上(由于各种原因,我无法使用GPO进行部署)。
我所知道的使用命令行添加打印机的方法有两种:
START \\printserver\printer
这些方法
&
RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n\\printserver\printer
两个认证的实验室域后工作。我想要做的是在批处理文件的上下文中传递证书并进行身份验证,而不是Windows提示用户。我想这样做是为了避免用户在跨域(productionDomain \ user/labDomain \ user)进行身份验证时遇到困惑。 Runas不起作用,因为生产域不知道实验室域凭据。
我想要做的事,如:
@echo off
set loc=\\printserverip\
set p1=printername1
set p2=printername2
set p3=printername3
set p4=printername4
set /P id=Enter LABDOMAIN Login: %=%
powershell -Command $pw = read-host "Enter LABDOMAIN password" -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pw) ; [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) > .tmp.txt & set /p pwd=<.tmp.txt & del .tmp.txt
REM ---AUTHENTICATE OR RUN THE FOLLOWING IN THE CONTEXT OF THE CREDENTIALS ABOVE---
START %loc%%p1%
START %loc%%p2%
START %loc%%p3%
START %loc%%p4%
REM ---OR---
RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n%loc%%p1%
RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n%loc%%p2%
RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n%loc%%p3%
RUNDLL32 PRINTUI.DLL,PrintUIEntry /in /n%loc%%p4%
我最终使匿名打印来解决我的问题,但这个解决方案的工作原理。 – Jaxaeon