A simple script to create Windows PowerShell Module structure

As part of creating Windows PowerShell modules, I have recently created a script to create the structure required, as follows: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about … More A simple script to create Windows PowerShell Module structure

Generating log output using Windows PowerShell

I previously wrote a post in regards to streaming output to a log file synchronously in Windows PowerShell, which was required for a specific reason to lock the file during the script invocation and event message generation. I have since created an advanced function to provide the ability to generate event messages to the console and/or a log file … More Generating log output using Windows PowerShell

Inheriting Verbose Preference in Windows PowerShell Module Functions

When specifying verbose preference this will only be inherited by the scripts module functions, if specified in the global scope. However, it is possible to use an advanced function to access the variable preference using the ‘$PSCmdlet.GetVariableValue()’ method to access the SessionState object and inherit the preference value. This file contains hidden or bidirectional Unicode text … More Inheriting Verbose Preference in Windows PowerShell Module Functions

PowerShell and retrieving environment variables from a content file

I was recently creating a Windows PowerShell script which retrieved content from a JSON-formatted file containing configuration information to be used as variables. A number of  configuration values contained an evironment variable for the user profile of the current user. When retrieving the value the string would be returned as a string and not the dynamic … More PowerShell and retrieving environment variables from a content file

Windows PowerShell Exit Codes, SSIS and the Environment.Exit Method

I was recently compiling a PowerShell script which would be integrated into a SSIS package, depending on the status of the script invocation this would return custom error codes to determine success or failure as part of the package. By default, I would generally use Try/Catch statements and provide and exit code. However, when invoking … More Windows PowerShell Exit Codes, SSIS and the Environment.Exit Method