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
  • Inserting Text into String

    Use Insert() to insert new text into an existing string at a given position. Here is an example: $text = "Server failed" 1 . .100 | ForEach-Object { $text . Insert ( 6 , $_ ) } It produces a list of servers with an increment. Of course, this...
  • Dealing With Long File Names

    The Windows file system often has issues with file paths longer than 256 characters. Provided you followed our tips and installed PowerShellGet, you can easily download a PowerShell module with new cmdlets that help overcome this limit: PS> Install...
  • Colorizing PowerShell Console

    In PowerShell 5.0, when you enter code into the PowerShell console, the tokens get colorized, much similar to the PowerShell ISE interactive console. This colorization is done by a module named "PSReadLine" that ships with PowerShell 5.0. If...
  • Check PowerShell Gallery Code

    In the previous tip we introduced the PowerShell Gallery and showed how to download content (scripts and modules). Since the PowerShell Gallery is a public repository, and anyone can upload code, you should execise caution. Use Install-Module or Install...
  • Using PowerShell Gallery

    The PowerShell Gallery is a public repository for PowerShell scripts and modules. It is entirely managed by cmdlets. Before you can use the PowerShell Gallery to download new scripts and modules, or to share your own with others, you need the PowerShellGet...
  • Nested PowerShell Transcripts

    In previous versions of PowerShell, session logging (transcripts) were supported only in the PowerShell console, and there could only be one transcript log active at a time. In PowerShell 5.0, transcripts can be nested, and work in all hosts. Your script...
  • Logging PowerShell Sessions

    PowerShell always supported session logging in the PowerShell console. Simply enter Start-Transcript to log all input and output to a text file. This cmdlet did not work in the PowerShell ISE, though. Beginning with PowerShell 5.0, Start-Transcript can...
  • Ad-hoc Debugging in PowerShell ISE

    Beginning with PowerShell 5.0, you can break into the debugger any time (in the PowerShell ISE). Simply press CTRL+B to invoke the debugger while a script runs. The next time a script takes longer than expected, try CTRL+B and have a look what it was...
  • Revealing Function Source Code

    Many of the PowerShell commands are made out of functions. Here is how you can peek into the source code of any function: ( Get-Command Test-NetConnection ) . Definition Just make sure the command you want to examine does exist, and is a function. Test...
  • Finding Useful .NET Types

    You may have heard about "type accelerators": they are shortcuts for the long .NET type name: PS> [XML] IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False XmlDocument System.Xml.XmlNode PS> [XML].FullName System...
  • Automatic Unrolling Can Fail

    Beginning with PowerShell 3.0, there is a new feature called "Automatic Unrolling": when you specify a property or method on an array, then the property or method is called on all elements of that array: ( Get-Process ) . Name Unless you specify...
  • New Where-Syntax

    In PowerShell 4.0 and better, there is a new alternative to the Where-Object cmdlet: $all = Get-Service $all | Where-Object { $_ . Status -eq ' Running ' } $all . Where { $_ . Status -eq ' Running ' } The Where() method is special and...
  • Create New XML Item Programmatically

    In a previous tip we explained how you can clone an existing XML item to add a new item. This works only when there are already some items in the XML file that you can clone. To add new items from scratch, you can also programmatically add items. Before...
  • Remove an Item from an XML Document

    Removing items from an XML document is almost trivial: you use XPath to identify the node you want to remove, then remove it. Once you save the XML document, you get a new XML file without the item you wanted to get rid of. Before you play: In a previous...
  • Adding New Nodes to an XML Document

    If you need to add new items to an XML document that already contains such items, the easiest way is to search for an existing item, then clone it. You can then update the information in the cloned item and insert it into the XML document. Before you...
< Previous 1 2 3 4 5 Next > ... Last »
Copyright 2012 PowerShell.com. All rights reserved.