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
  • Finding and Dumping Registry Key Paths

    All PowerShell versions In a previous tip we illustrated how to convert an internal PowerShell path format to a real path. Here is a use case. This code recursively searches through HKEY_CURRENT_USER and dumps all Registry keys that contain the word “powershell”...
  • Correcting PowerShell Paths

    All PowerShell versions Occasionally, you might stumble across strange path formats like this one: Microsoft.PowerShell.Core \ FileSystem :: C:\windows\explorer.exe This is a full PowerShell path name which includes the module name and provider name that...
  • Case-Correct Name Lists

    All PowerShell versions Let’s assume it’s your job to update a list of names. Here is an approach that will make sure that only first letter in a name is capitalized. This approach works with double-names as well: $names = ' some-wILD...
  • Hibernate System

    All PowerShell versions Here is a simple system call that will hibernate a system (provided of course that hibernation is enabled): function Start-Hibernation { rundll32.exe PowrProf.dll , SetSuspendState 0 , 1 , 0 } Note that this call is case-sensitive...
  • Recursing a Given Depth

    PowerShell 3.0 and newer When you use Get-ChildItem to list folder content, you can add the –Recurse parameter to dive into all subfolders. However, this won’t let you control the nesting depth. Get-ChildItem will now search in all subfolders...
  • Managing Printers Low-Level

    All PowerShell versions Recent Windows operating systems like Windows 8 and Server 2012 come with great printing support, but if you run older Windows versions, then this call may help: PS> rundll32.exe PRINTUI.DLL,PrintUIEntry PS> Note that this...
  • Aliases Can Be Dangerous

    All PowerShell versions Aliases enjoy the highest priority among executable commands in PowerShell, so if you have ambiguous commands, PowerShell always picks the alias. This can be dangerous: if you allow others to change your PowerShell environment...
  • Converting Special Characters, Part 2

    All PowerShell versions In a previous tip we illustrated how you can replace special characters in a text. Here is another approach that may be a bit slower but is easier to maintain. It also features a case-sensitive hash table: function ConvertTo -...
  • Converting Special Characters, Part 1

    All PowerShell versions Sometimes it becomes necessary to replace special characters with other characters. Here is a simple function that does the trick: function ConvertTo - PrettyText ( $Text ) { $Text . Replace ( ' ü ' , ' ue '...
  • Test-Driving Scripts without Aliases

    All PowerShell versions Aliases can be cool in interactive PowerShell but should not be used in scripts. In scripts, use the underlying commands (so use “Get-ChildItem” instead of “dir” or “ls”). To test drive a script...
  • Delete Aliases

    All PowerShell versions While you can easily create new aliases with New-Alias or Set-Alias, there is no cmdlet to delete aliases. PS> Set-Alias -Name devicemanager -Value devmgmt.msc PS> devicemanager PS> To delete an alias, you would typically...
  • Finding AD Accounts Easily

    All PowerShell versions You do not necessarily need additional cmdlets to search for user accounts or computers in your Active Directory. Provided you are logged on to the domain, simply use this: $ldap = ' (&(objectClass=computer)(samAccountName...
  • Loading Functions from Separate File

    PowerShell 3.0 and newer To keep things simple, you may want to put PowerShell functions into a separate file. To load these functions into your job scripts, you can use a simple approach. Make sure the script file with your PowerShell functions is stored...
  • Creating Great Reports

    All PowerShell versions You can change all properties of objects when you clone them. Cloning objects can be done to “detach” the object data from the underlying real object and is a great idea. Once you cloned objects, you can do whatever...
  • Accepting Multiple Input

    All PowerShell versions When you create PowerShell functions, here is a template that defines a InputObject parameter that will accept multiple values both via parameter and via pipeline: function Get-Something { param ( [ Parameter ( Mandatory = $true...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.