Saturday, June 3, 2017

Import-Module Uses Old Version of Module When Running in Powershell ISE or May the Force Be With You

A little tip for those that are debugging and executing scripts.  If you are calling Import-Module always use -Force on the end so it will force the script to reload during your session.

Import-Module c:\myscript.ps1m -Force

This will save you a lot of headaches during debugging and troubleshooting. For performance reasons, if you wanted to do this only when in the ISE you could wrap it in an if and use a function like this to check if you are in the ISE:

function Test-IsISE {
# try...catch accounts for:
# Set-StrictMode -Version latest
    try {  
        return $psISE -ne $null;
    }
    catch {
        return $false;
    }
}

I found this snippet on stackoverflow

Monday, May 1, 2017

Windows Powershell for Automation

Whether it is automated unit testing or automated tasks, Windows Powershell is the right script for you.  Even products like Episerver and Sitecore have Extensions for it.  You can extend it yourself simply by loading assemblies.

You can also run Powershell Scripts from your custom applications.  Are you struggling with Powershell, email me at chris.williams@readwatchcreate.com and I will see if I can assist.