March 2009 - Power Tips

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

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 Simple SMTP Mail

    You need to notify an admin that something happened or something is finished and would like to send a quick e-mail from inside your PowerShell scripts. Here is a simple wrapper allowing you to use any standard SMTP server to send simple e-mails: function...
  • Check Online Status

    When managing more than just one system, you may want to remotely access those systems. Maybe you use WMI to do that. However, when you try and access a system that is offline, you probably run into a network timeout. Here is a simple filter that checks...
  • An Easy InputBox

    All user input and output normally occurs inside the PowerShell console. Simply access the .NET framework directly if you'd like to get back the same dialogs VBScript scripters are using. Here is the old-fashioned InputBox: [ void ][ System.Reflection...
  • Finding Current Script Path

    Ever wanted to locate the path of your current PowerShell script? This can be useful to call other scripts or resources in the same folder. To determine the folder your current PowerShell script is located in, try this: Split-Path -parent $MyInvocation...
  • Finding Aliases for a Command

    PowerShell defines a lot of shortcuts (aliases) for most commands. You may want to determine whether there is a shortcut if you find yourself using some commands repeatedly. Use the Get-CmdletAlias function below to find them: function Get-CmdletAlias...
  • Clone NTFS Permissions

    NTFS access permissions can be complex and tricky. To quickly assign NTFS permissions to a new folder, you can simply clone permissions from another folder that you know has the correct permissions applied. md $home \sample # manually assign correct permissions...
  • Finding and Deleting Orphaned Shares

    Maybe you never noticed but when you delete folders that were shared on the network, the share may be left behind. To locate shares that have no folder anymore, use WMI and the Win32_Share class to give you the folder path that the share is pointing toward...
  • Creating HTML Reports

    PowerShell can convert objects into HTML using ConvertTo-HTML. By adding a bit of custom formatting, your reports can be colorful and cool. The following example shows how to retrieve all error event log entries from all eventlogs and nicely output them...
  • Parsing Logfiles With Regular Expressions

    Regular expressions are a powerful but somewhat complex mechanism to match and find patterns in text files. However, it is not always necessary to dig deep into regular expressions. Take a look at the following example, which reads a log file using Get...
  • Using PowerShell To Create Batch Command Calls

    Whenever you do something twice, automate it! This applies to native commands as well. PowerShell can help you call a native command repetitively. For example, here is how to construct a PowerShell loop if you'd like to use NETSH.EXE to create a bunch...
  • Creating A Computer Profile

    Often, information needed to comprehensively profile a computer comes from a number of sources. A great way to meld these different bits of information together is by creating a new result object with just the properties you need. Simply,, use any simple...
  • Shutting Down Computers Remotely

    WMI not only provides rich information, it also supplies methods that you can call to take action. In the next example, you can forcefully shut down a remote system as long as you have appropriate privileges and there is no firewall blocking your way...
  • Finding Out Interesting WMI Classes

    WMI provides a wealth of information as long as you know the name of the WMI class that represents the entity you are seeking. Fortunately, Get-WMIObject has a built-in dictionary that lists all available WMI classes in the default namespace: Get-WMIObject...
  • Accessing Servers Remotely via WMI

    WMI is a fantastic source of information! Best of all, it works locally as well as remotely. For example, the next line gives you details about your operating system: Get-WMIObject Win32_OperatingSystem Use the parameter -computer like this to get the...
  • Filtering Events by Date and Time

    As you have discovered in a previous tip, reading Eventlog entries is fairly simple using WMI and Win32_NTLogEvent: Get-WmiObject Win32_NTLogEvent - filter "LogFile='System' and EventType=1" | Format-Table ComputerName, EventCode, Message...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.