functions/private/Get-JobVariable.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function Get-JobVariable {
    [cmdletbinding()]
    param(
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string] $Id
    )
    if((Get-Variable -Name SMBInstances -Scope Global -ErrorAction SilentlyContinue) -eq $null){
        $global:SMBInstances = [hashtable]::Synchronized(@{})
        
    }
    if(!$Id){
        $Id = [Guid]::NewGuid().ToString()
        $global:SMBInstances.Add($Id,[hashtable]::Synchronized(@{InstanceId=$Id;Root=$global:root}))
        $global:SMBInstances[$Id]
    } else {
        try{
            $global:SMBInstances[$Id]
            
        } catch {
            throw "SMBBluePrint Instance Id not found"
        }
    }
}