PowerShell for Windows Admins:

November, 2018

How can you test if a string contains a numeric character?
The simple answer is to use a regular expression. If you’ve been reading my stuff for any length of time you’ll know how much I love regular expressions. This is a simple regex.
Create a string
PS> $s1 =...

I sort of brushed over it on my last post but this is how you reverse a string.
The code is at https://github.com/RichardSiddaway/Blogcode/blob/master/stringtechniques.ps1
Take the input string and turn it into an array of chars. Use the reverse static method of the array class to reverse the...

This is the first in a short series in which I’ll look at some string handling techniques. PowerShell is all about objects but sometimes you just have to work with the basics. In this post I’ll show how to test in a string is a palindrome.
A palindrome is a list of characters that read the...

Last time I showed a brute force way to find the pairs of numbers in an array that would sum to a given value. This time I have a more elegant way to find pairs.
function get-pairs1 {
[CmdletBinding()]
param (
[int[]]$iarray,
[int]$value
)
Write-Information -MessageData...

If you have an array of integers how do you find pairs that give required sum. In other words which pairs of numbers add up to a given value.
There are a number of ways to solve this. Lets start with my favourite technique – brute force.
function get-pairs...

With the Windows Server 2019 media now being available again it’s time to move my test lab over to the new version. I’d built a Windows Server 2019 VM and installed PowerShell v6.1.1. I discovered that in Server 2019 and the Windows 10 October 2018 update that the AD module worked in PowerShell...

Just discovered that you can run the Active Directory cmdlets in PowerShell v6.1.1 BUT there is a huge caveat.
The Windows 10 October 2018 (Windows 10 1809) update includes the RSAT tools (including the AD tools) as optional features. This means that you can easily install the AD...

Ever needed to reverse an array?
If it's sorted then sorting in the opposite direction will work. Most arrays aren’t sorted so you need to use the Reverse static method of the array class
Here’s some examples:
$carray =...

About This Blog

A blog for Windows administrators, Architects, Consultants and System Integrators maximizing the use of PowerShell and WMI. Simple solutions to everyday problems using two tools that should be available on every Windows system. Save time, save effort, script now!