From the course: PowerShell: Scripting for Server Administration

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Read from text files

Read from text files - Server Tutorial

From the course: PowerShell: Scripting for Server Administration

Start my 1-month free trial

Read from text files

- [Narrator] A task that we will be completing as this course progresses, is the export of all users from one Active Directory domain to a series of files. The final task will then be to use those text-based files to create the same list of users in a different domain. To import this information, we need to be able to read the text files. And the commandlet for that is Get-Content. It may be easiest to see how this commandlet works by placing it in a pipeline. Add-Content or Set-Content usually goes at the end of a pipeline because they write data that's already been processed. It makes sense then that Get-Content would be at the beginning of the pipeline so that it can retrieve data that's about to be processed. The Get-Content commandlet will open a file and view each line as a string to be processed. This makes it important that we know what to expect on each line in the file. Here's a text file that has a list of local user accounts that we'd like to create on this machine. Notice…

Contents