3 min read
Decoding URLs: PowerShell's hidden gems
In this article, we explore how PowerShell handles URL encoding and decoding using two powerful APIs:...
Unlocking the Power of PowerShell: Tips for Success
Are you familiar with try...catch error handling? What is a catch block without a try block? It's a trap – and here is the explanation why and when it's useful.
Most advanced users are familiar with try…catch error handling. Here is an example:
try
{
Write-Host 'Previous Command'
$result = Get-ChildItem -Path $env:windir -Depth 1 -Filter *.log -ErrorAction Stop
Write-Host 'Next Command'
}
catch
{
$_.CategoryInfo | Select-Object -Property Category, TargetName
}
This behavior may be desired, and that's when try...catch is the best choice.
However, if you do not want to skip any commands, you can use a trap instead (see below). And if you do not want to abort a cmdlet, but instead want to evaluate errors after the cmdlet completes, see our next tip in this series.
Remove try keyword and {} braces, and replace catch with trap, add continue and you get:
Write-Host 'Previous Command'
$result = Get-ChildItem -Path $env:windir -Depth 1 -Filter *.log -ErrorAction Stop
Write-Host 'Next Command'
trap
{
$_.CategoryInfo | Select-Object -Property Category, TargetName
continue
}
Unleash the full potential of PowerShell with our handy poster. Whether you're a beginner or a seasoned pro, this cheat sheet is designed to be your go-to resource for the most important and commonly used cmdlets.
The poster is available for download and in paper form.
Oct 1, 2024 by Aleksandar Nikolić and Dr. Tobias Weltner
In this article, we explore how PowerShell handles URL encoding and decoding using two powerful APIs:...
Sep 30, 2024 by Aleksandar Nikolić and Dr. Tobias Weltner
Tired of cryptic number codes cluttering your PowerShell scripts? Discover how PowerShell enums can transform your code...
Jan 7, 2025 by Aleksandar Nikolić and Dr. Tobias Weltner
PowerShell arrays are a powerful and versatile way of managing collections of data, enabling you to efficiently...
Tobias Weltner and Aleksandar Nikolić joinly wrote the blog post series 'Tobias&Aleksandar's PowerShell tips'. So we introduce both of them here:
----------------------------
Aleksandar Nikolić is a Microsoft Azure MVP and co-founder of PowerShellMagazine.com, the ultimate online source for PowerShell enthusiasts. With over 18 years of experience in system administration, he is a respected trainer and speaker who travels the globe to share his knowledge and skills on Azure, Entra, and PowerShell. He has spoken at IT events such as Microsoft Ignite, ESPC, NIC, CloudBrew, NTK, and PowerShell Conference Europe.
----------------------------
Tobias is a long-time Microsoft MVP and has been involved with the development of PowerShell since its early days. He invented the PowerShell IDE "ISESteroids", has written numerous books on PowerShell for Microsoft Press and O'Reilly, founded the PowerShell Conference EU (psconf.eu), and is currently contributing to the advancement of PowerShell as member in the "Microsoft Cmdlet Working Group". Tobias shares his expertise as a consultant in projects and as a trainer in in-house trainings for numerous companies and agencies across Europe.