none
remote ausführen von powershell dauert wesentlich länger wie lokal RRS feed

  • Allgemeine Diskussion

  • Hallo Community,

    ich habe ein vermutlich interessantes Konstrukt. Ich habe ein C#-Programm, welches wie folgt aussieht:

    string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    
    PowerShell ps = PowerShell.Create();
    ps.AddScript("Invoke-Command -Computer host1 -ScriptBlock { C:\\path1\\path22\\script.ps1 " + userName + " }");
    ps.BeginInvoke(); //asynch job
    ps.AddScript("Invoke-Command -Computer host2  -ScriptBlock { C:\\path1\\path2\\script.ps1 " + userName + " }");
    ps.Invoke();
    

    Wie ihr sehen könnt, habe ich schon ein bisschen mit BeginInvoke versucht eine gewisse Parallelität zu erzeugen.

    Interessant ist aber folgendes, wenn ich die Script ohne dem Programm remote ausführe, dauert es auch ewig. Wenn ich das script (script.ps1) einfach lokal ausführe, ist es in paar Sekunden durchgeführt.

    (Ich habe mitgemessen, für beide Scripts benötige ich aktuell 1:35min)

    Weiß hier jemand was? bzw. kann mir Tipps geben?

    Das script.ps1 sieht so aus:

    Add-PSSnapin Citrix.XenApp.CommandsGet-XASession -Account $args[0] | Get-XaSessionProcess | ? { $_.ProcessName -like "*something*" } | Stop-XASessionProcess
    Danke!

    Donnerstag, 15. Mai 2014 08:34

Alle Antworten