PowerTip: Use PowerShell to return first two lines of file

Summary: Learn how to use Windows PowerShell to return the first two lines of a text file.  How can I use Windows PowerShell to easily return the first two lines of a text file?  Use the Get-Content cmdlet and specify the TotalCount parameter. In this example, TotalCount is set           to 2 and the file is named AMoreComplete.txt:…


Weekend Scripter: Two Way-Cool PowerShell Text File Tricks: Tail and Wait

Summary: Microsoft Scripting Guy, Ed Wilson, talks about two way-cool new Windows PowerShell parameters: Tail and Wait. Microsoft Scripting Guy, Ed Wilson, is here. Some things in Windows PowerShell are just so cool that I get all carried away with them and lose focus on whatever I am supposed to be doing. It happens that…


Weekend Scripter: Creating a Sample Log File by Using PowerShell

Summary: Microsoft Scripting Guy, Ed Wilson, shows how to create sample textual log output by using Windows PowerShell. Microsoft Scripting Guy, Ed Wilson, is here. Well, it is the weekend. It seems like it has been a rather long week, but I guess in reality it was no longer than any other week. I did…


Scripting Wife Learns to Work with Text Files

Summary: The Scripting Wife learns to use Windows PowerShell to write to text files and to include the date in a log. Microsoft Scripting Guy, Ed Wilson, is here. The other night the Scripting Wife and I went to the Charlotte IT Pro User Group meeting where I participated in a panel discussion about various…


Search for and Replace Words in a CSV File by Using PowerShell

Summary: Learn how to search for and replace words in a CSV file by using Windows PowerShell.   Hey, Scripting Guy! I have a comma-separated value (CSV) file that contains user names, user groups, and organizational unit (OU) assignments. The problem is that we are moving one of our office locations, and I need to…


Use PowerShell to Open Files That Contain Matching Words

Summary: Learn how to use Windows PowerShell to search a folder for matching strings and to open them automatically in Notepad.   Hey, Scripting Guy! I have been enjoying using the Select-String cmdlet, but I have a question. When I use Select-String, it lists the file that it finds the match in, but I have…


Use an Easy PowerShell Command to Search Files for Information

Summary: Learn how to use a Windows PowerShell command to search easily for information in a collection of files.   Hey, Scripting Guy! I need to be able to parse multiple files for text that are in a single folder. I hate to have to write a script for such a common task, but I…


Expert Solution for 2011 Scripting Games Beginner Event 6: Parse the Windows Update Log for Errors with PowerShell

Summary: Microsoft MVP, Sean Kearney, uses Windows PowerShell to solve 2011 Scripting Games Beginner Event 6 and parse the Windows update log for errors. Microsoft Scripting Guy, Ed Wilson, here. Today we have Sean Kearney to provide his solution for Beginner Event 6. Sean Kearney is an infrastructure support analyst and Microsoft MVP in Window…

8

The 2011 Scripting Games Beginner Event 5: Use PowerShell to Collect Basic Computer Information

Summary: Beginner Event 5 uses Windows PowerShell to collect basic computer information. About this event Division Beginner Date of Event 4/8/2011 12:01 AM Due Date 4/15/2011 12:01 AM Event scenario You need to collect the user name, computer name, domain name, and the operating system information from a number of computers. To make matters easier,…

5

Scripting Wife Uses PowerShell to Create Files Automatically

Summary: The Scripting Wife learns how to use Windows PowerShell to automatically create files with the date stored in them. The room seems quiet now. I take a deep breath, let it out slowly, and begin to relax. My name is Ed Wilson. I am the Microsoft Scripting Guy. I have just completed the second…

8