PowerShell for Windows Admins:

November, 2018


November 30, 2018  6:00 AM

Test if string contains numeric

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

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

November 29, 2018  1:01 PM

Reverse a string

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

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


November 28, 2018  1:49 PM

Test if a string is a palindrome

Tom Curtin Tom Curtin Profile: Tom Curtin
Powershell, PowerShell Scripts, String

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


November 27, 2018  6:44 AM

Third way to find pairs for given sum

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

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


November 26, 2018  9:11 AM

A more elegant way to find pairs

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

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


November 25, 2018  8:33 AM

Find pairs that give required sum

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

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


November 22, 2018  7:19 AM

Moving FSMO roles in PowerShell v6.1.1

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Active Directory, Powershell

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


November 16, 2018  9:40 AM

Active Directory cmdlets in PowerShell v6.1.1

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Active Directory, 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...


November 8, 2018  7:02 AM

Reverse an array

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

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


November 7, 2018  6:54 AM

Hyper-V book now available

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Hyper-V

My Hyper-V book now available.   Ebook direct from the publisher: 0 Comments     RSS Feed     Email a friend


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: