PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Forum experts available to answer your PowerShell questions

Power Tips

Power Tips

Syndication

  • Using Arrays as Parameter Default Values

    PowerShell 3.0 and later If you define a PowerShell function with some parameters, and you want a given parameter to have a default value that is an array, you may run into a syntax problem: function Get-SomeData { param ( $ServerID = 1 , 2 , 5 , 10 ...
  • Shorten the Prompt

    PowerShell 3.0 and later By default, PowerShell includes the current path into the prompt, and when you launch PowerShell as regular user, the current location is your user profile. That is a long path, and it is eating a lot of space. The most effective...
  • Getting DELL Warranty Information (Part 2)

    PowerShell Version 2.0 and later In a previous tip we illustrated how you can use a web service to retrieve warranty information for DELL computers. We received a lot of feedback, so before we add something new, here is the code that gets the warranty...
  • Normalizing File Extensions

    PowerShell 2.0 and later Let’s assume you want the user to submit a list of file extensions, or you are getting them from some other source. File extensions are a perfect example of fuzzy standards. How would you specify a text file extension? Is...
  • Using the PowerShell ISE Debugger

    PowerShell 3.0 and later Sometimes, it is hard to find out why a PowerShell script is not doing what it should do. To get a better understanding of what the code does, use the debugger that is built into the PowerShell ISE. Before you can debug a script...
  • Using Code Regions in ISE

    PowerShell 3.0 and later PowerShell ISE already supports collapsible code regions. When you write functions, loops, or conditions, you will notice a vertical line in the left margin with a “minus” symbol on top. Click it to collapse the region...
  • Process Killer (and some gotchas)

    PowerShell 3.0 and later In a previous tip we explained how you can turn Out-GridView into a selection dialog, and suggested a couple of ideas. One idea was to list all top level applications, and allow the user to select one, and kill it. To get all...
  • Copying Results to Clipboard

    PowerShell 3.0 and later In a previous tip we explained how you can easily copy and paste information from a grid view window produced by Out-GridView. This will not copy the column headers, though. Here is a line that you can add to any command, and...
  • Out-GridView: Universal Dialog

    PowerShell 3.0 and later By default, Out-GridView is a one-way road: you can pipe data into it and display it in a grid view window, but you cannot pass the data on. Once you add the –PassThru switch parameter, this changes, and Out-GridView displays...
  • Finding All Stoppable Services

    PowerShell 3.0 and later Get-Service lists all services installed on your computer. It has no parameter to select only running or stopped services, though. With a simple Where-Object clause, you can make up for this. Most often, you will see something...
  • Exporting Out-GridView Content

    PowerShell 3.0 and later Out-GridView is a very useful cmdlet to output results to an extra window. Unlike outputting to the console, Out-GridView will not cut off anything. And it has a not-so-obvious way of easily copying the information to other applications...
  • Getting a Clean PowerShell Environment

    PowerShell 3.0 and later When you develop PowerShell scripts in the PowerShell ISE, you will probably make a lot of changes and revisions, and regularly execute scripts for testing. This can “pollute” your environment: all variables defined...
  • Adding PowerShell Tools to Windows 8 Start Screen

    Windows 8/Windows 8.1 You may have noticed that the Windows 8 start screen by default is missing PowerShell tools like the PowerShell ISE. When you switch to the start screen and enter “ISE”, the search yields no result. To change this, make...
  • Find AD Replication Failures

    Windows 8.1, Server 2012 R2 Investigating Active Directory replication failures becomes easy with Windows 8.1 and Server 2012 R2. A new cmdlet called Get-ADReplicationFailure will output recent replication failure information. Use it to check a specific...
  • Useful Static .NET Methods

    All Versions PowerShell can access static methods of .NET types. Here are some real world one-liners that can do a lot for you: [ Math ] :: Round ( 7.9 ) [ Convert ] :: ToString ( 576255753217 , 8 ) [ Guid ] :: NewGuid () [ Net.Dns ] :: GetHostByName...
« First ... < Previous 3 4 5 6 7 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.