Powershell

Import-CSV and Types

Export-CSV and Import-CSV are great ways of persisting data in a structured way. There are some limitations, though. Take a look. This line saves a...

PowerShell ISE uses Unicode

If you start experimenting with PowerShell V2 ISE (editor), you may notice that all scripts you create are saved in Unicode by default. This was...

Finding Alias Names in V2

Alias names are shortcuts for other commands, and you probably know that. In PowerShell V1, the only way to retrieve all aliases for a given target...

Deleting Characters in the Console

Moving the cursor in long input lines is not very convenient. You cannot use the mouse and have to use arrow keys to move backwards and forward....

Why isn’t my console background blue?

Maybe you have noticed that some PowerShell consoles have a nice blueish background while others default to black. Actually, the blueish background...

Download Consolas Font For PowerShell

Well, ok, Consolas wasn't specifically designed for PowerShell but rather as an enhancement for all consoles. It is a new Microsoft font that...

Better Fonts And Larger Buffer

Each PowerShell console has a small icon at the left of its title bar, and when you right-click this icon and choose Properties, you open the...

Autocompleting the Console Way

There are many autocompletion tricks built into PowerShell, and you probably know that pressing TAB is always a good idea to save typing. There is...

Clear Command List

There are actually two places where your commands get stored: One is maintained by PowerShell (Get-History, Invoke-History). The other one is...

Selecting Previous Commands

In our last tip, you learned that F7 opens a dialog with your command history. To select a command, you had to use the arrow keys to move to the...

Open Console History

Did you know that the PowerShell console shares some key shortcuts with classic cmd consoles? For example, press F7 to open a menu with your command...

Docking PowerShell in Windows 7

If you happen to run Windows 7 already, not only will you get PowerShell V2. In addition, with the new "Superbar", you can create your...

File Or Folder? Find Out!

Test-Path can check whether a file or folder exists, but this does not tell you whether the path specified was actually a file or a folder. If...

Test-Path Can Check More Than Files

Test-Path is your friend whenever you want to check whether a file or folder exists: Test-Path C:autoexec.batTest-Path C:windows Test-Path can check...

Creating A HTML Font List

With just a couple of lines of code, you can create a HTML document listing each installed type face on your computer which you then can print out...

Converting Objects Into Text

PowerShell internally always works with objects, and this can cause confusion when you mix object and string technologies. In a previous example,...

Listing All Installed Font Families

To get a list of all available font families on your system, you can load the .NET drawing library and then ask the InstalledFontCollection for all...

Finding Empty Folders

To find out all folders that contain no files, you can use this line: dir -recurse | Where-Object { $_.PSIsContainer } | Where-Object {...

List All Folders and Subfolders

Ever wanted to create a list of all folders and subfolders? It just takes one line: dir -recurse | Where-Object { $_.PSIsContainer } |...

List Hidden Files

Did you notice that Dir, ls or Get-ChildItem do not return hidden files? To see hidden files, you need to specify the -force parameter: Dir...

Converting FileSystem To NTFS

When you buy a new external USB drive, most of the time it is preformatted with the old FAT32 file system for compatibility reasons. You could...

Reading and Writing Drive Labels

Drive Labels are the names attached to logical disks. Using WMI, you can both read and write (change) drive labels. To read the existing drive...

Finding Out A Drives’ FileSystem

If you ever needed a tool to find out the type of file system for any drive, take a look at this simple PowerShell function: function...

Feeding Input Into Native Commands

Sometimes, you need to call commands that require interactive input to work. For example, to find out existing drives with DiskPart, you would have...

Advanced String Filtering

In a previous tip, you learned how Select-String can filter string arrays based on a keyword. Have a look: route print | Select-String 127.0.0.1...

Filtering Command Results

PowerShell captures any output from any command you enter. This is why you can always store command results in a variable, even with native...