header image

Archive for October, 2018

Find a missing integer–alternative solution

Posted by: | October 31, 2018 Comments Off on Find a missing integer–alternative solution |

In my recent post about finding a missing integer in an array of numbers I didn’t spell out the assumptions. In this post I’ll explain those assumptions and show you how to Find a missing integer–alternative solution. The assumptions were: The sequence of numbers in the array starts at 1 The values increment by 1 […]

under: PowerShell

Finding and removing duplicates

Posted by: | October 29, 2018 Comments Off on Finding and removing duplicates |

Continuing the thoughts about techniques for dealing with integer arrays – this is how to go about finding and removing duplicates from the array. First – to find any duplicates use Group-Object function get-duplicate { [CmdletBinding()] param ( [int[]]$iarray ) $iarray | Group-Object | where Count -gt 1 | foreach { New-Object -TypeName PSobject -Property […]

under: PowerShell

Find a missing integer

Posted by: | October 25, 2018 Comments Off on Find a missing integer |

I stumbled across a set of programmer interview questions recently. They raised some interesting problems that I thought would be fun to show a PowerShell answer. This is the first of them – find a missing integer in an array. Consider an array of integers. It should have 10 members: $iarray = 1,2,3,4,5,6,7,8,9,10   But […]

under: PowerShell

Managing errors

Posted by: | October 22, 2018 Comments Off on Managing errors |

If you try to do a directory listing through C:\Windows\system32 you’ll get some access denied errors. I’m going to show you how to do this while managing errors that arise. The code will also highlight a few of the PowerShell error handling techniques.   $epath2 = $null Get-ChildItem -Path C:\Windows\System32 -Recurse -Force -Directory -ErrorVariable epath2 […]

under: PowerShell

Test-Connection cmdlet

Posted by: | October 21, 2018 Comments Off on Test-Connection cmdlet |

The Test-Connection cmdlet wasn’t included in PowerShell v6.0 but did make a come back in v6.1.   The v6.1 version of Test-Connection has some serious issues as I’ve described before.   Work is being done at the moment to remedy those issues – hopefully for v6.2   This is your chance to comment on a cmdlet […]

under: PowerShell v6

DevOps team structures

Posted by: | October 19, 2018 Comments Off on DevOps team structures |

DevOps has never really excited me and I never understood why until I read about DevOps team structures – https://web.devopstopologies.com/ The article suggests 7 bad practices or ‘anti-types: Dev and Ops Silos DevOps Team Silo Dev doesn’t need Ops DevOps as tools team Rebranded administrators Ops embedded in dev team Dev and DBA silos   […]

under: DevOps

PowerShell v6.2 preview 1

Posted by: | October 18, 2018 Comments Off on PowerShell v6.2 preview 1 |

PowerShell v6.2 preview 1 quietly appeared yesterday – https://github.com/PowerShell/PowerShell/releases No major breaking changes.   New features include: Type accelerators for unsigned integers Support for cd+ Test-ModuleManifest update to correctly populate nested modules Set-Service –status stopped will also stop dependencies   The Test-Connection and –workingdirectory issues are still unresolved.   There’s nothing earth shattering in the updates but […]

under: PowerShell v6

PowerShell v6.1 working directory

Posted by: | October 18, 2018 Comments Off on PowerShell v6.1 working directory |

PowerShell v6.1 introduced a very annoying change in that a –workingdirectory parameter was added to pwsh.exe. When you install v6.1 working directory is automatically set to ~ which is your home folder. The workingdirectory doesn’t play nice with your profile. In my profile I set the location to C:\scripts where I keep my work in […]

under: PowerShell v6

PowerShell approved verbs

Posted by: | October 17, 2018 Comments Off on PowerShell approved verbs |

PowerShell uses a verb-noun style for naming cmdlets. The list of Powershell approved verbs is available at https://docs.microsoft.com/en-us/powershell/developer/cmdlet/approved-verbs-for-windows-powershell-commands.   You should use the approved verbs when writing functions or cmdlets. Import-Module will complain about using unapproved verbs.   You can also see the list of approved verbs using Get-Verb.   There’s also a set of […]

under: PowerShell

Running Ping tests

Posted by: | October 16, 2018 Comments Off on Running Ping tests |

I’ve shown how to discover network information using the get-internetconnection function and how to construct simple Pester tests to ping the IP addresses returned by get-internetconnection. This time I’ll show you how to create a control function for running ping tests. In fact the control script could be used to run any set of tests […]

under: PowerShell

Older Posts »