So basically, all I want to do is execute an “sc” command on 100 servers whose names are mentioned in a text file “server.txt”. I tried the following and it doesnt work as it returns empty notepad file.
for /f %%a in (servers.txt) do sc \\server_name query | find "SERVICE_NAME">>servicecontroller.txt
I tried the above command locally and it worked just fine. I know the issue is in the “\server_name”. Not sure what about it is wrong. Do i need to use the hidden shares?
Like this maybe?
\\server_name\c$ /user:domain\username password
Or like this?
\\server_name\c$
If you’ve hardcoded
\\server_namethere rather than%%a, then that’s your problem. Try this instead:EDIT :
The following line helps in getting admin access consistently on all the servers. This is the line I(OP) was looking for.