Help with scripting a DSQuery request

Posted on 2011-10-03
Last Modified: 2012-08-14
I have the following DSQuery which outputs to a text file. I then have to pull that into a file editior and count the lines. I would like to convert this to a vbs file so I can run from a command line. The gotcha is that I am currently using findstr to filter out 'stuff'.

dsquery user dc=mydomain,DC=oc,DC=sample,DC=com -limit 0 |findstr /v /i "delete inactive SystemMailbox .adm Monitoring"|findstr /i /v "Org Accts"

Ideal output would be something like
Count: 1027
Question by:edrz01
    LVL 51

    Expert Comment

    by:Bill Prew
    Try this addition to your command.

    dsquery user dc=mydomain,DC=oc,DC=sample,DC=com -limit 0 |findstr /v /i "delete inactive SystemMailbox .adm Monitoring"|findstr /i /v "Org Accts"|find /c /v ""

    Open in new window


    Author Comment

    Solution provided was not helpful.
    LVL 51

    Accepted Solution


    ==> Solution provided was not helpful.

    Can you be more specific, that should have returned the count of the number of selected items, did you not get that?  Or did you get an error?


    Author Comment

    bp, sorry bout that and it did produce a number.

    What I was trying to accomplish was to convert this to a vbs file.

    I actually need to expand this but I will close this and reopen as another question......

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
    Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now