How Do You Find the PID when You only Know It by the Task Name in the Task Manager?

Problem scenario
You have an application (in Windows) running, and you want to terminate it with PowerShell.  You want to find running program’s PID.  But you only know its name in Task Manager.  

How do you obtain the Process ID (identification number) of a program (or application) in Windows when you only know the Task Manager name of the program (or application)?

Solution
1.

How Do You Troubleshoot This PowerShell Error “Unable to initialize device PRN.”?

Problem scenario
When running a PowerShell script, you receive the error “Unable to initialize device PRN.”  

Solution
Use the “echo” reserved word instead of “print”.

PRN is what the Windows system name for printer (according to this external posting).

Optional:  If you want to buy a book on PowerShell, click here; you may also want to click here and search for “PowerShell”.

Using PowerShell, How Do You Reverse the Individual Strings in a .txt File While Preserving the Top to Bottom Order of the Lines Themselves?

Problem scenario
You have a list of strings in a .txt file.  You want each string to be in the reverse order from left to right.  You want the strings to remain in their current order from top to bottom.  In other words, you want the content of each line to be reversed. Otherwise you want to preserve the lines in the file (row by row).  For example,

How Do You Create a PowerShell Script to Filter a List by Removing Any Line That Matches Patterns or Strings in a Second File?

Problem scenario
You have two files.  One file is the main file you want to modify by removing lines that match specific patterns.  The second file has patterns (or strings) that should not be in a final, filtered list.   How do you filter a file to remove the patterns that match strings in another file?

Solution
# This assumes you want to ignore blank spaces in the second file.  

How Do You Troubleshoot a PowerShell Error “CreateFromDirectory … The Path Is Not of a Legal Form”?

Problem scenario
You want a PowerShell script to place files from a folder into one zip file.

When using PowerShell version 3, your script throws this error:


Exception calling “CreateFromDirectory” with “2” argument(s): “The path is not of a legal form.”
At line…
     CategoryInfo                  : NotSpecified: (:) [], MethodInvocationException
   

Using PowerShell Version 3, How Do You Determine If a Port Is Open for a given IP Address?

Problem scenario
You are using Windows 7 and PowerShell version 3.  You want to test if a port is open to a given IP address.  (If you are using a modern version of PowerShell, use the Test-NetConnection command.)   How do you find out if a port of an IP address is open or not?

Solution
Use the PowerShell function Test-TCPPortConnection written by Jonathan Medd.  

How Do You Download a File With PowerShell When You Get the Error “Not enough space on disk”?

Problem scenario
You are using PowerShell 3.0 on Windows 7 and you try to run the PowerShell command start-bitstransfer to download a large file.  Running start-bitstransfer results in an error that says “Not Enough space on disk.” 

Solution
Verify the size of the file.  See if the destination directory/drive has sufficient space.  If this error happens despite there being ample space available in the destination drive and destination directory compared to the size of the source media,