Pull data from text file into PS Script.


  • I am an extreme novice at PS scripting and was wondering how I would pull data from each line of a TXT (or CSV) and plug it into my script.  Below is my current script and what I want is to be able to use each line from a txt file or csv in the $client variable. There are 300+ "Client" names.

    $client = "Client1"
    $Environment = "-testenv"

    $targetDNS = "bigtime$Environment"        
    $newClient = "$client-testenv"

    Add-DnsRecord -Session $session -HostHeaderName $newClient -TargetHost $targetDNS

    I believe I have to use something like:

    Get-Content C:\PATH\ClientNames.txt | ForEach...............

    Tuesday, March 21, 2017 1:23 AM

All replies

  • Start by learning to use PowerShell "help"

    Type "help help" and read the instructions.  After  that get help on the CmdLet and look at the examples;


    Tuesday, March 21, 2017 2:23 AM