functions/utility/Set-PSFDynamicContentObject.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function Set-PSFDynamicContentObject
{
<#
    .SYNOPSIS
        Updates a value object that can easily be accessed on another runspace.
     
    .DESCRIPTION
        Updates a value object that can easily be accessed on another runspace.
     
        The Dynamic Content Object system allows the user to easily have the content of a variable updated in the background.
        The update is performed by this very function.
     
    .PARAMETER Name
        The name of the value to update.
        Not case sensitive.
     
    .PARAMETER Object
        The value object to update
     
    .PARAMETER Value
        The value to apply
     
    .EXAMPLE
        PS C:\> Set-PSFDynamicContentObject -Name Test -Value $Value
     
        Sets the Dynamic Content Object named "test" to the value $Value.
#>

    [CmdletBinding()]
    Param (
        [string[]]
        $Name,
        
        [Parameter(ValueFromPipeline = $true)]
        [PSFramework.Utility.DynamicContentObject[]]
        $Object,
        
        [Parameter(Mandatory = $true)]
        [AllowNull()]
        $Value
    )
    
    begin
    {
        
    }
    process
    {
        foreach ($item in $Name)
        {
            [PSFramework.Utility.DynamicContentObject]::Set($item, $Value)
        }
        
        foreach ($item in $Object)
        {
            $item.Value = $Value
        }
    }
    end
    {
    
    }
}