June 2010 - 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
  • How Much RAM Do You Have?

    Ever wondered what type of RAM your PC uses and if there is a bank available to add more? Ask WMI! This example also converts the cryptic type codes into clear-text using hashtables to create new columns: $memorytype = "Unknown" , "Other"...
  • Accessing Object Properties

    Objects store information in various properties. There are two approaches if you would like to get to the content of a given property. One is commonly used among developers, the other one among admins. Both will get you the same result. Have a look: #...
  • Changing File/Folder Creation Date

    You should use this approach if you need to change the creation time of a folder or file after you have created it: Get-Childitem c:\testfolder | Foreach-Object { $_ . CreationTime = '1/1/1972 10:35' } It will change creation time of c:\testfolder...
  • Changing Error Background Color

    If you would like to make error messages more readable, you can change their background color from black to white: $host . PrivateData.ErrorBackgroundColor = 'White' Use this line to see the colors that you can assign: [ System.Enum ]:: GetNames...
  • Removing Empty Things

    How do you exclude objects based on empty properties? For example, WMI returns all kinds of "network adapters:" Get-WMIObject Win32_NetworkAdapterConfiguration To focus only on those that have an IPAddress assigned, you should exclude any object...
  • Filtering Day of Week

    You can also use this little helper function if you run scripts every day and want to make sure they don't do anything on weekends: function is-Weekend { ( Get-Date ). DayOfWeek -gt 5 } You can use it like this: If ( is-Weekend ) { 'no service...
  • Finding Object Types

    When you pipe the result of a command to Get-Member, it examines the returned objects and shows the properties and methods. Use this line if you would like to focus on the different object types a command returns: Dir $env:windir | Get-Member | Group...
Copyright 2012 PowerShell.com. All rights reserved.