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 = ‘qwertyuiop’ Test if it has […]
Archive for November, 2018
Test if string contains numeric
Posted by: richardsiddaway | November 30, 2018 Comments Off on Test if string contains numeric |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 and turn it into an array of chars. Use the reverse static method of the array […]
Test if a string is a palindrome
Posted by: richardsiddaway | November 28, 2018 Comments Off on 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 in a string is a palindrome. A palindrome is a list of characters that […]
Third way to find pairs for given sum
Posted by: richardsiddaway | November 27, 2018 Comments Off on 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 “Sorted Array: $sarray” -InformationAction Continue Write-Information -MessageData “Sum: $value” -InformationAction Continue $left = 0 $right = $sarray.Count – […]
A more elegant way to find pairs
Posted by: richardsiddaway | November 26, 2018 Comments Off on 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 ( [int[]]$iarray, [int]$value ) Write-Information -MessageData “Array: $iarray” -InformationAction Continue Write-Information -MessageData “Sum: $value” […]
Find pairs that give required sum
Posted by: richardsiddaway | November 25, 2018 Comments Off on 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 with my favourite technique – brute force. function get-pairs { [CmdletBinding()] param ( [int[]]$iarray, […]
Moving FSMO roles in PowerShell v6.1.1
Posted by: richardsiddaway | November 22, 2018 Comments Off on 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 the Windows 10 October 2018 update that the AD module worked in PowerShell v6.1.1. I […]
Active Directory cmdlets in PowerShell v6.1.1
Posted by: richardsiddaway | November 16, 2018 Comments Off on 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 means that you can easily install the AD tools: Add-WindowsCapability -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0 –Online […]
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’ $carray -join ‘,’ [array]::Reverse($carray) $carray -join ‘,’ $iarray = 1,2,3,4,5,6,8,9,10 “$iarray” [array]::Reverse($iarray) “$iarray” […]
Hyper-V book now available
Posted by: richardsiddaway | November 7, 2018 Comments Off on 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 on 25 December 2018 – Happy Christmas
Categories
- .NET
- Active Directory
- Architecture
- Azure
- Bash
- BITS
- Books
- CDXML
- CIM
- Cloud
- COM
- Containers
- Deep Dive
- Desired State Configuration
- DevOps
- DHCP
- DNS
- DSC
- European Summit
- Events
- Exchange
- File System
- Firewall
- General
- General IT Matters
- Hyper-V
- IIS
- Infrastructure
- IT Community
- IT Security
- Learning PowerShell
- Linux
- Math
- Microsoft
- Modules
- Nano Server
- Networking
- Office 2010
- Office 2013
- Open Source
- Opinion
- Outlook
- Philosophy
- PowerShell
- PowerShell 7
- PowerShell and .NET
- PowerShell and Active Directory
- PowerShell and CIM
- PowerShell and Exchange 2007
- PowerShell and IIS
- PowerShell and SQL Server
- PowerShell and WMI
- PowerShell Basics
- PowerShell original
- PowerShell Summit
- PowerShell User Group
- PowerShell User Group 2
- PowerShell v2
- PowerShell V3
- PowerShell v4
- PowerShell v5
- PowerShell v6
- PowerShell.org
- PowerShellGet
- PowerShellV2
- PSAM
- Rant
- Registry
- Scripting
- Scripting Games
- Scripting Games 2104
- Security
- SQL Server
- Storage
- Strings
- Summit
- Technology
- Uncategorized
- Virtualization
- Windows 10
- Windows 2012 R2
- Windows 7
- Windows 8
- Windows 8 Server
- Windows 8.1
- Windows Server
- Windows server 1709
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows Server 2019
- WMFv5
- WPF
- WSUS