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
  • Encrypting Text

    There are many ways to encrypt text. Here is an approach that does not use an explicit “secret”. Instead, the secret is defined as your identity plus your machine. When you encrypt text using ConvertTo-TextEncrypted, the result can only be...
  • Moving Outdated Log Files to Archive

    Occasionally, you may want to move files to an archive folder when they are older than a given number of days. Here is an example that illustrates the basic strategy on how to identify outdated files, and how to move them to an archive: #requires -Version...
  • Create Benign “Task Kill” Application

    In a previous tip we showed how you can select applications and kill them immediately. All unsaved data in the applications would get lost. Here is a more sophisticated approach. It lists all applications, and you can select those you want to end (hold...
  • Create “Task Kill” Application

    With just one pipeline command, PowerShell can open a list of running applications. You can then select one or more in the list (hold CTRL to select more than one), and PowerShell would kill the selected applications. Get-Process | Where-Object { $_ ...
  • Open Web Page

    To quickly open a new web page in the Internet Explorer, you could define a new function called Show-WebPage like this: #requires -Version 2 function Show-WebPage { param ( [ Parameter ( Mandatory = $true , HelpMessage = ' URL to open ' )] $URL...
  • Getting Active Directory User Name

    Here is a quick way to find the current user in your Active Directory and retrieve account information such as the display name: ([ adsisearcher ] "(samaccountname=$env:USERNAME)" ) . FindOne () . Properties [ ' displayname ' ] ReTweet...
  • Adding "List All Variables" to PowerShell ISE

    In a previous tip we showed a script that would find all variable names in all scripts open in PowerShell ISE. Here is an adaption that adds a new command called "List Variables" to the Add-ons menu inside the PowerShell ISE: $code = { $psise...
  • Listing All Variables in All Scripts

    Ever wanted an inventory of variable names used in all open scripts in the PowerShell ISE? Here is some code that you can run to create such a list: $psise . CurrentPowerShellTab . Files | ForEach-Object { $errors = $null [ System.Management.Automation...
  • Quick Loop

    Requires PowerShell 4.0 There are plenty of looping constructs in PowerShell. Here is a rather unusual way introduced in PowerShell 4.0 to repeat code. This example will play a sound with an increasing frequency (make sure you enable your speakers): ...
  • Analyzing (All) Event Log Entries

    You probably know Get-EventLog. This cmdlet can dump all entries from a given event log: Get-EventLog -LogName System However, Get-EventLog can only query one event log at a time. So if you wanted to find all errors in all event logs, you would create...
  • Finding the Most Important Event Log Error Sources

    If you don't have much time yet would like to know what the most common sources of errors are in your System event log, try this line: Get-EventLog -LogName System -EntryType Error , Warning | Group-Object -Property Source | Sort-Object -Property...
  • Refresh Newly Mounted Disks

    If your script has just mounted a new drive, PowerShell may not immediately be able to access it (via Get-ChildItem, for example), because PowerShell did not yet update its drive list. To update the PowerShell drive list, run this: $null = Get-PSDrive...
  • Load Cmdlets from PSSnapins

    Most cmdlets these days are organized in modules. Modules were introduced in PowerShell 2.0. Their main advantage is copy&paste deployment (no installation required) and module auto-loading (PowerShell automatically loads modules when you need them...
  • Loading PowerShell Modules

    All cmdlets live in modules or snap-ins. To see which modules are currently loaded, use Get-Module. In PowerShell 3.0 or better, most modules are imported implicitly when you run a cmdlet found in that module. This clever mechanism implements a "load...
  • How to find Commands that have the Specified Parameter

    Get-Command is your primary tool when you need to find a command to accomplish something. You can search for verbs and/or nouns like this: # find all cmdlets/functions that stop things Get-Command -Verb Stop # find all cmdlets/functions that affect services...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.