Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus


13 Free SQL Tools from Idera


Free Ebook: Mastering Powershell

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
  • Finding Numbers in Text

    Regular Expressions are a great help in identifying and extracting data from text. Here's an example that finds and extracts a number that ends with a comma: PS > $text = "I am looking for a number like this 67868683468932689223479, that is...
  • Verbose Driver Information

    In a previous tip you discovered driverquery.exe to list driver information. This tool sports a /V switch for even more verbose information. However, due to localization errors, when you specify /V, column names may no longer be unique. That's when...
  • Making Names Unique

    To make a list of items or names unique, you could use grouping and then, when a group has more than one item, append a numbered suffix to these items. Here's a simple example: function Convert - Unique ( $list ) { $list | Group-Object | ForEach-Object...
  • Home-Made Driver Query Tool

    Some months ago we introduced to you the driverquery.exe tool and how to convert its output to PowerShell objects. Here's now an amazing function that turns this command-line tool into a graphical tool that lists drivers from both local and remote...
  • Checking Text Ending with Wildcards

    In a previous tip you learned how to use the string method EndsWith() to check whether a text ends with certain characters. This method does not accept wildcards, though. So to check text endings for patterns, try this approach instead: PS > "Account123"...
  • Checking if a Text Ends with Certain Characters

    You can always use the String method EndsWith(). Just make sure you convert the text to lower-case first to avoid case-sensitive comparison. This will check whether the file name ends with '.pdf': PS > "somefile.PdF" . toLower ()...
  • Counting Log Activity Based On Product Install

    In a previous tip you learned how to use Group-Object to analyze text-based log files. Here's a refined snippet. It will count on which days your Windows box received the most updates: Get-Content $env:windir\windowsupdate.log | Where-Object { $_...
  • Counting Log Activity

    Did you know that Group-Object can analyze text-based log files for you? Here's sample code that tells you how many log entries on a given day a log file contains: Get-Content $env:windir\windowsupdate.log | Group-Object { $_ . SubString ( 0 , 10...
  • Shrinking Paths

    Many file-related .NET Framework methods fail when the overall path length exceeds a certain length. Use low-level methods to convert lengthy paths to the old 8.3 notation which is a lot shorter in many cases: function Get - ShortPath ( $Path ) { $code...
  • Output to Console AND Variable

    To assign results to a variable and at the same time view these results in your console, place the assignment operation into parenthesis: ( $result = Get-Process ) As you will see, the processes will still appear in your console. At the same time, they...
  • Converting to Signed Using Casting

    In a previous tip, you learned how to use the Bitconverter type to convert hexadecimals to signed integers. Here is another way that uses type conversion: PS > 0xffff 65535 PS > 0xfffe 65534 PS > [ int16 ]( "0x{0:x4}" -f ([ UInt32 ...
  • Converting to Signed

    If you convert a hex number to a decimal, the result may not be what you want: PS > 0xFFFF 65535 PowerShell converts it to an unsigned number (unless its value is too large for an unsigned integer). If you need the signed number, you would have to...
  • Getting Timezones

    Here's a low level call that returns all time zones: PS > [ System.TimeZoneInfo ] :: GetSystemTimeZones () Id : Dateline Standard Time DisplayName : ( UTC - 12 : 00 ) International Date Line West StandardName : Dateline Standard Time DaylightName...
  • Mapping Printers

    To map a network printer to a user profile, here's a powerful low level command: rundll32 printui.dll , PrintUIEntry /in /n "\\pntsrv1\HP552" This will map the printer share and also install drivers if required. A dialog window outputs progress...
  • Fun with Date and Time

    Get-Date can extract valuable information from dates. All you need to know is the placeholder for the date part you are after. Then, repeat that placeholder to see different representations. For example, an upper-case "M" represents the month...
« First ... < Previous 58 59 60 61 62 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.