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
  • Best Practice for PowerShell Functions

    This is a best-practice message: when you create your own function, here are some things you should consider: - Function name: use cmdlet naming syntax (Verb-Noun), and for verbs, stick to the list of approved verbs. For the noun part, use a meaningful...
  • Adding New Lines to Strings

    In a previous tip you learned that text arrays can easily be multiplied. The same is true for assignment operators such as +=. When you apply this operator to a string, it appends a text: PS > $text = "Hello" PS > $text += "World"...
  • Creating Multiline Strings

    You probably know what this line produces: ' Hello ' * 12 Right, you get 12 times the string you submitted. If you wanted new lines instead, a minor adjustment will do the job: , ' Hello ' * 12 The comma puts the string into an array,...
  • Enumerating Registry Keys

    To enumerate all subkeys in a Registry key, you might be using a line like this: PS > Dir HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | Select-Object -expand PSPath Microsoft.PowerShell.Core \ Registry :: HKEY_LOCAL_MACHINE \ SOFTWARE...
  • Asking for Credentials

    When you write functions that accept credentials as parameters, add a transformation attribute! This way, the user can either submit a credential object (for example, a credential supplied from Get-Credential), or simply a user name as string. The transformation...
  • How to List Registry Hives

    Use the provider name instead of a drive name when you need to get a list of all registry hives: Dir Registry :: ReTweet this Tip!
  • Writing Registry Key Default Values

    If you need to set the default value for a registry key, you can use either of these approaches: Set-ItemProperty -Path HKCU:\Software\Somekey -Name ‘ ( Default ) ’ -Value MyValue Or, you can just do this: Set-Item -Path HKCU:\Software\Somekey...
  • Use Dumping Help

    You can start by dumping all Help information into a file to learn more about a PowerShell cmdlet. You can then read all details about the cmdlet while you are playing with it. This is how you dump all Help information for Get-Process: Get-Help -Name...
  • Use Out-GridView Requirements

    Out-GridView is a great way to present results in a “mini-Excel” sheet: Get-Process | Out-GridView However, Out-GridView has two requirements:.NET Framework 3.51 and the built-in script editor ISE must both be installed. ISE is not installed...
  • Use the CTRL+Arrow

    Inside the PowerShell console, you can hold CTRL while pressing the arrow key to move the cursor word-by-word. This way, you can move the cursor much faster. ReTweet this Tip!
  • Change Service Start Mode the PowerShell Way

    When you list services with Get-Service, you will find that a lot of properties may seem to be missing. You can still set such properties when you pipe a service to Set-Service. The following code will change the start mode of the Spooler service (provided...
  • Change Service Startmode

    You can use WMI like this if you want to change a service start mode: ([ wmi ] ' Win32_Service.Name="Spooler" ' ) . ChangeStartMode ( ' Automatic ' ) . ReturnValue ([ wmi ] ' Win32_Service.Name="Spooler" ' ...
  • Determining Service Start Modes

    By using WMI, you can enumerate the start mode that you want your services to use. To get a list of all services, try this: Get-WMIObject Win32_Service | Select-Object Name , StartMode If you want to find out the start mode of one specific service, try...
  • Print All PDF Files in Folders

    Try this one-liner if you need to print out all PDF documents you have stored in one folder: Dir c :\ myfolder \ * . pdf | Foreach-Object { Start-Process -FilePath $_ . FullName – Verb Print } ReTweet this Tip!
  • Store Pictures in Active Directory

    When you need to store a picture into an AD account, the picture will have to be converted to byte values before it can be stored. Just make sure you adjust the path to the picture you want to store and the LDAP path of the AD object you want the picture...
« First ... < Previous 57 58 59 60 61 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.