Powershell

Finding Numbers in Text

Regular Expressions are a great help in identifying and extracting data from text. Here's an example that finds and extracts a number that ends...

read more

Making Names Unique

To make a list of items or names unique, you could use grouping and then, when a group has more than one item, append a numbered suffix to these...

read more

Counting Log Activity

Did you know that Group-Object can analyze text-based log files for you? Here's sample code that tells you how many log entries on a given day a...

read more

Shrinking Paths

Many file-related .NET Framework methods fail when the overall path length exceeds a certain length. Use low-level methods to convert lengthy paths...

read more

Converting to Signed

If you convert a hex number to a decimal, the result may not be what you want: PS> 0xFFFF 65535 PowerShell converts it to an unsigned number...

read more

Getting Timezones

Here's a low level call that returns all time zones: PS> [System.TimeZoneInfo]::GetSystemTimeZones() Id : Dateline Standard Time DisplayName...

read more

Mapping Printers

To map a network printer to a user profile, here's a powerful low level command: rundll32 printui.dll,PrintUIEntry /in /n...

read more

Fun with Date and Time

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...

read more

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...

read more

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...

read more

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 (...

read more

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]$_ }...

read more

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 {...

read more

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...

read more

Converting UNIX Time

Surprisingly, when you read some values from the Windows Registry, they do not seem to be in a readable format: $key =...

read more
1 92 93 94 95 96 130