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

Archives

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
  • Sending Emails (and Diagnosing Mail Servers)

    Send-MailMessage has been around for many years. It can be used to quickly send an email without the need to have an email client at hand. All you need is an SMTP server. Likewise, it can be used to diagnose problems with a particular mail server: Send...
  • Saving Multiple Credentials

    Thanks to Jaap Brasser’s finding, here is an easy way of encrypting a bunch of credentials: $CredPath = " $home\Desktop\mycreds.xml " $creds = @ { Local = Get-Credential -Message LocalAccount Remote = Get-Credential -Message RemoteAccount...
  • Saving Credentials

    Here is a safe way of saving credentials to a file: $CredPath = " $home\Desktop\mycred.xml " Get-Credential | Export-Clixml -Path $CredPath This code generates the file mycred.xml on your desktop. The password is encrypted with your identity...
  • Clearing the Recycle Bin

    A much awaited new cmdlet surfaced in PowerShell 5.0: Clear-RecycleBin! You can clear the recycle bin on a particular drive, or on all drives. This will immediately clear all recycle bins and retrieve disk space: PS> Clear-RecycleBin -Force ReTweet...
  • Launching PowerShell with Admin Privileges - Always

    When you launch PowerShell, you should right-click the PowerShell icon in the taskbar and pin it to the taskbar. This way it is always visible, and a right-click opens the jump list with additional functionality. You may have known this. But did you know...
  • Sorting Multiple Properties

    Sort-Object can sort multiple properties. Just submit a comma separated list: Get-Service | Sort-Object -Property Status , Name | Out-GridView This line sorts all services first by status, and then by name. However, how would you sort multiple properties...
  • ValidateSet Instead of Enum

    In the previous tip we illustrated how the new "enum" keyword works in PowerShell 5.0 to set the values that are assignable to a parameter. This has two backdraws: it works in PowerShell 5.0 only, and the enum needs to be declared before you...
  • Using Enumerations

    Beginning with PowerShell 5.0, you can use the new keyword "enum" to create enumerations. They can be useful for parameter validation: #requires -Version 5 enum MyFavoriteCities { Hannover Seattle London NewYork } function Select-City { param...
  • Remotely Executing Applications on Behalf of Someone Else

    When you remotely execute an application, it will run invisibly on the remote system. Here is some code that illustrates how you can run an application remotely and visibly in the context of another user - provided you have local Administrator privileges...
  • Changing Excel Cells from PowerShell

    If you need to change the content of a specific cell in an Excel spreadsheet, take a look at this sample code: $ExcelPath = ' c:\path..to..some..excel..file.xlst ' $excel = New-Object -ComObject Excel.Application $excel . Visible = $true $workbook...
  • Reading Excel Cells

    The fastest way to read data from an Excel spreadsheet is to export the data to CSV, then use Import-CSV. However, sometimes the data in an Excel sheet is not tabular, or you want to access specific cells. Here is a sample that accesses cells directly...
  • Minimizing All Windows (Part 2)

    If all you need to do is minimizing all open windows, there is the Shell.Application COM object. PowerShell can access its methods via New-Object: $shell = New-Object -ComObject Shell.Application $shell . MinimizeAll () Start-Sleep -Seconds 2 $shell ...
  • Minimizing All Application Windows

    In a previous tip we explained how PowerShell can access low level API functions such as ShowWindowAsync(). Once you better understand how a particular API function works you can use it for many purposes. Here is an example that takes all open application...
  • Accessing API Methods

    PowerShell can use C# to define new .NET types that access the internal Windows API methods. Here is some code that makes accessible the ShowWindowAsync() API function which you can use to control application windows. It minimizes your PowerShell instance...
  • Check Default PowerShell Module Paths

    Sometimes, PowerShell modules ship as MSI packages. When they do, you never know what the installation logic does to your system. Unfortunately, there are module authors who replace rather than add paths to the list of default PowerShell module paths...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.