title: Read entries from text file into a variable in PowerShell
body: <p>I hope someone can help me.  I am pretty new to PowerShell and can't really script it myself with the exception of looking at existing code and modifying it.</p>
  
  <p>I have found a PowerShell script that reports file share permissions for a specific share and recurses through the subfolders returning their permissions as well.</p>
  
  <p>My problem is I need to do this with a lot of shares so would like to be able to provide the script with a text file containing the share names.  I know I need to do a for each loop and read the names of the shares in a text file into an array but I don't know how to do this.  I guess it's pretty simple for someone with more experience.</p>
  
  <p>This is the script i have used with single entry.</p>
  
  <p><a href="http://mywinsysadm.wordpress.com/2011/08/17/powershell-reporting-ntfs-permissions-of-windows-file-shares/" rel="nofollow">http://mywinsysadm.wordpress.com/2011/08/17/powershell-reporting-ntfs-permissions-of-windows-file-shares/</a></p>
  
  <pre><code>#Set variables
  $path = Read-Host "Enter the path you wish to check"
  $filename = Read-Host "Enter Output File Name"
  $date = Get-Date
  
  #Place Headers on out-put file
  $list = "Permissions for directories in: $Path"
  $list | format-table | Out-File "C:\scripts\$filename"
  $datelist = "Report Run Time: $date"
  $datelist | format-table | Out-File -append "C:\scripts\$filename"
  $spacelist = " "
  $spacelist | format-table | Out-File -append "C:\scripts\$filename"
  
  #Populate Folders &amp; Files Array
  [Array] $files = Get-ChildItem -path $path -force -recurse
  
  #Process data in array
  ForEach ($file in [Array] $files)
  {
  #Convert Powershell Provider Folder Path to standard folder path
  $PSPath = (Convert-Path $file.pspath)
  $list = ("Path: $PSPath")
  $list | format-table | Out-File -append "C:\scripts\$filename"
  
  Get-Acl -path $PSPath | Format-List -property AccessToString | Out-File -append "C:\scripts\$filename"
  
  } #end ForEach
  </code></pre>
  
  <p>Sorry for the noob question.  I plan to learn more when I have a bit more time but any help now would be massively appreciated.</p>
  
  <p>Thanks in advance.</p>