Zum Inhalt

GetPowerShellResult (Opus Funktion)

Beschreibung

Führt ein Powershellscript aus und gibt ein Objekt mit resultierenden Daten zurück. Executes a PowerShell script and parses its JSON output into an Opus object. Returns an empty object if the script produces no output.

Diese Funktion benötigt mindestens PowerShell 3.0.

Argumente

Name

Typ

Beschreibung

PowerShellScript

string

Powershell Script.

Das Resultat der letzten Anweisung wird als Objekt zurückgegeben.

Die letzte Anweisung kann zum Beispiel eine "Get-***" Funktion sein.

Get-Variable **Name**

Rückgabewert Object

an Opus object built from the JSON output of the PowerShell script

Beispiel

Lo_Result = GetPowerShellResult(PS = R"(
try { $mailSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http:/)" + R"(/server.xyz.ch/PowerShell/set} catch {}
try { Import-PsSession $mailSession } catch {}
try {$Mail = Get-MailContact -Identity )" + Lo_Address.s_EmailB + R"( } catch {}
if (-not $Mail) { try {$Mail = Get-MailBox -Identity )" + Lo_Address.s_EmailB + R"( } catch {} }
Get-Variable Mail)");

Siehe auch