Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Major Batch Issues

$
0
0

Hello All,

Previously, I had this .bat that ran perfectly and did everything I needed it to do. When I image a machine and join it to the domain with a random name, I then run the .bat you are about to see below and it does everything it's supposed to do. I decided to take a few lines out of the .bat today because I no longer need them (it was to delete local accounts that are no longer being created during the imaging process). After I did this is when I started running into issues (I don't think it's related at all, but this is when I started to have problems); I'm receiving an error code 1 and when I try to run the NETDOM portion of it, I'm getting an invalid switch error. ALL of this stuff has worked for me in the past, more than once. Here is the .bat below-- I spaced everything out and remarked what each command does; I don't have spaces or remark lines in the actual .bat that I run.

REM Migrate computer to the desired OU
FOR /F %%i IN (computerlist.txt) DO admod.exe -b cn=%%i,cn=computers,dc=euroinv,dc=com -move ou="toxic test - user",dc=euroinv,dc=com



REM Remote computer via Psexec
FOR /F %%i IN (computerlist.txt) DO PsExec \\%%i -s -i CMD /C (^

REM Copy files from the network down to the local computer's "c:\Windows\Temp" directory
xCOPY "\\euroinv.com\SYSVOL\euroinv.com\Scripts\DeploymentFiles" "c:\Windows\Temp\DeploymentFiles" /E /I /Y ^

REM Activate Microsoft Office
& CScript //b "C:\Program Files\Microsoft Office\Office14\ospp.vbs" /act ^

REM Force a Group Policy update
& GPUpdate /Force ^

REM Delete all local firewall rules
& netsh advfirewall firewall delete rule name="all" ^

REM Enable Wake-on-Lan BIOS setting
& "c:\Windows\Temp\DeploymentFiles\wol.exe" ^

REM Stop and start the Winrm service
& NET STOP "Winrm" ^& NET START "Winrm" ^
)



REM Rename computer and reboot
FOR /F %%i IN (computerlist.txt) DO (FOR /F "skip=2 tokens=2 delims=," %%A IN ('WMIC /NODE:%%i OS GET csname /FORMAT:csv') DO (SET "CNAME=%%A")) ^
& (FOR /F "skip=2 tokens=2 delims=," %%B IN ('WMIC /NODE:%CNAME% SYSTEMENCLOSURE GET serialnumber /FORMAT:csv') DO (SET "SERIAL=%%B")) ^
& NETDOM RENAMECOMPUTER %CNAME% /NewName:NYC-%SERIAL% /UserD:euroinv.com\parkerp /PasswordD:R00tR00t /Force /REBoot



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>