I'm trying to grab the output of a WMIC command to get the members of the local Administrators group on a remote system so I can check if a user's ID is present and also know if the command ran successfully at all as I get a lot of RPC errors on our network. The though is capture the output to a variable, then use FINDSTR to check for the user ID and also for "The RPC server is unavailable".
This is the command that I can run from the command prompt successfully.
When I wrap this in a FOR command, I get "No closing quote".
I'm sure it's something I'm doing wrong with the quotes\backticks but I just can't find a solution so I figured I would ask for help.
Thank you in advance.
This is the command that I can run from the command prompt successfully.
Code:
wmic /Node:"ComputerName" path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"Computername\"")
When I wrap this in a FOR command, I get "No closing quote".
Code:
FOR /F "tokens=* delims= usebackq" %%F IN (
`wmic /Node:"ComputerName" path win32_groupuser where (groupcomponent="win32_group.name=\"administrators\",domain=\"Computername\"")`
) DO set output=%%F
I'm sure it's something I'm doing wrong with the quotes\backticks but I just can't find a solution so I figured I would ask for help.
Thank you in advance.