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

Archives

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
  • Debugging Other PowerShell Processes

    PowerShell 5 Beginning with PowerShell 5.0, the PowerShell ISE can connect to other processes that run a PowerShell runspace, display the source code, and debug the foreign process. This is great news because now you can debug PowerShell code that runs...
  • Use CredSSP to Fight Double-Hop Networking Issues

    PowerShell 2+ If you do PowerShell remoting, you may have experienced “double-hop” problem. It occurs when you try to pass on your identity from the remote code to a 3rd party. Simple example: the remote code wants to access a file share and...
  • Reading NTFS Permissions

    PowerShell 2+ NTFS permissions are represented by complex object hierarchies that are hard to read. A much simpler way is to output the structure in an SDDL (Security Descriptor Definition Language) format: $sd = Get-Acl -Path c:\windows $sd . GetSecurityDescriptorSddlForm...
  • New Delayed Output in PowerShell 5.0

    PowerShell 2+ Let’s do two things. First, have a look at a useful small new function that does DNS resolution. Then, let’s discuss why this function can behave differently in PowerShell 5.0. Here is the function: function Get-HostByName {...
  • Creating Your Private PowerShellGet Repository

    PowerShell 3+ / PowerShellGet In the previous tip we introduced PowerShellGet and showed how you can install this module from www.powershellgallery.com if you are using PowerShell 3.0 or 4.0 (it ships with 5.0). You also learned how you can use the cmdlets...
  • Test-Driving PowerShellGet Module

    PowerShell 3+ PowerShell 5.0 ships with a new module called PowerShellGet, and on older PowerShell versions, you can easily download and install this module from www.powershellgallery.com . With it, you have a bunch of new cmdlets that can search for...
  • Type-Based Parameter Binding (Part 2)

    PowerShell 2+ In a previous tip we introduced automatic type-based parameter binding. Here is a use case. The function Test-Binding accepts files and folders. For incoming files, it calculates the file size. For incoming folders, it emits a warning. Note...
  • Understanding Type-Based Parameter Binding

    PowerShell 2+ PowerShell can automatically bind arguments to parameters based on type. Simply define different parameter sets. Here is an example: function Test-Binding { #Content [ CmdletBinding ( DefaultParameterSetName = ' Number ' )] param...
  • Find All Writeable Object Properties

    All Versions .NET objects often have properties that you can read to retrieve information. Some of these properties may actually be writeable, so you can use them to change the object. To find writeable properties, here is a trick. Take any .NET object...
  • Creating Custom Mandatory Parameters

    All Versions While you can declare a parameter as mandatory, this leaves not much control to you. If the user omits the mandatory parameter, PowerShell prompts the user with its ugly default prompt. Here is an alternative that allows you to define your...
  • Use a Shorter Prompt

    All Versions By default, PowerShell displays the current path in its input prompt which wastes as lot of space. When you overwrite the “prompt” function, you control how the prompt is displayed. Here is a prompt that displays the current location...
  • Doing Things in Parallel

    Any version By processing things in parallel rather than sequential, a script can complete much faster. Here is an example that uses background jobs to execute three tasks in parallel: # three things to do... $task1 = { Start-Sleep -Seconds 5 ; 1 } $task2...
  • More Splitting Fun

    In the previous tip, we explained how you can use a regular expression to split strings in groups of a given length. Let’s explore what else can be done with this approach: To split regular text in chunks of 5 character words, try this: ' Hello...
  • Splitting Groups

    All PowerShell Versions Ever wanted to split a string in chunks of a given length? Regular expressions can help. Here is an example that splits a list of numbers in groups of 8 digits each: ' 000111010010010000101001 ' -split ' (\d{8}) '...
  • Using Form-Based Windows in PowerShell

    WPF-based windows are the preferred way to create user interfaces this way - because the code is much easier to write, shorter, and WPF scales well on high-density high-resolution displays. Still, if you must use Windows Forms, here is a sample to get...
1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.