Get-Date can extract valuable information from dates. All you need to know is the placeholder for the date part you are after. Then, repeat that...
database-tools
Chapter 14. XML
In today’s world, data is no longer presented in plain-text files. Instead, XML (Extensible Markup Language) has evolved to become a de facto...
Counting Work Days
Ever wanted to know how many days you need to work this month? Here's a clever function that lists all the weekdays you want that are in a...
Chapter 13. Text and Regular Expressions
Converting to Hex
Here's a simple way to convert a decimal to a hex representation, for example, if you want to display an error number in standard hexadecimal...
Chapter 12. Managing Scope
Anything you define in PowerShell - variables, functions, or settings - have a certain life span. Eventually, they expire and are automatically...
Sending Variables through Environment Variables
Let's assume you want to launch a new PowerShell session from an existing one. To carry over information from the initial session, you can use...
Chapter 11. Error Handling
Chapter 10. Scripts
PowerShell can be used interactively and in batch mode. All the code that you entered and tested interactively can also be stored in a script file....
Chapter 9. Functions
Showing MsgBox
Ever wanted to display a dialog box from PowerShell rather than spitting out console text? Then try this function: function Show-MsgBox { param (...
Chapter 8. Loops
Loops repeat PowerShell code and are the heart of automation. In this chapter, you will learn the PowerShell loop constructs. Topics Covered:...
ASCII Table
Here’s a simple way of creating an ASCII table through type casting: 32..255 | ForEach-Object { 'Code {0} equals character {1}' -f $_, [Char]$_ }...
Chapter 7. Conditions
Conditions are what you need to make scripts clever. Conditions can evaluate a situation and then take appropriate action. There are a number of...
Pipeline Used Or Not?
Sometimes you may want to know if your function received parameters over the pipeline or direct. Here is a way to find out: function test {...
Chapter 6. Working with Objects
In this chapter, you will learn what objects are and how to get your hands on PowerShell objects before they get converted to simple text. Topics...
Using Background Jobs to Speed Up Things
PowerShell is single-threaded and can only do one thing at a time, but by using background jobs, you can spawn multiple PowerShell instances and...
Chapter 5. The PowerShell Pipeline
The PowerShell pipeline chains together a number of commands similar to a production assembly. So, one command hands over its result to the next,...
Validate IP Addresses
You can use regular expressions and the –match operator to validate user input. Here’s a loop that keeps asking until the user enters a...
Chapter 4. Arrays and Hashtables
Chapter 3. Variables
It is time to combine commands whenever a single PowerShell command can't solve your problem. One way of doing this is by using variables....
Chapter 2. Interactive PowerShell
PowerShell has two faces: interactivity and script automation. In this chapter, you will first learn how to work with PowerShell interactively....
Converting UNIX Time
Surprisingly, when you read some values from the Windows Registry, they do not seem to be in a readable format: $key =...
Chapter 1. The PowerShell Console
Welcome to PowerShell! This chapter will introduce you to the PowerShell console and show you how to configure it, including font colors and sizes,...