July 2011 - 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
  • Combining Network Adapter Information

    In a previous tip you learned that WMI network adapter information is separated into two classes. Win32_NetworkAdapter represents the hardware, and Win32_NetworkAdapterConfiguration contains the configuration details. To mix information from both classes...
  • Getting Network Adapter Settings

    To view the configuration details of a network adapter, you can specify the network adapter connection ID as it appears in your control panel. By linking the WMI result to the corresponding Win32_NetworkAdapterConfiguration class, you get to the actual...
  • Enumerating Network Cards

    In a previous tip you learned how to use a shortcut to quickly open the dialog with your network adapters. Today, you get a piece of code to access these network adapters programmatically and list the available NetConnectionIDs: Get-WmiObject Win32_NetworkAdapter...
  • Shortcut to Network Cards

    To quickly access the settings for your network cards, use this line from within PowerShell: explorer.exe ' ::{7007ACC7-3202-11D1-AAD2-00805FC1270E} ' You can also create a new link on your desktop and use this shortcut as target path. ReTweet...
  • Find Local Group Members

    If you'd like to list all members of local groups, encapsulate net.exe and make it a PowerShell function: function Get - LocalGroupMember { param ( [ Parameter ( Mandatory = $true )] $name ) try { $ErrorActionPreference = ' Stop ' $users ...
    Filed under: ,
  • Find Local Groups

    On Windows 7, net.exe can list all local groups. To use this information with PowerShell, try this simple wrapper: function Get-LocalGroup { net localgroup | Where-Object { $_ . StartsWIth ( ' * ' ) } | ForEach-Object { $_ . SubString ( 1 ) }...
    Filed under:
  • Find Local Users

    On Windows 7, the easiest way to find local user accounts is to use net.exe. Here is a simple PowerShell wrapper called Get-LocalUser: function Get-LocalUser { $users = net user $users [ 4 .. ( $users . count - 3 )] -split ' \s+ ' | Where-Object...
    Filed under:
  • Escape Regular Expressions

    PowerShell supports regular expressions in a lot of areas which is why the following code fails: ' c:\test\subfolder\file' -split '\ ' Split expects a regular expression and fails when you use special characters like "\". To...
  • Monitor Open Files

    In a previous tip we introduced the command openfiles which lists and disconnects files that were opened remotely on your machine. Openfiles can also track open files on your local machine. You pay for it with a lower overall system performance because...
    Filed under:
  • Finding Open Files

    If you'd like to see which files are opened by network users on your machine, there is an internal command for it. All you need are local admin privileges, so you may want to launch PowerShell with full privileges first. And then, enter this: PS >...
    Filed under:
  • Removing File Extensions (Safe)

    In a previous tip we showed that Trim() is an unsafe way for removing file extensions. A safe way uses .NET methods: [ system.io.path ] :: GetFileNameWithoutExtension ( ' c:\test\report.txt ' ) Report ReTweet this Tip!
  • Removing File Extensions (Unsafe)

    Some users use Trim() to remove file extensions like this: ' c:\test\file.txt'.Trim('.txt ' ) c:\test\file This seems to work great, but in reality, Trim() removes all the characters you submitted from the beginning and end of the text...
  • Finding Useful WMI Classes

    To find the most useful WMI classes you can use Get-WmiObject, and let PowerShell provide you with a hand-picked list: Select-XML $env:windir\System32\WindowsPowerShell\v1.0\types.ps1xml -Xpath / Types / Type / Name | ForEach-Object { $_ . Node . innerXML...
  • Finding Type Definitions

    PowerShell enhances many .NET types and adds additional information. These changes are defined in xml files. To list all .NET types that get enhanced by default, use this: Select-XML $env:windir\System32\WindowsPowerShell\v1.0\types.ps1xml -Xpath / Types...
  • Analyze Cmdlet Results

    There are two great ways to analyze the results a cmdlet returns: you can send the results to Get-Member to get a formal analysis, telling you the properties, methods and data types, and you can send them to Select-Object to view the actual property content...
1 2 Next >
Copyright 2012 PowerShell.com. All rights reserved.