Sometimes you may want to create your own objects to store multiple pieces of information. Here is a pretty dense oneliner that illustrates a quick...
posts-powershell
Mapping Network Drives (Part 3)
If you migrated from VBScript to PowerShell, you may remember how VBScript mapped network drives. This option is still available in PowerShell....
Mapping Network Drives (Part 2)
Beginning with PowerShell 3.0, you can use New-PSDrive to map network drives. They will be visible in File Explorer as well. Here is some sample...
Mapping Network Drives (Part 1)
PowerShell supports console commands, so if you need to map a network drive, often the most reliable way is to use good old net.exe like this:...
Executing with Timeout
Start-Process can start processes but does not support a timeout. If you wanted to kill a runaway process after a given timeout, you could use an...
Executing Selected Code as Admin
If you need to run selected parts of your script with Administrator privileges, you could temporarily launch a second PowerShell with Administrator...
Finding Drive Letters
Here is a simple function to find out the reserved drive letters: #requires -Version 3 function Get-DriveLetter { (Get-WmiObject -Class...
Quickly Setting Multiple Environment Variables
To quickly (and permanently) set a bunch of environment variables, here is a nice approach: $hashtable = @{ Name = 'Weltner' ID = 12 Ort =...
Quickly Finding Scripts
To quickly locate a PowerShell script anywhere in your MyDocuments folder, take a look at this Find-Script function: #requires -Version 3 function...
Hiding Variable Content
When you override the ToString() method of an object you control how this object is displayed. The object content stays untouched, though: $a = 123...
Adding Additional Information to Objects
When you retrieve results, you may want to add additional properties to the results so later you know where they came from. Attaching additional...
Appending Extra Information to Primitive Data Types
Maybe you'd like to tag a variable and provide some extra information. In PowerShell, use Add-Member and attach NoteProperties or ScriptProperties...