lib/TMD.PowerShell.ps1
function Test-TMDIsRunningAction { $Global:TmdRunningAction ?? $false } Function Invoke-WindowsPowerShell { param( [Parameter(Mandatory = $true, ValueFromPipeline = $false, Position = 0)][PSObject]$Params, [Parameter(Mandatory = $true, ValueFromPipeline = $false, Position = 0)][scriptblock]$ScriptBlock ) $WpsSession = New-PSSession -ComputerName ($env:COMPUTERNAME + '.' + $env:USERDNSDOMAIN) -ConfigurationName TMD51 -EnableNetworkAccess -Authentication Kerberos $StdOut = Invoke-Command -ScriptBlock $ScriptBlock -Session $WpsSession -ArgumentList $Params if ($null -ne $StdOut) { $ReturnObjects = $StdOut | Select-Object -Last 1 | ConvertFrom-Json -Depth 100 ## Create each of the items as a Variable object with the name foreach ($obj in $ReturnObjects.PSObject.Properties) { New-Variable -Name $obj.Name -Value $obj.Value -Force -Scope Global # $obj } } } |