Modules installed via PowerShellGet can be updated automatically to the latest version. You would need to run PowerShell with full Administrator...
ps1
Keeping Your Modules Up-To-Date
Once you start downloading modules from the PowerShell Gallery (or via PowerShellGet in general), you get version control automatically. You can...
Better Prompting for Mandatory Parameters
When you do not submit an argument to a mandatory parameter, PowerShell prompts you for a value. You don't have much control over how this is done,...
Use Mandatory Parameters
Mandatory parameters are cool: you can submit values to them for automated solutions, and you can omit them and get prompted interactively. Here is...
Accept User Input with Validator
Of course you can use Read-Host to ask a user for some input, or use mandatory parameters. They all are kind of ugly, and have next to no...
Keeping Track of Installed Modules
When you start using PowerShellGet to download modules from the PowerShell Gallery (www.powershellgallery.com) or your own NuGet repositories, you...
Tailing Log Files
You can ask PowerShell to monitor a text-based log file and output any changes. It is a one-liner: Get-Content c:\Windows\WindowsUpdate.log -Wait...
Checking Paths and Files for Illegal Characters
In the previous tip we illustrated how you can get a list of characters that are illegal in paths or file names. However, what would be the best and...
Finding Invalid File and Path Characters
When dealing with files and folders, some characters are considered illegal. Here is an easy way to get a list of the characters that Windows...
Operate Your Own PowerShell Gallery
With PowerShellGet, you can easily share PowerShell code. Go to www.powershellgallery.com and download the MSI installer to install PowerShellGet if...
Identifying Special Characters
If you must ensure that a string contains only a given set of characters, try this: $text = 'tobias.weltner' $hasOtherCharacters = $text...
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 |...
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...
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...
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...
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...
Nested PowerShell Transcripts
In previous versions of PowerShell, session logging (transcripts) were supported only in the PowerShell console, and there could only be one...
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....
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...
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...
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...
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...
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...
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...