Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
  • Loading branch information
episource committed Nov 1, 2018
1 parent 3e636e7 commit bbc4274
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
@@ -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

0 comments on commit bbc4274

Please sign in to comment.