Monthly Archives: November 2018

Test if string contains numeric

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 … Continue reading

Posted in Powershell | 1 Comment

Reverse a string

I sort of brushed over it on my last post but this is how you reverse a string. function get-reversestring {   [CmdletBinding()]   param (     [string]$teststring   )   $ca = $teststring.ToCharArray()   [array]::Reverse($ca)   -join $ca } Take the input string … Continue reading

Posted in Powershell | Leave a comment

Test if a string is a palindrome

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 … Continue reading

Posted in Powershell | 4 Comments

Third way to find pairs for given sum

There’s a third way to find pairs for given sum that’s a bit more complicated. function get-pairs2 {   [CmdletBinding()]   param (     [int[]]$iarray,     [int]$value   )        $sarray = $iarray | Sort-Object   Write-Information -MessageData “Array: $iarray” -InformationAction Continue   Write-Information -MessageData … Continue reading

Posted in Powershell | Leave a comment

A more elegant way to find pairs

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 … Continue reading

Posted in Powershell | Leave a comment

Find pairs that give required sum

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 … Continue reading

Posted in Powershell | Leave a comment

Moving FSMO roles in PowerShell v6.1.1

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 … Continue reading

Posted in PowerShell and Active Directory, PowerShell v6 | 2 Comments