Okay here's another one.
So the idea for this batch uses two loops, but I feel like I lack the proper knowledge but here we go:
Batch code: (Please be advised, that when user's are assigned computers, they are assigned by the description. Not my choice but anyway, it searches for computers owned by the description.)
@echo off
echo First and Last Name of User:
echo.
set /p name=
set desc="assigned to %name%"
echo.
dsquery computer domainroot -desc %desc%*
for /f "delims=," %%a in ('dsquery computer domainroot -desc %desc%*' ) do set CompName=%%a123
set CompName=%CompName:~4,-3%
pause
for /f "delims=" %u in ('wmic /node:%CompName% COMPUTERSYSTEM GET USERNAME^|find "\"') do set userfound=%~nxu
pause
The batch seems to break at the second loop. I feel as though maybe because the first loop that is assigned a variable, it won't allow for a second for /f command to run properly.
Any suggestions?