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
  • Using Enumeration Types for Parameter IntelliSense

    In a previous tip you learned how decorating function parameters with a ValidateSet attribute would allow the ISE editor to display intelliSense help for the parameter arguments. As an alternative, you can assign an enumeration data type to a parameter...
  • Rich IntelliSense for Function Arguments

    To take advantage of the new PowerShell 3.0 argument completion, make sure you're adding ValidateSet attribute to your function parameters (where appropriate). In previous versions of PowerShell, ValidateSet made sure the user could enter only values...
  • Get-WmiObject Becomes Obsolete

    In PowerShell 3.0, while you still can use the powerful Get-WmiObject cmdlet, it is slowly becoming replaced by the family of CIM cmdlets. If you use Get-WmiObject to query for data, you can easily switch to Get-CimInstance . Both work very similar. The...
  • Finding Built-In Cmdlets

    In times where cmdlets can originate from all kinds of modules, it sometimes becomes important to find out which cmdlets are truly built into PowerShell and which represent external dependencies. One way of getting a list of built-in cmdlets is to temporarily...
  • Providing "Static" IntelliSense for Your Functions

    To get rich IntelliSense in PowerShell ISE 3.0, you should start adding the OutputType attribute to your functions. If you do, then ISE is able to provide IntelliSense inside your code without the need to actually have real values in your variables. Here...
  • Detecting STA-Mode

    Here is a simple line that tells you whether PowerShell runs in MTA- or STA-mode: [ Runspace ] :: DefaultRunspace . ApartmentState -eq ' STA ' This information may be important because only in STA-mode can PowerShell run WPF functionality (like...
  • Finding IP Address

    There are various ways to determine the IP address that is assigned to your machine. Here is a rather unusual approach that uses text operators to filter the information out of the results provided by ipconfig.exe. This is not the most solid way of getting...
  • Finding Object Properties in Powershell

    Sometimes, you know the information you are after is present in some object property, but there are so many properties that it is a hassle to search for the one that holds the information. In cases like this, you can convert the object to text lines,...
  • Preserving Special Characters in Excel-generated CSV files

    When you save Excel spreadsheets to a CSV file, special characters get lost. That's because Excel is saving the CSV file using very simple ANSI encoding. The following line re-encodes the CSV file and uses UTF8 encoding, making special characters...
  • Change Order of CSV Columns

    If you have a CSV file and would like to change the order of columns, simply import it into PowerShell, use Select-Object to change the order, and then re-export the CSV file again! $Path = "c:\somepathtocsv.csv" ( Import-CSV -Path $Path ) ...
  • Find Open Files

    To find open files on a remote system, use openfiles.exe and convert the results to rich objects. Here is a sample (replace "storage1" with the name of a remote computer you have access permissions): PS > openfiles /Query /S storage1 /FO...
  • Creating Custom Objects in Powershell

    If you want to create your own custom objects, for example, to enable your functions to return rich objects, you can always use Select-Object like this: PS > $newobject = ' dummy ' | Select-Object -Property Name , ID , Address Then, you can...
  • New Operators in PowerShell v3

    There are four new operators in PowerShell v3: -shl: shifts bits to the left -shr: shifts bits to right and preserves sign for signed values -in: works like -contains, operand order is reversed -notin: works like -notcontains, operand order is reversed...
  • Validation Attributes On Variables

    In PowerShell v2, function parameters could be decorated with validation attributes. In PowerShell v3, these attributes can now also be applied to plain variables, ensuring for example that they keep a certain range, thus producing more robust code: PS...
  • Line Breaks After "." and "::"

    In PowerShell v3 language syntax, it is finally allowed to have line breaks after "." and "::". These symbols are used to access dynamic and static object properties. So with PowerShell v3, concatenating such statements no longer necessarily...
« First ... < Previous 59 60 61 62 63 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.