PoshCode Archive  Artifact [597e778202]

Artifact 597e778202fd182791f2247d12d1731409b2f01498af884fa17c2dc7b25c6b71:

  • File Get-StrictMode-psm1.ps1 — part of check-in [f995f65521] at 2018-06-10 13:20:51 on branch trunk — Retrieve the Set-StrictMode session setting. Use as a Module (psm1) and expose any of the user’s settings, but the ‘latest’ parameter cannot be retrieved at present. (user: Archdeacon size: 1131)

# encoding: ascii
# api: powershell
# title: Get-StrictMode.psm1
# description: Retrieve the Set-StrictMode session setting. Use as a Module (psm1) and expose any of the user’s settings, but the ‘latest’ parameter cannot be retrieved at present.
# version: 0.1
# type: module
# author: Archdeacon
# license: CC0
# function: Get-StrictMode
# x-poshcode-id: 3136
# x-archived: 2017-05-18T12:39:04
# x-published: 2012-12-31T00:45:00
#
#
<#
.SYNOPSIS
 A very simple module to retrieve the Set-StrictMode setting of the session.
.DESCRIPTION
This procedure is necessary as there is, apparently, no PowerShell variable 
for this and enables the user setting to be returned to its original state 
after possibly being changed within a script.
The various values returned will be Version 1, Version 2, or Off.
#>
function Get-StrictMode {
   try {
      $version = '2'
      $z = "2 * $nil"       #V2 will catch this one.
      $version = '1'
      $z = 2 * $nil         #V1 will catch this.
      Write-Host "StrictMode: Off"
   }
   catch {
      Write-Host "StrictMode: Version $version"
   }
}