Skip to content

Commit

Permalink
Update ModuleVariablesPOC.psm1
Browse files Browse the repository at this point in the history
  • Loading branch information
exactmike committed Oct 17, 2018
1 parent 90b02ff commit 770f94e
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions ModuleVariablesPOC.psm1
Expand Up @@ -48,37 +48,3 @@ function Remove-ModuleVariable
)
Remove-Variable -Scope Script -Name $name
}
function Get-FirstNonNullEmptyStringVariableValueFromScopeHierarchy
{
Param(
[string]$VariableName
,
[int]$ScopeLevels = 15
,
[int]$timeout = 500 #In Milliseconds
)
$scope = 0
$stopwatch = [Diagnostics.Stopwatch]::StartNew()
do
{
Try
{
$value = Get-Variable -Name $VariableName -ValueOnly -Scope $scope -ErrorAction SilentlyContinue
}
Catch
{
}
$scope++
}
until (-not [string]::IsNullOrWhiteSpace($value) -or $stopwatch.ElapsedMilliseconds -ge $timeout -or $scope -ge $ScopeLevels)
$value
}
#end function Get-FirstNonNullEmptyStringVariableValueFromScopeHierarchy
###############################################################################################
function Test-WriteLog
{
#test if an outside function called within a module function can see the module variable.
#Yes, it can. Of course, after thinking about it, just like you can use any external to a module powershell command within your module.
Write-Log -Message $MyIntVariable -Verbose
}
Export-ModuleMember -Variable MyIntVariable

0 comments on commit 770f94e

Please sign in to comment.