Skip to content

Import preference variables from the caller of a powershell module script.

License

Notifications You must be signed in to change notification settings

episource/import-callerpreference

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

About

Import preference variables from the caller of a powershell module script. This was inspired by The Scripting Guys. Their blog also provides a good overview of the topic and its background.

Quickstart

At the beginning of your powershell module script function invoke Import-CallerPreference:

Import-Module import-callerpreference
#
function Receive-PreferencesExample {
    [CmdletBinding()]
    Param()
    
    Import-CallerPreference
    #
}

In-Depth

Import-CallerPreference copies the following proference variables from the caller's scope into the current scope:

  • ConfirmPreference
  • DebugPreference
  • ErrorActionPreference
  • ErrorView
  • FormatEnumerationLimit
  • InformationPreference
  • LogCommandHealthEvent
  • LogCommandLifecycleEvent
  • LogEngineHealthEvent
  • LogEngineLifecycleEvent
  • LogProviderLifecycleEvent
  • LogProviderHealthEvent
  • OFS
  • OutputEncoding
  • ProgressPreference
  • PSDefaultParameterValues
  • PSEmailServer
  • PSModuleAutoLoadingPreference
  • PSSessionApplicationName
  • PSSessionConfigurationName
  • PSSessionOption
  • VerbosePreference
  • WarningPreference
  • WhatIfPreference

About

Import preference variables from the caller of a powershell module script.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published