August 2009 - Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

Welcome to the archive of tips delivered through Tobias' Tip of the Day RSS Feed and Your Power Tip of the Day email. Subscribe in the sidebar to get the latest tips!

Sort by: Most Recent | Most Viewed | Most Commented
  • Accessing Current PowerShell Process

    If you ever want to access the process that is executing your current PowerShell session, use the $pid automatic variable which tells you the Process ID, and feed it to Get-Process: Get-Process -id $pid ReTweet this Tip!
  • Adding Custom Methods to Types

    In a previous tip, we have added a new script method to a string called Words() which would split the string into words. But is it worth the effort? After all, your new Words() method would only be available in that single instance of a string. You would...
  • Adding Custom Methods to Objects

    In a previous tip, you learned how to add custom properties to objects. Today, we want to show you how to add custom methods and also give an example how useful this can be. Let's say you manipulate text and need to find out the word count in a string...
  • Adding Custom Properties

    You may have heard that PowerShell can add custom properties to objects. While we are not going into much detail about this here, we'd like to explain why this works for some objects and not for others. Let's assume you pick a process object,...
  • CSV-Files With Culture

    In a previous tip, you learned that CSV files use different separators, depending on your culture. While you were unable to select a separator in PowerShell V1, in PowerShell v2 you now can use the new -Delimiter parameter to specify your own. An even...
  • CSVs with Alternative Delimiters

    In PowerShell V1, creating CSVs wasn't very flexible because PowerShell was limited to the comma as separator. In many cultures, different separators (like semicolons or tabs) are used instead. With PowerShell V2, you now have a choice and can specify...
  • Persisting Objects with XML

    In the previous tip , you learned that Export/Import-CSV does not persist property types. Instead, all properties are converted to string. To preserve types as well, do not persist objects as CSV (because CSV has no place to store property types). Instead...
  • 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 folder listing to a csv file: Dir $env:windir | Select-Object Name, Length | Export-CSV $home \ test.csv...
  • 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 done to support more languages, but you may no longer be able to open these scripts in other editors. To work...
  • 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 was this line: Get-Alias | Where-Object { $_ . Definition -eq 'Get-Childitem' } In PowerShell V2...
  • Storing Cmd-Results in PowerShell Variables

    You can run classic cmd commands from within PowerShell and store the results in variables. All you need to do is invoke cmd.exe with the /c switch like so: $result = cmd.exe / c dir $result ReTweet this Tip!
  • Using Classic Shell Inside of PowerShell

    Since both PowerShell and the classic cmd.exe are console-based, it is very easy to switch between both of them. If you must use a classic shell command that is not working right inside of PowerShell, simply switch to the classic shell temporarily. Enter...
  • 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. There are some keyboard shortcuts, though. You may already know that pressing HOME places the cursor at the...
  • 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 is defined in the PowerShell link Microsoft has placed into your start menu. So if you launch PowerShell...
  • 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 really looks cool and enhances readability with special support for ClearType and flat screens. And it's...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.