posts-powershell

Using COM Objects to Say "Hi!"

If you have ever written scripts using VBScript, you probably know COM objects which are DLLs and work like command libraries. You can use COM...

Downloads with Progress Bar

If you'd like to download larger files from the Internet and get a progress indicator, you can load the .NET Visual Basic assemblies, which...

Downloading Files from the Internet

You can tap into the wealth of .NET methods easily. Use New-Object to instantiate a new .NET class, and off you go. For example, instantiate an...

Finding System Folders

When you automate file system tasks, you may want to know where special folders such as MyPictures or Documents are located. The .NET class...

Finding Out a Scripts Parent Folder

If you need to find helper files that are stored in the same folder, you may want to know where a given script is stored. The automatic variable...

Finding the Current User

Should you try and use PowerShell as a log-on script, you may want to know who is actually running the script to access user specific folders or...

Outputting Calculated Properties

Format-Table is a very convenient cmdlet to output data as table. You can pick the object properties you want to output like this: Dir |...

Finding Old Files

Occasionally, you might want to find files that are older than a give number of days to delete or backup those. A simple filter can provide that...

Working with Arrays

Creating arrays in PowerShell is easy using the comma delimiter. The next line creates an array with five elements: $myArray = 'Hello', 12,...

Converting Results into Arrays

Whenever you call a function or cmdlet, PowerShell uses a built-in mechanism to handle results: If no results are returned, PowerShell returns...

Finding Duplicate Files

Hash Tables are a great way to find duplicates. Simply use the Hash Table as lookup to see if the file (or element) was already added to the Hash...

Converting Hash Tables to Objects

Hash Tables are convenient but are not true objects. This is bad because you are unable to output the hash content to formatting cmdlets or export...