Advertisement
Old-Lost

Get and Set module private data

Jun 8th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Set-Private {
  2.     [CmdletBinding()]
  3.     param (
  4.         [Parameter(Mandatory, Position = 0)][string]$Name,
  5.         [Parameter(Mandatory, Position = 1)][AllowEmptyCollection()][AllowEmptyString()][AllowNull()] [System.Object]$Value
  6.     )
  7.     $MyInvocation.MyCommand.Module.PrivateData[$Name] = $Value
  8. }
  9. function Get-Private {
  10.     [CmdletBinding()]
  11.     param (
  12.         [Parameter(Mandatory, Position = 0)] [string]$Name
  13.     )
  14.     Write-Output $MyInvocation.MyCommand.Module.PrivateData[$Name] -NoEnumerate
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement