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 Information Using Passphrase

    PowerShell 3.0 and later In a previous tip we explained how you can use the Windows product ID stored in the Windows Registry to encrypt some text information. If you find that this publicly available information is not safe enough for your purpose, then...
  • Encrypting Information with Windows ProductID

    PowerShell 3.0 and later To store secret information, you can use a SecureString object and save it to disk. PowerShell automatically takes the user account as a secret key, so only the user who saved the information can retrieve it. If you want to bind...
  • Finding Exchange Mailboxes

    Microsoft Exchange 2013 To find the number of mailboxes, simply use the Exchange cmdlets and have Measure-Object count the results: Get-Mailbox – ResultSize Unlimited | Measure-Object | Select-Object -ExpandProperty Count Likewise, to find all shared...
  • Clever Parameter Validation

    PowerShell 2.0 and later When you create PowerShell functions with parameters, make sure you tell PowerShell what kind of values the parameter expects. In a simple example, you could ask for a weekday: function Get-Weekday { param ( $Weekday ) "You...
  • Discovering High Impact Cmdlets

    All Versions Cmdlets can declare how severe their impact is. Typically, cmdlets that make changes to the system that cannot be undone will have an “Impact Level” of “High”. When you run such a cmdlet, PowerShell will automatically...
  • ISE Auto-Completion Trick

    PowerShell 3.0 ISE and later When you want to select the information returned by a cmdlet, you typically use Select-Object: Get-Process | Select-Object -Property Name , Company , Description However, you would have to manually enter the property names...
  • Accessing Non-Microsoft LDAP Servers

    All Versions There are free Active Directory cmdlets from Microsoft (part of the RSAT tools) and Dell (Quest). They take the complexity out of accessing a domain controller, and ask for information. To access a non-Microsoft LDAP server, while there are...
  • Finding Read-Only and Constant Variables

    All PowerShell versions Some variables are protected and cannot be changed. To identify these, take a look at this line: Get-Variable | Where-Object { $_ . Options -like ' *Constant* ' -or $_ . Options -like ' *ReadOnly* ' } | Select-Object...
  • Read-Only and Strongly Typed Variables

    All PowerShell versions To make PowerShell scripts more robust, you can code a lot of requirements right into your script variables. When you do this, PowerShell monitors these requirements for you, and throws an error if someone breaks your rules. Requirement...
  • Using Constants

    All PowerShell versions Variables in PowerShell are volatile. You can overwrite and delete them – unless you create constants. Constants can only be created when there is no such variable yet. This line creates a constant named “cannotChange”...
  • Including Resources with Your Scripts

    PowerShell 3.0 and later If your script needs additional resources, like text lists of server names, or picture files, or anything else, then make sure your script stays portable. Never use absolute path names to refer to your resource files. Instead...
  • Using “more” in the PowerShell ISE

    PowerShell ISE In the PowerShell console, you can pipe commands to the old-fashioned “more.com”, or better yet, to Out-Host –Paging. This will display data page by page, asking for a key press to continue: PS> Get-Process | more PS>...
  • Read User Profiles from Registry

    All versions To find out which users have a (local) user profile on your machine, and where this profile is located, try this snippet: $path = ' Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\* ' Get-ItemProperty...
  • Reading Associated File Extensions from Registry (Part 2)

    All versions In a previous tip you learned how a one-liner can read multiple registry keys. In part 2, check out this one-liner: $lookup = Get-ItemProperty Registry :: HKCR \. [ a -f ] ?? | Select-Object -Property PSChildName , ' (default) ' ...
  • Reading Associated File Extensions from Registry

    All versions PowerShell code can be extremely dense. Here is a one-liner that reads all associated file extensions from the Windows Registry: Get-ItemProperty Registry :: HKCR \. * | Select-Object -Property PSChildName , ' (default) ' , ContentType...
« First ... < Previous 3 4 5 6 7 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.