Monthly Archives: December 2018

PowerShell articles

Here’s some links for other PowerShell articles I’ve written recently Enjoy

Posted in Powershell | Leave a comment

Change file times

When a file is created, accessed or modified that time is recorded. This is how to change file times. There are three properties to consider: CreationTime LastAccessTime LastWriteTime Just to add to the fun there are UTC (GMT in real … Continue reading

Posted in Powershell | 1 Comment

Get first non-repeating character in a string

How do you get first non-repeating character in a string. In Windows PowerShell v5.1 you could use Group-Object but as I showed last time that approach has been taken away in PowerShell v6.1. Instead you need to loop through the … Continue reading

Posted in Powershell | 1 Comment

Group-Object change in PowerShell v6.1

There’s a subtle Group-Object change in PowerShell v6.1. In PowerShell v5.1 if you do this: $ts = ‘ffrluoluntlvxutxbdvbktgyyvsvcrkxoyfotzkzogcwuwycmnhuedk’ $ts.ToCharArray() | group You get this: Count Name                      Group —– —-                      —–     3 f                         {f, f, f}     2 r                         {r, … Continue reading

Posted in PowerShell v5, PowerShell v6 | Leave a comment

Counting vowels

If you’re given a string how would you go about counting vowels, consonants  and non-alphabet characters. My approach would be: function measure-vowel {   [CmdletBinding()]   param (     [string]$teststring   )   $counts = [ordered]@{      Vowels      = 0      Consonants  = 0      NonAlphabet = … Continue reading

Posted in Powershell | 2 Comments

Create a random string

I often need to create a random string of characters. Here’s a simple function to achieve that: function get-randomstring {   [CmdletBinding()]   param (     [int]$length   )   $rca = 1..$length |   foreach {     $ran = Get-Random -Minimum 97 -Maximum 123     [char][byte]$ran   … Continue reading

Posted in Powershell | 2 Comments

Return of the missing PSDiagnostics

Return of the missing PSDiagnostics members in PowerShell v6.2 preview 3. In Windows PowerShell v5.1 the PSDiagnostics module contains these members: Disable-PSTrace Disable-PSWSManCombinedTrace Disable-WSManTrace Enable-PSTrace Enable-PSWSManCombinedTrace Enable-WSManTrace Get-LogProperties Set-LogProperties Start-Trace Stop-Trace In PowerShell v6.1.1 you just get these: Disable-PSTrace Enable-PSTrace … Continue reading

Posted in PowerShell v6 | Leave a comment