Reputation: 133
I'm trying to write a batch file to make the output of net user /domain more usable as the guys who need to user it where I work aren't familiar with CLI interfaces.
Currently It's fairly basic:
@echo off
set /p id="Enter the ID of user: " %=%
net user %id% /domain
pause
I was wondering if there was a way to display only specific parts of the output?
I only want it to output the account active, expires and password last set, expires.
I haven't spent much time scripting so my knowledge is small and limited to python but have been told that for work I cannot install python to create scripts so trying to get used to widows batching.
Any help would be great or if anyone knows good knowledge bases on the subject of windows batch as most sites I have found have just been extracts of man pages.
Upvotes: 0
Views: 423
Reputation: 29450
One options is to dump the results in a temporary file and then use the find
command to echo what you want:
@echo off
set /p id="Enter the ID of user: " %=%
net user %id% /domain > usertmp.txt
type usertmp.txt | find "Account active"
type usertmp.txt | find "Account expires"
type usertmp.txt | find "Password last set"
type usertmp.txt | find "Password expires"
del usertmp.txt
pause
Upvotes: 1