Power Tips

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
  • Multiple Text Replace

    Imagine that you need to replace a number of different characters in a text. For example, you need to remove special characters or escape something. The switch statement can do that. You will just need to temporarily convert the text into a character...
  • Print All PDF Files in a Folder

    Try this one-liner if you need to print out all PDF documents you have stored in one folder: Dir c:\myfolder\ * . pdf | Foreach-Object { Start-Process -FilePath $_ . FullName –Verb Print } ReTweet this Tip!
  • Shortcut to Network Cards

    To quickly access the settings for your network cards, use this line from within PowerShell: explorer.exe ' ::{7007ACC7-3202-11D1-AAD2-00805FC1270E} ' You can also create a new link on your desktop and use this shortcut as target path. ReTweet...
  • Testing Numbers and Date

    With a bit of creativity (and the help from the -as operator), you can create powerful test functions. These two test for valid numbers and valid DateTime information: PS > function Test - Numeric ( $Value ) { ( $Value -as [ Int64 ]) -ne $null } PS...
  • Create CSV without Header

    ConvertTo-CSV can create comma separated values (CSV) on the fly but it always adds a new header. To create CSV data without columns, take a look at some piece of code - it removes the first two lines: $filepath = " $env:temp\rawcsv.txt " $processes...
  • Check Whether a Program is Running

    If you'd like to find out whether an instance of WinWord (or any other program) is currently running, you can try this: ( Get-Process winword -ea 0 ) -ne $null This line will returns $true if at least one instance is running. Note that this will also...
  • Removing CSV Headers

    Try this to remove column headers from a CSV file: $result = get-process | ConvertTo-Csv -Delimiter ";" $count = $result . Count - 1 $result [ 2 .. $count ] | Out-File $home\test.csv notepad $home\test.csv You can also use this to append raw...
  • Adding Members to Local Group

    To manage local groups, you can think about using net.exe. It may be much easier than using COM interfaces. The next line will add a local user account to the local Administrators group: net localgroup Administrators Tobias /ADD This functionality may...
  • Getting NIC IP addresses and MAC addresses

    WMI can return network information such as your current IP address and MAC address. Here is a sample how PowerShell can utilize and beautify the information. The result is a table with all network adapters that have a MAC address, neatly displaying IPv4...
  • Adding Progress to Long-Running Cmdlets

    Sometimes cmdlets take some time, and unless they emit data, the user gets no feedback. Here are three examples for calls that take a long time without providing user feedback: $hotfix = Get-Hotfix $products = Get-WmiObject Win32_Product $scripts = Get...
  • Validate IP Addresses

    You can use regular expressions and the –match operator to validate user input. Here’s a loop that keeps asking until the user enters a valid IP address: $pattern = ' ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4]...
  • Create Own Driver Tool

    Thanks to Peter Bishop, here's an enhancement to one of our earlier tips. It turns the command line output delivered by driverquery.exe into a nice info window. Driverquery.exe /v /FO CSV | ConvertFrom-Csv | Select-Object ' Display Name '...
  • Integrating WhoAmI Into PowerShell

    There is a cool little tool called whoami.exe which is part of Windows ever since Windows Vista. Since it can provide results not just in plain text but also as comma separated values, it is very easy to integrate into PowerShell. For example, to find...
  • Opening Databases from PowerShell

    The easiest way of accessing databases right from PowerShell is to visit control panel and open the Data Sources (ODBC) module (which resides in Administrative Tools inside control panel). Use the GUI to set up the database type by clicking the "User...
  • Converting Database Records into PowerShell objects

    When you access a database, the result is not automatically wrapped as objects so you cannot pipe the result into other cmdlets like Sort-Object or Group-Object. You can with PowerShell v.2. Here is a sample based on a previous tip (refer to the previous...
« First ... < Previous 2 3 4 5 6 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.