Power Tips

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
  • Remote Configuration in a Peer-to-Peer environment (or across domains)

    By default, PowerShell requires Kerberos authentication to operate remotely, so you cannot use it in a simple peer-to-peer scenario. You can also not use it in a cross-domain scenario with untrusted domains. You will need to allow WSMan to use different...
  • Enabling PowerShell V.2 Remotely

    Setting up the brand new PowerShell v.2 remotely in a domain environment is easy: simply run Set-WSManQuickConfig As long as you have proper privileges to run this command, it does everything automatically: it runs the WinRM service, sets up a PowerShell...
  • Retrieving Error Messages From Your Event Logs

    Event logs record all kinds of stuff. To find the important things, use Get-EventLog and query for the events you are seeking. In PowerShell v.2, Get-Eventlog has a lot of new parameters, such as -computername. With it, you can retrieve events from remote...
  • Use Regular Expression to Validate Input

    PowerShell can use regular expressions to validate user input. All you need is a regular expression that adequately defines the pattern you are seeking. Fortunately, you do not need to create regular expressions from scratch. Simply Google them and then...
  • Add New Properties To Your Objects

    You can use Select-Object to add new properties to an existing object. In PowerShell v.2, Select-Object accepts a wildcard, which in turn adds all existing properties. Why would that be useful? Have a look: Dir | Select-Object * , Age | Foreach-Object...
  • Calculating Time Differences

    Use New-Timespan and submit a date if you'd like to know how long it is until next Christmas. New-Timespan automatically compares this date to the current date (and time) and returns the timespan in a number of different formats from which you can...
  • Analyze Parameter Binding

    You probably know that PowerShell is pretty flexible when it comes to parameters you want to submit to cmdlets and functions. You can name them (putting the parameter name in front of your arguments), you can abbreviate the name (as long as the parameter...
  • Why is my PowerShell console not blue?

    When launching powershell.exe directly, you get a console with black background and only 300 lines of buffer text. When you launch PowerShell from your start menu, you really launch a link, and links can store console custom settings. So this time, your...
  • Don't be surprised by the Help bug

    Get-Help is great for discovering cmdlet and function syntax but sometimes it fails on PowerShell v.2. Take a look at this: Get-Help Enable-PSRemoting Get-Help Disable-PSRemoting When you run both lines in PowerShell v.2, only the first one will retrieve...
  • Making Comment-Based Help Compatible

    In a previous tip, you learned how to add Comment-Based Help information to your own functions so that Get-Help can auto-document the usage. However, once you do this your functions break on PowerShell v.1 because v.1 does not know the block comment feature...
  • Using Comment-Based Help

    PowerShell v.2 allows your functions to seamlessly integrate with the built-in PowerShell Help system. All you need to do is a Comment-Based- Help block into each function: function Test-Me ( $parameter ) { <# .SYNOPSIS A useless function .DESCRIPTION...
  • Using Block Comments

    Another new feature in PowerShell v.2 is the introduction of a new block comment. Basically, anything you place between <# and #> will be treated as comment and ignored by PowerShell. This makes marking multiple lines as comment very easy. Just...
  • Creating Custom Objects

    PowerShell v.2 has a new trick for creating your very own objects that you can then pass to other cmdlets. It is a two-step process. First, create a hash table and add all the information you want in your object: $hash = @{} $hash . name = "Tobias"...
  • Finding Hidden Parameter Shortcuts

    Many cmdlet parameters have built-in alias names that you can use instead of the full parameter name. So instead of "dir -ErrorAction SilentlyContinue," you could use the shortcut "ea" like this: "dir -ea SilentlyContinue."...
  • Shortcuts for Cmdlet Parameters

    You can shorten parameter names since cmdlet parameters are sometimes long and hard to type in. You will only need to enter as much of a parameter name as is necessary to uniquely identify it. For example, instead of calling "dir –recurse,"...
« First ... < Previous 59 60 61 62 63 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.