|
| 1 | +# |
| 2 | +# WaitForAny |
| 3 | +# |
| 4 | + |
| 5 | +# |
| 6 | +# The Get-TargetResource cmdlet. |
| 7 | +# |
| 8 | +function Get-TargetResource |
| 9 | +{ |
| 10 | + param |
| 11 | + ( |
| 12 | + [parameter(Mandatory)] |
| 13 | + [ValidateNotNullOrEmpty()] |
| 14 | + [string[]] $NodeName, |
| 15 | + |
| 16 | + [parameter(Mandatory)] |
| 17 | + [ValidateNotNullOrEmpty()] |
| 18 | + [PSCredential] $Credential, |
| 19 | + |
| 20 | + [ValidateRange(1,[Uint64]::MaxValue)] |
| 21 | + [Uint64] $RetryIntervalSec = 1, |
| 22 | + |
| 23 | + [Uint32] $RetryCount = 0, |
| 24 | + |
| 25 | + [Uint32] $ThrottleLimit = 32 #Powershell New-CimSession default throttle value |
| 26 | + ) |
| 27 | + |
| 28 | + Write-Verbose "In Get-TargetResource" |
| 29 | + |
| 30 | + Import-Module $PSScriptRoot\..\..\PSDSCxMachine.psm1 |
| 31 | + |
| 32 | + $b = @{"hash" = "table"} |
| 33 | + |
| 34 | + if ($true) |
| 35 | + { |
| 36 | + return $b; |
| 37 | + } |
| 38 | + elseif ($c) |
| 39 | + { |
| 40 | + return @{"hash2"="table2"} |
| 41 | + } |
| 42 | + else |
| 43 | + { |
| 44 | + # can't determine type of c so error should not be raised as we're trying to be conservative |
| 45 | + return $c; |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +# |
| 50 | +# The Set-TargetResource cmdlet. |
| 51 | +# |
| 52 | +function Set-TargetResource |
| 53 | +{ |
| 54 | + param |
| 55 | + ( |
| 56 | + [parameter(Mandatory)] |
| 57 | + [ValidateNotNullOrEmpty()] |
| 58 | + [string] $ResourceName, |
| 59 | + |
| 60 | + [parameter(Mandatory)] |
| 61 | + [ValidateNotNullOrEmpty()] |
| 62 | + [string[]] $NodeName, |
| 63 | + |
| 64 | + [parameter(Mandatory)] |
| 65 | + [ValidateNotNullOrEmpty()] |
| 66 | + [PSCredential] $Credential, |
| 67 | + |
| 68 | + [ValidateRange(1,[Uint64]::MaxValue)] |
| 69 | + [Uint64] $RetryIntervalSec = 1, |
| 70 | + |
| 71 | + [Uint32] $RetryCount = 0, |
| 72 | + |
| 73 | + [Uint32] $ThrottleLimit = 32 #Powershell New-CimSession default throttle value |
| 74 | + ) |
| 75 | + |
| 76 | + Write-Verbose "In Set-TargetResource" |
| 77 | + |
| 78 | + Import-Module $PSScriptRoot\..\..\PSDSCxMachine.psm1 |
| 79 | + |
| 80 | + if ($PSBoundParameters["Verbose"]) |
| 81 | + { |
| 82 | + Write-Verbose "Calling xMachine with Verbose parameter" |
| 83 | + |
| 84 | + PSDSCxMachine\Set-_InternalPSDscXMachineTR ` |
| 85 | + -RemoteResourceId $ResourceName ` |
| 86 | + -RemoteMachine $NodeName ` |
| 87 | + -RemoteCredential $Credential ` |
| 88 | + -MinimalNumberOfMachineInState 1 ` |
| 89 | + -RetryIntervalSec $RetryIntervalSec ` |
| 90 | + -RetryCount $RetryCount ` |
| 91 | + -ThrottleLimit $ThrottleLimit ` |
| 92 | + -Verbose |
| 93 | + } |
| 94 | + else |
| 95 | + { |
| 96 | + PSDSCxMachine\Set-_InternalPSDscXMachineTR ` |
| 97 | + -RemoteResourceId $ResourceName ` |
| 98 | + -RemoteMachine $NodeName ` |
| 99 | + -RemoteCredential $Credential ` |
| 100 | + -MinimalNumberOfMachineInState 1 ` |
| 101 | + -RetryIntervalSec $RetryIntervalSec ` |
| 102 | + -RetryCount $RetryCount ` |
| 103 | + -ThrottleLimit $ThrottleLimit |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +# |
| 108 | +# Test-TargetResource |
| 109 | +# |
| 110 | +# |
| 111 | +function Test-TargetResource |
| 112 | +{ |
| 113 | + param |
| 114 | + ( |
| 115 | + [parameter(Mandatory)] |
| 116 | + [ValidateNotNullOrEmpty()] |
| 117 | + [string] $ResourceName, |
| 118 | + |
| 119 | + [parameter(Mandatory)] |
| 120 | + [ValidateNotNullOrEmpty()] |
| 121 | + [string[]] $NodeName, |
| 122 | + |
| 123 | + [parameter(Mandatory)] |
| 124 | + [ValidateNotNullOrEmpty()] |
| 125 | + [PSCredential] $Credential, |
| 126 | + |
| 127 | + [ValidateRange(1,[Uint64]::MaxValue)] |
| 128 | + [Uint64] $RetryIntervalSec = 1, |
| 129 | + |
| 130 | + [Uint32] $RetryCount = 0, |
| 131 | + |
| 132 | + [Uint32] $ThrottleLimit = 32 #Powershell New-CimSession default throttle value |
| 133 | + ) |
| 134 | + |
| 135 | + Write-Verbose "In Test-TargetResource" |
| 136 | + |
| 137 | + Import-Module $PSScriptRoot\..\..\PSDSCxMachine.psm1 |
| 138 | + |
| 139 | + $a = $true |
| 140 | + $a |
| 141 | + |
| 142 | + if ($true) |
| 143 | + { |
| 144 | + $false; |
| 145 | + } |
| 146 | + elseif ($b) |
| 147 | + { |
| 148 | + return $a -or $true |
| 149 | + } |
| 150 | + elseif ($c) |
| 151 | + { |
| 152 | + return $false; |
| 153 | + } |
| 154 | + else |
| 155 | + { |
| 156 | + return $true |
| 157 | + } |
| 158 | +} |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | +Export-ModuleMember -Function *-TargetResource |
0 commit comments