Re: DSQUERY an OU for Computers and then list what GPO “group” of the computers/servers

Home Forums Scripting General Scripting DSQUERY an OU for Computers and then list what GPO "group" of the computers/servers Re: DSQUERY an OU for Computers and then list what GPO “group” of the computers/servers


Rems
Moderator
#227908

Re: DSQUERY an OU for Computers and then list what GPO "group" of the computers/serve

StephenDoesIT;225481 wrote:
I get “ERROR: The RPC server is unavailable.

In order for this script to work I literally have to have logged on to each one of these servers at least once? That probably won’t work for my scenario there are going to be roughly 1000 or more – the need of the script was to find a quicker way of grabbing this info without having to touch each machine manually.

Any ideas?

thanks!

Try this batch

@echo off

>”[COLOR=”Blue”]Win2k3OU_.log[/COLOR]” 2>&1 call:main & goto:EOF

:main batch

set “strOU=[COLOR=”Blue”]OU=Win2k3,OU=A,OU=Servers,OU=Location A,DC=B,DC=my,DC=domainname,DC=net[/COLOR]”
For /f “delims=” %%* in (
‘DSQUERY COMPUTER “%strOU%” -o samid -limit 0’
) do call:machine %%~*

set “strOU=[COLOR=”Blue”]OU=Win2k3,OU=Servers,OU=Location Bl,DC=C,DC=my,DC=domainname,DC=net[/COLOR]”
For /f “delims=” %%* in (
‘DSQUERY COMPUTER “%strOU%” -o samid -limit 0’
) do call:machine %%~*

goto:EOF – – – Sub routines – – –
:machine
setlocal & Set CompNB=%*
Set CompNB=%CompNB:$=%
echo.
echo.———————————————————————–
echo.COMPUTER NAME: [%CompNB%]
echo.———————————————————————–
GPRESULT.exe /s %CompNB% /scope COMPUTER /R ||ping.exe %CompNB%
echo.
endlocal
exit /b 0
[/CODE]
On Error the remote machine is Ping’d, you see the results in the log.

“The RPC server is unavailable” Errors can occur when the machine can not be found by the provided name or, when the machine does not respond because a firewall is blocking the conversation.

Yes, the user must have a profile on the targed computer for GPResult to run.
You can specify a domainusername using the /USER switch of a user you know who had logged-on once to the computer.

Rems[CODE]
@echo off

>”Win2k3OU_.log” 2>&1 call:main & goto:EOF

:main batch

set “strOU=OU=Win2k3,OU=A,OU=Servers,OU=Location A,DC=B,DC=my,DC=domainname,DC=net
For /f “delims=” %%* in (
‘DSQUERY COMPUTER “%strOU%” -o samid -limit 0’
) do call:machine %%~*

set “strOU=OU=Win2k3,OU=Servers,OU=Location Bl,DC=C,DC=my,DC=domainname,DC=net
For /f “delims=” %%* in (
‘DSQUERY COMPUTER “%strOU%” -o samid -limit 0’
) do call:machine %%~*

goto:EOF – – – Sub routines – – –
:machine
setlocal & Set CompNB=%*
Set CompNB=%CompNB:$=%
echo.
echo.


echo.COMPUTER NAME: [%CompNB%]
echo.


GPRESULT.exe /s %CompNB% /scope COMPUTER /R ||ping.exe %CompNB%
echo.
endlocal
exit /b 0
[/CODE]
On Error the remote machine is Ping’d, you see the results in the log.

“The RPC server is unavailable” Errors can occur when the machine can not be found by the provided name or, when the machine does not respond because a firewall is blocking the conversation.

Yes, the user must have a profile on the targed computer for GPResult to run.
You can specify a domainusername using the /USER switch of a user you know who had logged-on once to the computer.

Rems