Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# About | ||
Import preference variables from the caller of a powershell module script. This was inspired by [The Scripting Guys](https://blogs.technet.microsoft.com/heyscriptingguy/2014/04/26/weekend-scripter-access-powershell-preference-variables/). [Their blog](https://blogs.technet.microsoft.com/heyscriptingguy/2014/04/26/weekend-scripter-access-powershell-preference-variables/) also provides a good overview of the topic and its background. | ||
|
||
# Quickstart | ||
At the beginning of your powershell module script function invoke `Import-CallerPreference`: | ||
|
||
```posh | ||
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 |