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

Active Directory cmdlets in PowerShell v6.1.1

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

Posted in PowerShell and Active Directory, PowerShell v6 | 1 Comment

Reverse an array

Ever needed to reverse an array? If its 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 = ‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’,’k’,’l’,’m’,’n’,’o’,’p’,’q’,’r’,’s’,’t’,’u’,’v’,’w’,’x’,’y’,’z’ … Continue reading

Posted in Powershell | Leave a comment

Hyper-V book now available

My Hyper-V book now available. Ebook direct from the publisher: https://www.apress.com/gb/book/9781484241158#otherversion=9781484241165 The Kindle version is on Amazon UK: https://www.amazon.co.uk/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=hyper-v+2019&rh=i%3Aaps%2Ck%3Ahyper-v+2019 Presumably other Amazon sites will follow soon The paper back version is on pre-order from Apress and Amazon to be available … Continue reading

Posted in Hyper-V | 1 Comment