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
  • Finding IP and MAC address

    When you query network adapters with WMI, it is not easy to find the active network card. To find the network card(s) that are currently connected to the network, you can filter based on NetConnectionStatus which needs to be "2" for connected...
  • Turning Multi-Value WMI Properties into Text

    When you read multi-valued information from WMI or any other source, for example, network adapter IP addresses, this information is returned as a multi line string: PS > Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter ' IPEnabled...
  • Finding Network Adapter Data Based On Connection Name

    Sometimes it would be nice to be able to access network adapter configuration based on the name of that adapter as it appears in your network and sharing center. To find the network configuration data for any network card with a "LAN" in its...
  • Creating Excel Reports from PowerShell Data

    Provided you have Microsoft Excel installed, here is a clever function that you can use to convert PowerShell results into Excel spreadsheets: function Out-ReportExcel { param ( $Path = " $env:temp\report$(Get-Date -format yyyyMMddHHmmss).csv "...
  • Outputting Text Reports without Truncating

    If you want to capture PowerShell results in a text file, you can redirect the results or pipe them to Out-File. In any case, what you capture is the exact representation of what would have been displayed in your PowerShell console. So, depending on the...
  • Turning SIDs into Real Names

    Sometimes, you'd like to turn security identifiers (SIDs) into real names. Here is a function that can do this for you: function SID2Name ( $sid ){ $objSID = New-Object System.Security.Principal.SecurityIdentifier ( $sid ) try { $objUser = $objSID...
  • Converting User Names to SIDs

    If you want to translate a valid user name to its security identifier (SID), here is a function to do that for you: function Name2SID ( $name , $domain = $env:userdomain ) { $objUser = New-Object System.Security.Principal.NTAccount ( $domain , $name ...
  • Changing Units

    When you list folder contents, file sizes are in bytes. If you'd rather like to view them in MB or GB, you can use calculated properties, but by turning numbers into MB or GB, you turn them into text strings. That's bad because then you can no...
  • Closing Excel Gracefully

    When you access Microsoft Excel from script, you may have noticed that it never gets removed from memory again, even if you call its Quit() method: ' Excel processes: {0} ' -f @ ( Get-Process excel -ea 0 ) . Count $excel = New-Object -ComObject...
  • Formatting Currencies

    Formatting numbers as currencies is straight-forward - as long as it is your own currency format: ' {0:C} ' -f 12.22 If you want to output currencies in other cultures, you still can do it. Let's assume you created a currency converter and...
  • Using Regular Expressions with Dir

    When you use Dir (alias: Get-ChildItem) to list folder contents, you can use simple wildcards but they do not give you much control. A much more powerful approach is to use regular expressions. Since Get-ChildItem does not support regular expressions...
  • Permanently Changing User Environment Variables

    To create or change an environment variable in the user context, use this low-level call: [ environment ] :: SetEnvironmentVariable ( ' Test ' , 12 , ' User ' ) This environment variable will keep the value until you change it or delete...
  • Using Wildcards with Environment Variables

    You can use the env: PowerShell drive to list all Windows environment variables like this: PS > Dir env : * user * Name Value ---- ----- USERNAME w7-pc9 USERPROFILE C:\Users\w7-pc9 ALLUSERSPROFILE C:\ProgramData USERDOMAIN DEMO5 To access the content...
  • Creating PowerShell Menus

    PowerShell is console based, so its default menus are console based as well. To offer choices to your users, here is some sample code to create a simple menu: $title = "Reboot System Now" $message = "Do you want to reboot your machine now...
  • Scanning Registry for ClassIDs

    The Windows Registry is a repository filled with various Windows settings. Get-ItemProperty can read Registry values and accepts wildcards. So, with Get-ItemProperty, you can create tools to find and extract Registry information. For example, if you know...
« First ... < Previous 57 58 59 60 61 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.