Category Archives: powershell

PowerShell related material and PowerShell programs.

Text file with line numbers

For some time now I’ve wanted to create text files with line numbers. An example of this could be: This can be useful if I want to use the line numbers to refer to. For example, having a text file … Continue reading

Posted in powershell | Tagged | Leave a comment

Function template

The following code can be used as a function template. I’ve found that using  BEGIN, PROCESS and END blocks makes the function more structured and my life a lot easier.  

Posted in powershell | Tagged | Leave a comment

Using $PSBoundParameters

$PSBoundParameters is one example of a PowerShell automatic variable. As the documentation tells us: … variables that store state information for PowerShell. These variables are created and maintained by PowerShell. Some basic examples of using this variable are as follows: … Continue reading

Posted in powershell | Tagged | Leave a comment

Files and file lengths

A hashtable can be used to help present file names and their lengths in a more meaningful manner rather than the default output from using the cmdlet Get-ChildItem.   Sample output:   Of course, if you were working with larger files, … Continue reading

Posted in powershell | Leave a comment

Create numbered test files

I often have the need to create numbered test files such as for example: myfile.txt.001 myfile.txt.002 : myfile.txt.099 or whatever the maximum numbered test file is. It doesn’t have to be 99 of course. In this example, I’m going to … Continue reading

Posted in powershell | Tagged | Leave a comment

Exploring Photographic EXIF data

I was doing some work recently learning how to extract Exif data from digital photographs. The requirement went away so I’m not doing any more learning on the subject for the present time. The web site “Exploring Photographic EXIF data … Continue reading

Posted in powershell | Leave a comment

A collection without duplicates

If you have a requirement to add strings to a collection but don’t want or need duplicate elements, think about using the HashSet Class. This class can be found in the System.Collections.Generic namespace. HashSet Class Namespace: System.Collections.Generic Demonstration program Sample output The use … Continue reading

Posted in powershell | Leave a comment