Monthly Archives: August 2018

PowerShell string contains

How can you check if a PowerShell string contains a character or substring? You might be tempted to try this: PS> $s = ‘abcdefghijk’ PS> $s -contains ‘f’ False But –contains is for working with the contents of arrays. So … Continue reading

Posted in Powershell | 1 Comment

PowerShell Day UK Agenda Update

There’s been a Powershell Day UK Agenda Update. Looks like there’ll be three tracks for most of the day. Full agenda and tickets from – https://psday.uk/

Posted in Powershell | Leave a comment

PowerShell v6.1– using PowerShell v5.1 modules

Something new to be aware of in PowerShell v6.1– using PowerShell v5.1 modules . In PowerShell v6.0.4 the default module path is PS>  $env:PSModulePath -split ‘;’ C:\Users\Richard\Documents\PowerShell\Modules C:\Program Files\PowerShell\Modules c:\program files\powershell\6.0.4\Modules If you want to use the netadapter cmdlets for … Continue reading

Posted in PowerShell v6 | Leave a comment

PowerShell v6.1 release candidate 1

PowerShell v6.1 release candidate 1 is now available from https://github.com/PowerShell/PowerShell/releases The release notes don’t show any major new functionality compared to preview 4 though there are a number of minor updates, changes and bug fixes.

Posted in PowerShell v6 | Leave a comment

Deleting folders based on month name

An interesting problem around deleting folders based on month name. You have a folder structure that looks like this C:\Testdata\2011\08-Aug C:\Testdata\2011\09-Sep C:\Testdata\2011\10-Oct C:\Testdata\2011\11-Nov C:\Testdata\2011\12-Dec C:\Testdata\2012\01-Jan C:\Testdata\2012\02-Feb C:\Testdata\2012\03-Mar C:\Testdata\2012\04-Apr C:\Testdata\2012\05-May C:\Testdata\2012\06-Jun C:\Testdata\2012\07-Jul C:\Testdata\2012\08-Aug C:\Testdata\2012\09-Sep C:\Testdata\2012\10-Oct C:\Testdata\2012\11-Nov C:\Testdata\2012\12-Dec C:\Testdata\2013\01-Jan C:\Testdata\2013\02-Feb C:\Testdata\2013\03-Mar C:\Testdata\2013\04-Apr … Continue reading

Posted in Powershell | Leave a comment

File searches with WMI

I saw a question about file searches with WMI. If you just know the file name it’s a very slow process. Painfully slow. If you have an idea about the folder its much quicker. function get-wmifile { [CmdletBinding()] param (   … Continue reading

Posted in PowerShell and CIM, PowerShell and WMI | Leave a comment

Variable type

Usually when you create a variable you implicitly set the type by the value you use. Sometimes though you may want to explicitly set the variable type. if you don’t give the variable a type you can do this: PS> … Continue reading

Posted in Powershell | Leave a comment