Batch file to use psgetsid.exe to check mulitple sids in a text file

Lauren Quattrocchi
Lauren Quattrocchi used Ask the Experts™
on
I had this question after viewing SID account to username.

I tried creating the batch file to run through a text file with SIDs in it. This is what i came up with

@echo off
>output.txt (
for /f %%i IN (unresolvedsids.txt) DO C:Desktop\psgetsid.exe %%i
)

When i run it, it creates an empty output file, this is my first attempt at a batch file so i'm not very sure how to troubleshoot what is happening behind the scenes when you click the .bat file
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AlexSenior Infrastructure Analyst

Commented:
If the unresolved SIDS aren't found, it won't give you an output in the first place. Do the accounts or groups even exist is more the question.

Author

Commented:
I'm running this to check if they exist so I don't know if they exist. When I run the command individually in cmd I get the message no mapping between account names and security IDs was done, I was expecting the output file to contain this message, I also have a sid in the text file that I know resolves, and it outputs the group when i run it individually but the output is still empty from the .bat file. Thanks
NVITEnd-user support

Commented:
This is tested and works...

@echo off
 
for /f %%i IN (unresolvedsids.txt) DO C:\Desktop\psgetsid.exe %%i >>output.txt

Open in new window


Also, just checking but... is that where psgetsid.exe is located, i.e. C:\Desktop?
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Author

Commented:
I tested and that way an output file is not create,d and yes it is located on the desktop specifically C:\users\[username]\desktop, which i have in my file path i just took it out  when i posted here for simplicity sake
NVITEnd-user support

Commented:
> ...an output file is not create,d

You are running this code via a .bat or .cmd file, right?

If so, probably don't have rights to write output.txt. Try writing to a different folder, e.g. >>%temp%\output.txt

Also, does this give the expected output?

@echo off
 
for /f %%i IN (unresolvedsids.txt) DO C:\Desktop\psgetsid.exe %%i

Open in new window


If so, then issue is writing output.txt as I mentioned.

Author

Commented:
the different file path did not make a difference. It creates the output file it is just empty.

For the expected output; how do i see the ouput of it if it is not writing anywhere?
NVITEnd-user support

Commented:
> ... how do i see the ouput

1. Open a CMD window where the
bat/.cmd is located

2. Type the name of the .bat/.cmd file.

Author

Commented:
There is no output when i run it that way

It is working on my computer, however it is not working in the VM environment i need to run it in, i'm thinking it might be an access issue

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial