none
Script to check Trust relationship for all PC's in domain RRS feed

  • Question

  • There is a command to check whether Trust relationship with Active Directory is fine for a machine:

    C:\>nltest /server:Computer1 /sc_query:contoso

    If trust relationship exists the output is:

    Flags: 30 HAS_IP  HAS_TIMESERV 
    Trusted DC Name \\DC.Contoso.com 
    Trusted DC Connection Status Status = 0 0x0 NERR_Success
    The command completed successfully

    If Trust relationship error exists:   I_NetLogonControl failed: Status = 5 0x5 ERROR_ACCESS_DENIED

    The Output does not mention the machine name for which the result is generated.

    Here Computer1 is the computer name. I have a csv with all the computer names.

    I don't know scripting that well.

    How do I modify the above mentioned script so that Computer name can be fetched from CSV file and the error output to a csv or text file along with appending computer name.

    • Moved by Bill_Stewart Monday, June 6, 2016 7:23 PM This is not "scripts on demand"
    Monday, April 11, 2016 12:12 PM

All replies

  • You will have to hire someone to write a script that parses the text and converts it into the output you seek.  We cannot do that for you.


    \_(ツ)_/

    Monday, April 11, 2016 12:41 PM
  • HINT:

    Parse output:

    $results=nltest /server:Computer1 /sc_query:contoso
    $status=if($results|select-string 'NERR_Success'){$true}
    [pscustomobject]@{Computer=$computer;Status=$status} | Export-Csv file.csv -append

    \_(ツ)_/


    • Edited by jrv Monday, April 11, 2016 12:47 PM
    Monday, April 11, 2016 12:47 PM