Zum Inhalt

GetPowerShellResult (Opus Funktion)

Beschreibung

Führt ein Powershellscript aus und gibt ein Objekt mit resultierenden Daten zurück.

Diese Funktion benötigt mindestens PoweShell 3.0.

Argumente

NameTypBeschreibung
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

xxx

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