Hi
I’m doing a simple batch file to check GPResults for a policy being applied to the computer account. It just checks the results and if it finds the policy it updates a local file and if it doesn’t it updates another file.
@echo off
gpresult /s %1 /z /user domain.account /SCOPE Computer|find “Policy I’m Looking For” >NUL
IF NOT ERRORLEVEL 1 echo %1 %ERRORLEVEL% >> c:tempBtGApplied.txt
IF ERRORLEVEL 1 echo %1 %ERRORLEVEL% >> c:tempBtGMissing.txt
So this is saved as BTG.bat and I call it as a local process using BTG.bat $computer and it works up to a point due to the way GPResults works.
Even though I’m using /SCOPE /COMPUTER I have to use a domain.user account. I’m using an account that I know is on about 95% of the laptops but this obviously leads to face positives because the RSOP failure is flagged as not finding the policy.
So..here’s the question!
When I import the Assets, I also imported the username that’s allocated to the laptop. Can I user this detail and if so how can I call it up for the batch file in the same way that host is assigned $computer. So if the user is stored as $user I can call the batch using BTG.bat $computer $user and the script is gpresult /s %1 /z /user %2 /SCOPE Computer|find “Policy I’m Looking For” >NUL
Sorry for the waffle but hope that makes sense.
Thanks