Search code examples
command-lineactive-directorywindows-server-2003

Displays the date of account expiration - Windows Server 2003


I'm using following command:

dsquery user -limit 0 | dsget user -display  –samid –acctexpires –disabled 

But I get this message

Value for 'Target object for this command' has incorrect format

What is the correct syntax?


Solution

  • I ran into these issues all the time. It is because the people that are creating objects in AD do not follow what Microsoft considers as standards for naming objects and placing objects properly. What I typically have to do to get around this is to break it up into pieces and work on it iteratively. For example above I would create a text file of just the DSQuery command by doing this:

    DSQUERY user limit 0 > Results.txt
    

    Now that you have all the user objects in a text file you can run the above command using:

    Type Results.txt | Dsget user -display  –samid –acctexpires –disabled > NewList.txt
    

    By looking at the very bottom of Newlist.txt you can see that last "successful" record that was retrieved. Go back to the Results.txt file in Notepad and search for that record and look at the record below it. You will need to delete the record (or make a change in AD and start all over). If you delete the record just run the same DSGet command above and keep going until it runs all the way through with no errors.