Whenever you write information to disk, it makes sense to use unique temporary file names. If you use static file names and run your code more than...
ps1
File System Stress Test
If you’d like to generate super large files for stress test purposes, you don’t have to waste time pumping data into a file to make it...
Passing Commands via Parameter
Here is a rather unusual use case for function parameters: a user can pass an output command: function Get-ProcessList { param ( [string]...
Dealing with File Encoding and BOM
When you write text content to a file, PowerShell cmdlets let you specify the encoding. Encoding determines how characters are stored, and when...
Finding Nested Active Directory Memberships (Part 3)
In the previous tip we illustrated how you can find out the direct and indirect group memberships for a user. If you’d like to know the...
Finding Nested Active Directory Memberships (Part 2)
In the previous tip we illustrated how you can use the cmdlets in the ActiveDirectory module to find all direct and indirect memberships for an...
Finding Nested Active Directory Memberships (Part 1)
The ActiveDirectory module (part of the free RSAT tools) provides a number of AD cmdlets. One of these can dump all direct group memberships, for...
Progress Bar Timer
Here is a simple example using the PowerShell progress bar. The code displays a progress bar counting down a break. Simply adjust the number of...
Automatic Document & Report Generation (Part 5)
Iain Brighton has created a free PowerShell module called „PScribo“ that can be used to easily create documents and reports in text, html, or Word...
Automatic Document & Report Generation (Part 4)
Iain Brighton has created a free PowerShell module called „PScribo“ that can be used to easily create documents and reports in text, html, or Word...
Automatic Document & Report Generation (Part 3)
Iain Brighton has created a free PowerShell module called „PScribo“ that can be used to easily create documents and reports in text, html, or Word...
Automatic Document & Report Generation (Part 2)
Iain Brighton has created a free PowerShell module called „PScribo“ that can be used to easily create documents and reports in text, html, or Word...
Automatic Document & Report Generation (Part 1)
Iain Brighton has created a free PowerShell module called „PScribo“ that can be used to easily create documents and reports in text, html, or Word...
Exchanging Variable Values
Here’s a quick tip how to switch variable content in one line: $a = 1 $b = 2 # switch variable content $a, $b = $b, $a $a $b ReTweet this...
Returning Rich Objects from Functions (Part 2)
Whenever a function returns objects with more than four properties, PowerShell formats the output as list, else as table. Before you learn a new...
Returning Rich Objects from Functions (Part 1)
If a PowerShell function needs to return more than one information kind, always make sure you wrap the pieces of information inside a rich object....
Using persisting variables inside functions
By default, when a PowerShell function exits, it “forgets” all internal variables. However, there is a workaround that creates...
Using Default Parameters
If you find yourself always using the same parameter values over again, try using PowerShell default parameters. Here is how: # hash table # Key = #...
Speed Difference: Reading Large Log Files
When it comes to reading large log files and, for example, extracting error messages, PowerShell can either use the low memory pipeline, or the high...
Finding Executable for File
Most things can be handled by built-in PowerShell commands, but if that’s not enough, you can always resort to the internal Windows API. For...
Understanding Script Block Logging (Part 7)
This is part 7 of our mini-series covering PowerShell script block logging. We now just need some cleanup tool that can clear the script block...
Understanding Script Block Logging (Part 6)
This is part 6 of our mini-series covering PowerShell script block logging, and it’s time to address a final thing: when you execute very...
Understanding Script Block Logging (Part 5)
This is part 5 of our mini-series covering PowerShell script block logging. We are almost done, and what’s missing is a better way to read...
Understanding Script Block Logging (Part 4)
This is part 4 of our mini-series covering PowerShell script block logging. By now, you know how to read logged PowerShell code, and how to turn on...