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
  • Adding PowerShell Tools to Windows 8 Start Screen

    Windows 8/Windows 8.1 You may have noticed that the Windows 8 start screen by default is missing PowerShell tools like the PowerShell ISE. When you switch to the start screen and enter “ISE”, the search yields no result. To change this, make...
  • Find AD Replication Failures

    Windows 8.1, Server 2012 R2 Investigating Active Directory replication failures becomes easy with Windows 8.1 and Server 2012 R2. A new cmdlet called Get-ADReplicationFailure will output recent replication failure information. Use it to check a specific...
  • Useful Static .NET Methods

    All Versions PowerShell can access static methods of .NET types. Here are some real world one-liners that can do a lot for you: [ Math ] :: Round ( 7.9 ) [ Convert ] :: ToString ( 576255753217 , 8 ) [ Guid ] :: NewGuid () [ Net.Dns ] :: GetHostByName...
  • Mandatory Parameters with a Dialog

    All Versions Typically, when you declare a parameter as mandatory, and the user does not submit it, PowerShell takes care and prompts the user for the value: function Get-Something { param ( [ Parameter ( Mandatory = $true )] $Path ) "You entered...
  • Use Open File Dialog

    All PowerShell versions To add some sophistication to your script, here is a simple function that opens the OpenFile dialog and lets the user pick a file. function Show-OpenFileDialog { param ( $Title = ' Pick a File ' , $Filter = ' All|*...
  • Logging Folders with Access Denied Errors

    All Versions When you browse the file system with Get-ChildItem, you may stumble across folders that you have no access to view. If you’d like to keep a log of all the folders that raised errors, try this approach: $result = Get-ChildItem -Path...
  • Managing Terminal Service Settings

    ActiveDirectory Module Sometimes you may want to directly access properties related to the terminal service in an Active Directory account. Here is some sample code illustrating how this can be done: $Identity = ' SomeUserName ' $distinguishedName...
  • Credential Obfuscator

    PowerShell ISE 3.0 and later While it is generally not recommended to hard code passwords in scripts, there are sometimes scenarios where this is done. Rather than hard coding plain text passwords, at least an effort should be made to obfuscate passwords...
  • Automatic Unrolling and Memory Consumption

    PowerShell 3.0 and later In PowerShell 3.0, a new feature called “Automatic Unrolling” was introduced. With it, you can write code like this: ( Get-ChildItem -Path $env:windir\system32 -Filter * . dll ) . VersionInfo This line takes all DLL...
  • Copying Command Line History

    All PowerShell versions To preserve all the PowerShell commands that you entered in a PowerShell session, check out this one liner: ( Get-History ) . CommandLine | clip.exe It copies all commands to the clipboard. From there, you can paste them into PowerShell...
  • Getting Computer Serial Number

    All PowerShell versions In a previous tip we illustrated how you can take a DELL serial number and check online the warranty status. Other vendors may offer similar services. Here is a piece of code that can read the serial number: $ComputerName = $env...
  • Checking DELL Warranty Online

    PowerShell Version 2.0 and later If you own a DELL computer, you can take advantage of a web service that takes your computer serial number and returns your entitlements: $serial = ' 36GPL41 ' $service = New-WebServiceProxy -Uri http : // 143...
  • Cmdlets to Manage MSI Packages

    PowerShell 2.0 and later Anyone who needs to manage MSI installer packages may benefit from an open source project found here: http://psmsi.codeplex.com/ . Simply download the PowerShell module – it comes as an MSI installer package itself. Make...
  • Reading Multiline Text

    PowerShell 3.0 and later Sometimes you will stumble across tips like the following one: $FilePath = " $env:SystemRoot\WindowsUpdate.log " $ContentsWithLinebreaks = ( Get-Content $FilePath ) -join "`r`n" Can you guess the purpose? Get...
  • Requiring Administrator Privileges

    PowerShell 4.0 and later If you know that a given script needs Administrator privileges, then a simple #requires statement is enough to make sure the requirement is met: #requires -version 4.0 #requires –runasadministrator ' I am Admin! '...
< Previous 1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.