I want to use validate set against the domain. RRS feed

  • Question

  • Hi People,

    I am currently using a basic validateset within a script. It validates against the host names below as an example. However, I want it to use the most up to date list of servers from our domain. Is there a way I can rewrite it to tab to the servers without the use of a TXT, CSV file or as below manually typing out the servers.

    Currently it is;

        [ValidateSet('DC1STG01', 'DC1STG02', 'DC1STG03', 'DC1STG04', 'DC1STG05')]

    Once the user runs the function and tab completes to the server required it is then passed into the $computername variable and then used with a new-pssession where my script is run. The environment is much larger than 5 servers. I have omitted them for the sake of company privacy.

    I was thinking to use some sort of test-connection against a wild card such as DC1* which will blanket it all the host names in the environment and then outputs the host names to a variable that is used as an array. If the answer to this is obvious I am quiet the noob. So all help would be appreciated.

    If you need me to elaborate further just let me know.

    Thanks in advance,

    • Moved by Bill_Stewart Tuesday, November 7, 2017 9:45 PM Unanswerable drive-by question
    Friday, September 15, 2017 3:27 PM

All replies