Quantcast
Channel: Windows PowerShell Forum
Viewing all 2314 articles
Browse latest View live

englische ausgabe in Powershell 4

$
0
0

Beispiel-Problem : Netstat listet die Stati in deutscher Sprache aus, z.B. "hergestellt" statt "connected". Will ich die Ausgabe mit einem generischen Script filtern, müsste ich bei den Rechner vorher mit Get-Culture den Ländercode abfragen und in einer Hashtabelle übersetzen lassen.

Gibt's da keine einfachere Lösung?


mfg Jürgen



File Watcher Events

$
0
0

Guten Morgen liebe Techniker,

 

dies ist jetzt nicht unbedingt ein Problem, ich wüsste aber doch gerne, wie ich das am besten ändern könnte.

 

Also wir wollen hier Daten abgleichen und das möglichst ohne, dass jemand etwas manuell starten muss. Dafür ist das Beobachten der Pfade durch den File System Watcher eigentlich ganz gut geeignet. Um verschiedene Daten z.B. auf die Homepage zu laden, wird NetDrive verwendet.

 

- Da das das Verschieben der Dateien nicht startet, wenn keine Datei erstellt wird, habe ich nach dem erstellen der Events noch eine Überprüfung eingebaut, die allerdings, auch wenn Daten verschoben (also an einem Ort entfernt) werden, keine Ausgabe der verschobenen Datei/en bringt. Kann man dies irgendwie ändern?

 

- Bei ein oder zwei Pfaden geht dies hier noch so. Wenn wir aber noch mehr Pfade hinzufügen müssen/wollen, müssen wir jedes Mal den Script-Block kopieren und die Daten ändern. Gibt es hier vielleicht eine Möglichkeit das Script so zu schreiben, dass source und destination als Array abgefragt und damit Events erstellt werden können?

 

Eine Rückmeldung wäre nett :)

 

Und hier das Script soweit:

# Multiple File System Watcher
# by: Me :)
# (c) 2014

# Error Handling
$ErrorActionPreference = "Stop" # Jede Exception ist ein Error
trap {
    Write-Host ("Fehler im Script: {0}" -f $_.Exception.Message) -F White -B Red ; continue
}

$filter = "*"
$srcDirs = @("C:\Files\","X:\datei\") 
$dstDirs = @("Z:\in\","\\srvbtn4\homepage\") 

# Eventuell Informationen ausgeben ??
Write-Host "Überwachte Pfade:`t"$srcDirs -F DarkGray
Write-Host "Ziel-Pfade:`t`t"$dstDirs -F DarkGray<# #### Watcher #### #><# ## Files ## #>

$watcher = New-Object System.IO.FileSystemWatcher -ArgumentList $srcDirs[0], $filter
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true

# Dateibewegung
$deleted = Register-ObjectEvent $watcher "Deleted" -Action {
    Write-Host (Get-Date -F "dd HH:mm:ss") -F Cyan -No
    Write-Host " Files" -F Magenta -No
    Write-Host ""$($eventArgs.Name) -F Yellow
}
# Datei erstellen
$created = Register-ObjectEvent $watcher "Created" -Action {
    Move-Item -Path ("{0}{1}" -f $srcDirs[0],"*.txt") -Dest $dstDirs[0]
}<# Existing Files when script starts? #>
If (Test-Path ("{0}{1}" -f $srcDirs[0],"*.txt")) {
    Write-Host "Files Daten bereits in Quelle vorhanden. Werden kopiert ..."
    Move-Item -Path ("{0}{1}" -f $srcDirs[0],"*.txt") -Dest $dstDirs[0]
    Write-Host "Done" -F Cyan
}<# ## Homepage ##>

$watcher = New-Object System.IO.FileSystemWatcher -ArgumentList $srcDirs[1], $filter
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true

# Dateibewegung
$deleted = Register-ObjectEvent $watcher "Deleted" -Action {
    Write-Host (Get-Date -F "dd hh:mm:ss") -F Cyan -No
    Write-Host " Homepage" -F Magenta -No
    Write-Host ""$($eventArgs.Name) -F Yellow
}

# Datei erstellen
$created = Register-ObjectEvent $watcher "Created" -Action {
    Move-Item -Path ("{0}{1}" -f $srcDirs[1],"*.csv") -Dest $dstDirs[1]
}<# Existing Files when script starts? #>
If (Test-Path ("{0}{1}" -f $srcDirs[1],"*.csv")) {
    Write-Host "Homepage Daten bereits in Quelle vorhanden. Werden kopiert ..."
    Move-Item -Path ("{0}{1}" -f $srcDirs[1],"*.csv") -Dest $dstDirs[1]
    Write-Host "Done" -F Cyan
}

# Script laufen lassen
Wait-Event



psexec remote lokale admingruppe auslesen

$
0
0

Hallo Nerds und Nerdeens,

weil es in letzter Zeit öfter zu Missbrauch von lokalen Adminrechten im Unternehmen gekommen ist wurde ich mit der Aufgabe betraut ein Script zu schreiben das die lokale Administratoren Gruppe auf allen Rechnern in der Domäne ausliest.

Da wir noch einige Windows XP Rechner im Einsatz haben ist wmi leider keine Lösung.
Ich habe nun schon einige Zeit zugebracht mit dem Versuch die Geschichte mit Hilfe von psexec zum laufen zu bekommen und habe nun folgendes Problem.
Das kuriose ist dass das Programm funktioniert wenn wenn ich die Befehle Zeile für Zeile in cmd bzw Powershell eingebe. Daher vermute ich, dass der Befehl irgendwie nicht ausgeführt wird auch wenn die Ausgabe auf der Kommandozeile gegenteiliges vermuten lässt

Es wird zwar eine Terminalverbindung zum Rechner aufgebaut aber das Script wird nicht ausgeführt. Es erscheint keine Fehlermeldung oder ähnliches.

Erst beim zurückkopieren des exportes kommt es zur Fehlermeldung da keine Datei gefunden werden konnte.

Der Programmablauf sieht so aus

$z1 = "c:\ava\pst\psexec.exe \\remotepc cmd.exe /c"
$z2 = "C:\AVA\LAS\script.bat"
$z3 = "net localgroup Administratoren>c:\windows\system32\admins.txt"


set-content C:\ava\LAS\rscript.bat $z1
add-content C:\ava\LAS\rscript.bat $z2
set-content C:\ava\LAS\script.bat $z3
#oben definierter code wurde in bats geschrieben

Copy-Item -path C:\ava\LAS\script.bat -destination \\remotepc\c$\Windows\System32\script.bat 
# net localgroup bat wurde auf remoterechner kopiert

start-process C:\AVA\LAS\rscript.bat
# bat mit psexec script wurde gestartet

Copy-Item \\cs1058\c$\Windows\System32\admins.txt C:\ava\LAS\
# export wird zurück kopiert

hat jemand von euch eine Idee, wo das Problem liegt oder einen anderen Lösungsansatz.

Problem mit mehrzeilen strings

$
0
0

Hallo Zusammen,

ich suche mir seit Stunden einen Wolf, aber irgendwie ist die passende Antwort nie dabei, oder ich bin nicht pfiffig genug diese zu erkennen (vermutlich letzteres). Worum es geht:

Auf einem SBS2011 verwende ich die Exchange Module um Mailboxitems auszulesen und weiter zu verarbeiten. Das klappt alles soweit einwandfrei.

Das Object der Mailbody sieht etwa so aus:

<send_mail>
<recipient>charliehotel</recipient>
<sender>charliehotel</sender>
<sender_phone>+49 123456</sender_phone>
<sender_mail>charliehotel@charliehotel.de</sender_mail>
<sender_subject>Diese Testmail mit zwei Zeilen</sender_subject>
<mailbody>das ist die 1. Zeile
das ist die 2. Zeile
</mailbody>
</send_mail>

Konzentrieren wir uns auf den Part des Scriptes:

=================================================================

   $arr_body = @{}
   $pattern_usradm_create = 'recipient', 'sender','sender_phone','sender_mail','sender_subject','mailbody'


   foreach($str_pattern in $pattern_usradm_create)
   {
    $str_pat = "<" + $str_pattern + ">(?<text>.*?)</" + $str_pattern + ">"
      
    if($mailbody -match $str_pat)
    {
     $arr_body.Add($str_pattern, $matches.text)
    }
   }
  
   $msg = New-Object -TypeName Microsoft.Exchange.WebServices.Data.EmailMessage -ArgumentList $service
   $str_nickname = $arr_body.recipient
   $str_mail = Get-ADObject -Filter {(mailNickname -like $str_nickname) -and (ObjectClass -eq "contact")} -properties mail

   $msg.Subject = $arr_body.sender_subject
   $str_body = "Diese Nachricht wurde &uuml;ber die Webseite blabla.de gesendet."
   $str_body = $str_body + "<br> Absender: " + $arr_body.sender
   $str_body = $str_body + "<br> Telefon: " + $arr_body.sender_phone
   $str_body = $str_body + "<br> Mail: " + $arr_body.sender_mail
   $str_body = $str_body + "<br>"
   $str_body = $str_body + "<br>" + $arr_body.mailbody


=============================================================================

Das Script funktioniert tadellos, bis auf eine kleine Stelle. Sobald der <mailbody> mehrere Zeilen enthält wird der über die -match Methode (ich hoffe es ist richtig, dass ich Methode gesagt habe) gefunden.

Eine Zeile funktioniert und der Text wird hinzugefügt. Mehrere Zeilen funktionieren nicht, der Text wird nicht mehr gefunden.

Ich habe die Add-Content & Write-Host Befehle der besseren Übersicht heraus genommen. Diese schreiben nur in eine Log-Datei und machen ein Bildschirmausgabe.

Wie bringe ich mein Powershellscript nun dazu über mehrere Zeilen das Ergebnis zu liefern?

gruss

Charlie Hotel

AD Gruppe in Lokale Gruppe einfügen

$
0
0

Hallo zusammen,

ich habe ein kleines Problem.

Um die Verteilung einer AD Gruppe in die Lokale Gruppe der Offer Remote Assistance Helper auf etwa 1600 Rechner zu beschleunigen, dachte ich mir zuerst oh fein gute alte DOS Batch bauen und das Script über Altiris verteilen ... Pustekuchen.

Mit einem AD User funktionierts gut mit AD Gruppe nicht.

Also gut dann über PS ...

Auslesen etc. kein Thema aber beim Adden verstauch ich mir gerade das Hirn ^^

Hat jemand einen Tip ?

Gruß

Uwe

Shutdown Script mit Interaktion und Zeit

$
0
0

Moin Moin,

ich ärgere mich seit 2 Tagen mit den Script rum (ich muss dazu sagen das ich absolut keine Ahnung habe was Programmierung oder Powershell angeht :D habe aber einiges gelesen und schon was gebastelt) und hoffe ihr könnt mir evtl sagen wo der Fehler liegt. Ich möchte ein Script schreiben in dem ich gefragt werde ob ich den PC herunterfahren möchte oder nicht das funktioniert soweit sogar grafisch. Allerdings hätte ich gerne das wenn ich 30 Sek nicht interagiere  oder bei der Abfrage auf Ja drücke das der PC herunterfährt, ich hab allerdings es nur geschafft das der PC ausgeht wenn ich auf ja drücke oder eben bei nein nicht runterfährt könnt ihr mir dort evtl en Tipp geben wie ich das am besten Umsetze.

Anbei mein Code:


$wPowerShell=new-object -comobject wscript.shell

$Wartezeit = 0 # Dauer wie lang das Fenster offen bleibt bei keiner Eingabe
$Schaltfläche = 4 # Schaltfläche Ja und Nein

$Antwort=$wPowershell.popup("Soll der PC Heruntergefahren werden?",$Wartezeit,"Shutdown",$Schaltfläche)

# Abfrage starten
if ($Antwort-eq 6 )  # Fall "Ja" oder "Yes" gedrückt wurde...

{
shutdown -s -f
}
else  # Fall "Nein" oder "No" gedrückt wurde...
{
exit
}

# Code-Ende



Nur Ordner verarbeiten, die eine bestimmte Anzahl von Dateien beinhalten

$
0
0

Hallo,

mit einem Powershellscript (Powershell3) durchsuche ich einen Speicher nach Ordnern mit bestimmten Namen, in diesen Odnern benenne ich bestimmte Unterordner um und verschiebe selbige an einen anderen Ort. Das klappt alles soweit sehr gut, allerdings versuche ich verzweifelt dem Script beizubringen, nur Ordner umzubenennen und zu verschieben, die eine bestimmte Anzahl von Dateien (in diesem Fall 2 oder mehr) beinhalten. Hier mein aktueller Code:

$myjob = [Powershell]::Create().AddScript({ # variablen definieren $AvidNr = 1

$quellpfad = "\\TTVUNITY1\TTVUnity1\Unity1_Avid_Projekte_und_MediaFiles\Unity1_Avid_Projekte_und_MediaFiles" $quellpfadtiefer = "\Avid MediaFiles\MXF" $folders = Get-ChildItem $quellpfad -Recurse | Where {$_.PSIsContainer -and $_.Name -match "Avid${AvidNr}MediaFiles"} # ordner umbenennen und verschieben foreach ($folder in $folders){

## hier müsste man doch vermutlich irgendwie einschränken können, dass die Shell nur $folder nimmt, die mehr als 2 Dateien beinhalten - nur WIE? ##

$cnt=0 Get-ChildItem "$($folder.FullName)$quellpfadtiefer" -Directory | Where {$_.PSIsContainer} | Foreach-Object {Rename-Item $_.FullName -NewName ((get-date -Format "yyyyMMddhhmmss")+$AvidNr+$AvidNr+$AvidNr+$AvidNr+$cnt++) -passthru} | Move-Item -Destination "$($folder.parent.FullName)$quellpfadtiefer" } }) $myjob.BeginInvoke()| out-null while($myjob.InvocationStateInfo.State -eq "Running"){ Write-Progress -Activity "Ordnerverarbeitung" -Status "Bitte warten Umbenennung läuft ..." } write-host "Vorgang abgeschlossen"

Hat jemand einen Tipp?

Viele Grüße




Foreach Variable als Referenz beim Ersetzen von Daten in CSV

$
0
0

Hallo,

ich habe ein Problem beim Ändern von Daten in einer CSV Datei. Ich habe eine CSV Datendatei (Datafile.csv) und eine CSV Ersetzungstabelle (ConversationTable.csv), Aufbau s.u.. In der Datendatei sind in einigen Spalten ($csvconvfields) die Daten durch die in der Ersetzungstabelle enthaltenen Daten zu ersetzen, z.B. "1234" durch "a2b2". Falls es für die zu ersetzenden Daten keine Entsprechung in der Ersetzungstabelle gibt wird ein Standardwert geschrieben ($wrongdata).

Dazu lese ich die beiden CSV Dateien ein, durchsuche die Datendatei nach den zu bearbeitenden Spalten (erste foreach Schleife), hole jeweils die Daten der Spalten (zweite foreach Schleife) und ersetze diese durch die Ersetzungsdaten bzw. den Standardwert. Die ersetzten Daten sollten aber wieder in die  Datentabelle zurückgeschrieben werden. Das passiert nicht da die foreach Laufvariable ($fieldcont) keine Referenz auf die eigentlichen Datentabelle (in $csvcont.$csvfield) ist. Geht das überhaupt so? Habe ich einen grundsätzlichen Fehler im Lösungsansatz?

Beispiele für die CSV Dateien:

CSV Datendatei "Datafile.csv" enthält die Daten ähnlich:
    dfield1; dfield2; dfield3; dfield4; dfield5
     "wwwq";  "aasa";  "1244"; "wehet";  "1545"
     "wwwz"; "e4234";  "1433"; "wgget";      ""

CSV Ersetzungstabelle "ConversationTable.csv" enthält die Daten ähnlich:
     "SRC";  "DST"
    "1234"; "a2b2"
    "1433"; "a1b3"
    "1455"; "a2b2"
    "1545"; "ffef"

$csvconvfields  = @('dfield3','dfield5')
$wrongdata      = 'MISSED'

$csvmangletable = Import-Csv -Delimiter ';' "ConversationTable.csv"

$csvcont        = Import-Csv -Delimiter ';' "Datafile.csv"

foreach($csvfield in $csvconvfields) {
  foreach($fieldcont in $csvcont.$csvfield) {
    $oldcont = $fieldcont
    $fieldcont = $csvmangletable | Where-Object{ $_.SRC -eq $oldcont } | %{ $_.DST }
    if( $fieldcont.length -eq 0 ) {
      $fieldcont = $wrongdata
    }
    Write-Host $csvfield, ": ", $oldcont, " -> ", $fieldcont
  }  
}

$csvcont | Export-Csv "Datafile.csv" -Delimiter ';' -NoTypeInformation



Wie kann ich via PS Skript Deny Logon Localy für einen User setezn?

$
0
0

Hallo,

ich nutzen ein PS SKript um einen localen Admin User anzulegen. So weit, so gut.

Ich muss jedoch auch die Einschränkungen "SeDenyRemoteInteractiveLogonRight" und "SeDenyInteractiveLogonRight" setzen.

Im alten cmd Skript habe ich es via secedit und einer inf Datei gemacht.

Nun muss ich Power Shell verwenden und stehe vor diesem Problem.


regards Stephan

EXE-Programme in PowerShell werden nicht ausgeführt

$
0
0
Hallo zusammen,

heute wurde uns bei der TechNet Deployment Hotlineunter anderem folgende Frage gestellt:

Warum werden in der Windows PowerShell keine EXE-Programme mehr ausgeführt, nachdem ein PowerShell-Skript gestartet wurde?

Unsere Antwort bzw. unser Lösungsvorschlag darauf war:

Dieses Verhalten kann auftreten, wenn ein Skript entweder die Console.Write-Methode oder eine ausführbare Datei, für eine Anwendung aufruft und dabei sehr viele Werte in die PowerShell geschrieben werden. Dabei generiert die Powershell mehrere Console Handles, die bei großen Datenmengen Probleme aufweisen können.

Gegen dieses Verhalten wurde von Microsoft ein Hotfix [1] herausgegeben. Vorraussetzung für den Hotfix ist Windows Server 2008 R2 oder Windows 7.

[1] http://support.microsoft.com/kb/2701373

 

Wir hoffen, vielen Besuchern der TechNet Foren durch das Posten dieses Problems und einer möglichen Lösung weiterhelfen zu können.

Viele Grüße,
Christian Kirschlager
TechNet Deployment Hotline

TechNet Deployment-Hotline

Disclaimer:

Bitte haben Sie Verständnis dafür, dass wir hier auf Rückfragen gar nicht oder nur sehr zeitverzögert antworten können.
Bitte nutzen Sie für Rückfragen oder neue Fragen den telefonischen Weg über die TechNet Deployment Hotline: http://technet.microsoft.com/de-de/ff959330

TechNet Deployment-Hotline
Telefon: 0800-6937233*
Email: deployment-hotline@escde.net

* 08:00 – 18:00 Uhr (außer an bundeseinheitlichen Feiertagen). Kostenfrei aus dem dt. Festnetz, Mobilfunknetz ggfs. abweichend. Anrufer aus Österreich und der Schweiz können die Telefon-Hotline aus technischen Gründen über +49 721 693 7233 zum Tarif für Auslandsverbindungen des jeweiligen Telefonanbieters erreichen.
Es gelten Nutzungsbedingungen, Hinweise zu Markenzeichen sowie die allgemein gültigen Informationen zu Datenschutz und Cookies. Bitte beachten Sie auch die gesonderten Nutzungsbedingungen für die Deployment-Hotline.

vsphere, vm, tag

$
0
0

Hallo zusammen

Ich habe auf meinem Win7 Client ein powershell Script zusammengestellt um die Zuordnung von Tags bei VMs zu automatisieren. Das hat wunderbar funktioniert.

Jetzt habe ich das gleiche Script auf einem WinServer 2012 gestartet aber folgender Aufruf funktioniert nicht mehr:

$vms = Get-VM -Tag "test"

Fehler: Get-VM : A Parameter cannot be found that matches Parameter Name 'Tag'.

Auf dem Client verwende ich Powershell v2 und auf dem Server v3. get-help GetVM -full liefert mir denn auch andere Parameter zurück wenn ich es auf dem Win7 Client oder dem Server 2012 ausführe. Kann das wirklich sein? Im Script binde ich mittels Add-PsSnapin VMware.VimAutomation.Core das Snapin ein.

Ich habe auch schon gelesen das es Überschneidungen mit dem get-vm von HyperV gibt aber dieses Snapin ist nicht installiert. Eine andere Methode um z.B. alle VMs zu einem bestimmten Tag auszulesen habe ich nicht gefunden.

Könnt Ihr mir weiterhelfen?

Vielen Dank und Gruss

Roger

Script mittels Button starten und anschließen Form schließen geht nicht

$
0
0

Hallo,

mit einem kleinen Script füttere ich ffmpeg zum Rechnen von Video-Clips. Es gibt zwei Arten von Abläufen, die ich am Anfang innerhalb einen Form mittels Buttons starten lassen möchte. Allerdings bekomme ich es nicht hin, dass nach dem Drücken eines Buttons die Abfrage verschwindet und das entsprechende Script bzw. die Funktion  dann startet. Außerdem schmiert mir die Shell ab, wenn ich den FolderBrowserDialog bzw. den OpenFileDialog, der nach dem klicken der Buttons aufgeht, wieder schließe. Die Fehlermeldung hierzu:

Informationen über das Aufrufen von JIT-Debuggen
anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.

************** Ausnahmetext **************
System.Management.Automation.ExitException: Systemfehler
   bei System.Management.Automation.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   bei System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   bei System.Management.Automation.CommandProcessorBase.DoComplete()
   bei System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstreamCommandsToStop)
   bei System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)
   bei System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
   bei System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   bei System.Management.Automation.DlrScriptCommandProcessor.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   bei System.Management.Automation.CommandProcessorBase.DoComplete()
   bei System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(CommandProcessorBase commandRequestingUpstreamCommandsToStop)
   bei System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate)
   bei System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
   bei System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   bei System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   bei System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(Boolean createLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
   bei System.Management.Automation.ScriptBlock.<>c__DisplayClass4.<InvokeWithPipe>b__2()
   bei System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
   bei System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
   bei System.Management.Automation.ScriptBlock.InvokeAsDelegateHelper(Object dollarUnder, Object dollarThis, Object[] args)
   bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.ButtonBase.WndProc(Message& m)
   bei System.Windows.Forms.Button.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Geladene Assemblys **************
mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18444 built by: FX451RTMGDR.
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll.
----------------------------------------
powershell_ise
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398 (win8_gdr_oobssr.120820-1900).
    CodeBase: file:///C:/Windows/system32/WindowsPowerShell/v1.0/PowerShell_ISE.exe.
----------------------------------------
Microsoft.PowerShell.ISECommon
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.ISECommon/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.ISECommon.dll.
----------------------------------------
System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
System.Management.Automation
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16481.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management.Automation/v4.0_3.0.0.0__31bf3856ad364e35/System.Management.Automation.dll.
----------------------------------------
System.Core
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll.
----------------------------------------
powershell_ise.resources
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/system32/WindowsPowerShell/v1.0/de/powershell_ise.resources.DLL.
----------------------------------------
Microsoft.PowerShell.GPowerShell
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.GPowerShell/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.GPowerShell.dll.
----------------------------------------
System.ComponentModel.Composition
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.ComponentModel.Composition/v4.0_4.0.0.0__b77a5c561934e089/System.ComponentModel.Composition.dll.
----------------------------------------
Microsoft.PowerShell.Editor
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.Editor/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Editor.dll.
----------------------------------------
PresentationFramework
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll.
----------------------------------------
WindowsBase
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll.
----------------------------------------
PresentationCore
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll.
----------------------------------------
System.Xaml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xaml/v4.0_4.0.0.0__b77a5c561934e089/System.Xaml.dll.
----------------------------------------
System.Configuration
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll.
----------------------------------------
System.Xml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
System.Runtime.Serialization
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll.
----------------------------------------
UIAutomationProvider
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationProvider/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationProvider.dll.
----------------------------------------
Accessibility
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll.
----------------------------------------
MetadataViewProxies_c77da18b-d318-4c51-8a79-f8ce753d1378
    Assembly-Version: 0.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.ComponentModel.Composition/v4.0_4.0.0.0__b77a5c561934e089/System.ComponentModel.Composition.dll.
----------------------------------------
Microsoft.PowerShell.GPowerShell.resources
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.GPowerShell.resources/v4.0_3.0.0.0_de_31bf3856ad364e35/Microsoft.PowerShell.GPowerShell.resources.dll.
----------------------------------------
Microsoft.Management.Infrastructure
    Assembly-Version: 1.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.Management.Infrastructure/v4.0_1.0.0.0__31bf3856ad364e35/Microsoft.Management.Infrastructure.dll.
----------------------------------------
System.Management
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll.
----------------------------------------
System.DirectoryServices
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.DirectoryServices/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.DirectoryServices.dll.
----------------------------------------
System.Numerics
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll.
----------------------------------------
Anonymously Hosted DynamicMethods Assembly
    Assembly-Version: 0.0.0.0.
    Win32-Version: 4.0.30319.18444 built by: FX451RTMGDR.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.dll.
----------------------------------------
PresentationCore.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationCore.resources/v4.0_4.0.0.0_de_31bf3856ad364e35/PresentationCore.resources.dll.
----------------------------------------
PresentationFramework.Aero
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.Aero/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.Aero.dll.
----------------------------------------
UIAutomationTypes
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationTypes/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationTypes.dll.
----------------------------------------
Microsoft.PowerShell.Editor.resources
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.Editor.resources/v4.0_3.0.0.0_de_31bf3856ad364e35/Microsoft.PowerShell.Editor.resources.dll.
----------------------------------------
PresentationFramework-SystemXml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemXml/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemXml.dll.
----------------------------------------
System.Management.Automation.resources
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management.Automation.resources/v4.0_3.0.0.0_de_31bf3856ad364e35/System.Management.Automation.resources.dll.
----------------------------------------
System.Configuration.Install
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration.Install/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.Install.dll.
----------------------------------------
System.Transactions
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll.
----------------------------------------
Microsoft.PowerShell.Security
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.Security/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Security.dll.
----------------------------------------
mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
----------------------------------------
PSEventHandler
    Assembly-Version: 0.0.0.0.
    Win32-Version: 6.2.9200.16481.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management.Automation/v4.0_3.0.0.0__31bf3856ad364e35/System.Management.Automation.dll.
----------------------------------------
Microsoft.PowerShell.GraphicalHost
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.GraphicalHost/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.GraphicalHost.dll.
----------------------------------------
Microsoft.PowerShell.GraphicalHost.resources
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.GraphicalHost.resources/v4.0_3.0.0.0_de_31bf3856ad364e35/Microsoft.PowerShell.GraphicalHost.resources.dll.
----------------------------------------
Microsoft.GeneratedCode
    Assembly-Version: 1.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
PresentationFramework.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.resources/v4.0_4.0.0.0_de_31bf3856ad364e35/PresentationFramework.resources.dll.
----------------------------------------
PresentationFramework-SystemCore
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemCore/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemCore.dll.
----------------------------------------
Microsoft.CSharp
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.CSharp/v4.0_4.0.0.0__b03f5f7f11d50a3a/Microsoft.CSharp.dll.
----------------------------------------
System.Data
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll.
----------------------------------------
PresentationFramework-SystemData
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemData/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemData.dll.
----------------------------------------
Microsoft.PowerShell.Commands.Management
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Management/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Management.dll.
----------------------------------------
Microsoft.PowerShell.Commands.Utility
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Utility/v4.0_3.0.0.0__31bf3856ad364e35/Microsoft.PowerShell.Commands.Utility.dll.
----------------------------------------
Microsoft.PowerShell.Commands.Utility.resources
    Assembly-Version: 3.0.0.0.
    Win32-Version: 6.2.9200.16398.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.PowerShell.Commands.Utility.resources/v4.0_3.0.0.0_de_31bf3856ad364e35/Microsoft.PowerShell.Commands.Utility.resources.dll.
----------------------------------------
SMDiagnostics
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/SMDiagnostics/v4.0_4.0.0.0__b77a5c561934e089/SMDiagnostics.dll.
----------------------------------------
System.ServiceModel.Internals
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.ServiceModel.Internals/v4.0_4.0.0.0__31bf3856ad364e35/System.ServiceModel.Internals.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.0.30319.18408 built by: FX451RTMGREL.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------

************** JIT-Debuggen **************
Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
Konfigurationsdatei der Anwendung oder des Computers
(machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.

Zum Beispiel:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

Wenn das JIT-Debuggen aktiviert ist, werden alle Ausnahmefehler an den JIT-Debugger gesendet, der auf dem
Computer registriert ist, und nicht in diesem Dialogfeld behandelt.

Leider kann ich damit überhaupt nichts anfangen.

Und hier das Script (vermutlich wahnsinnig umständlich geschrieben, aber die Shell und ich sind erst seit kurzem Freunde):

# Temp Ordner Reste löschen
if (Test-Path -path C:\TOOLS\TEMP\) {
    Get-ChildItem C:\TOOLS\TEMP | where-object {$_.LastWriteTime -lt (get-date).AddDays(-1)} | Remove-Item -recurse
    } else {
        New-Item C:\TOOLS\TEMP\ -type directory 
}


# Datei-Auswahl-Dialog für mehrere Dateien
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null

$DateiAuswahlRoot = New-Object System.Windows.Forms.Form
$DateiAuswahlRoot.TopMost = $true

$DateiAuswahl = New-Object System.Windows.Forms.OpenFileDialog
$DateiAuswahl.Title = "JR Proxytool - HighResClips auswählen:"
$DateiAuswahl.InitialDirectory = "$env:USERPROFILE\Desktop\"
$DateiAuswahl.MultiSelect = $true
#$DateiAuswahl.Filter = "AVCHD-Clips (*.MTS)|*.MTS|MXF-Clips (*.mxf)|*.mxf|Quicktime-Clips (*.mov)|*.mov"
$DateiAuswahl.Filter = "*.MTS // *.MXF // *.MOV|*.MTS;*.mxf;*.mov"
#$DateiAuswahlErgebnis = $DateiAuswahl.ShowDialog($DateiAuswahlRoot)
    if ($DateiAuswahl.ShowDialog($DateiAuswahlRoot) -eq [System.Windows.Forms.DialogResult]::OK -eq "OK"){
	            # Dateien in ein Array schreiben
                $DateiAuswahlNamenMitPfad = @($DateiAuswahl.FileNames)
                # Dateinamen ohne Pfad in ein Array schreiben
                $DateiNamen = @(Get-ChildItem $DateiAuswahl.FileNames | % {$_.BaseName})  
            } else {
                exit
}    

$MTSinput = (Get-ChildItem $DateiAuswahl.FileNames | Where-Object {$_.Extension -eq ".MTS"})
$MXFinput = (Get-ChildItem $DateiAuswahl.FileNames | Where-Object {$_.Extension -eq ".MXF"})
$MOVinput = (Get-ChildItem $DateiAuswahl.FileNames | Where-Object {$_.Extension -eq ".MOV"})


# prüfen ob Timecodeinformationen im MTS-Input vorhanden sind
if ($MTSinput.Count -gt 0) {
    if ((C:\Tools\exiftool.exe -a $MTSinput[0] | findstr /c:"Time Code") -notmatch "Time Code") {
        # Timecode fehlt Meldung
        $DatumUhrzeit2 = Get-Date -format "dd.MM.yyyy HH:mm:ss"
        [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
        $form2 = New-Object System.Windows.Forms.Form
        $form2.topmost = $true
        [System.Windows.Forms.MessageBox]::Show($form2,"Die ausgewählten Clips beinhalten keine Timecodeinformationen!`nVorgang wird abgebrochen.","JR Proxytool - $DatumUhrzeit2",
        [Windows.Forms.MessageBoxButtons]::OK,[Windows.Forms.MessageBoxIcon]::Warning)
    exit
    }           
} 


# prüfen ob Timecodeinformationen im MXF-Input vorhanden sind
if ($MXFinput.Count -gt 0) {
    if ((C:\TOOLS\ffmpeg\bin\ffprobe $MXFinput[0] 2>&1 | findstr timecode) -notmatch "timecode") {
        # Timecode fehlt Meldung
        $DatumUhrzeit2 = Get-Date -format "dd.MM.yyyy HH:mm:ss"
        [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
        $form2 = New-Object System.Windows.Forms.Form
        $form2.topmost = $true
        [System.Windows.Forms.MessageBox]::Show($form2,"Die ausgewählten Clips beinhalten keine Timecodeinformationen!`nVorgang wird abgebrochen.","JR Proxytool - $DatumUhrzeit2",
        [Windows.Forms.MessageBoxButtons]::OK,[Windows.Forms.MessageBoxIcon]::Warning)
    exit
    }            
}


# prüfen ob Timecodeinformationen im MOV-Input vorhanden sind
if ($MOVinput.Count -gt 0) {
    if ((C:\TOOLS\ffmpeg\bin\ffprobe $MOVinput[0] 2>&1 | findstr timecode) -notmatch "timecode") {
        # Timecode fehlt Meldung
        $DatumUhrzeit2 = Get-Date -format "dd.MM.yyyy HH:mm:ss"
        [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
        $form2 = New-Object System.Windows.Forms.Form
        $form2.topmost = $true
        [System.Windows.Forms.MessageBox]::Show($form2,"Die ausgewählten Clips beinhalten keine Timecodeinformationen!`nVorgang wird abgebrochen.","JR Proxytool - $DatumUhrzeit2",
        [Windows.Forms.MessageBoxButtons]::OK,[Windows.Forms.MessageBoxIcon]::Warning)
    exit
    }            
} 



function ClipsZusammenfassen {

    function ZielDateiAuswahl {
    # Datei-Auswahl-Dialog

        [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
        $DateiAuswahlRoot = New-Object System.Windows.Forms.Form
        $DateiAuswahlRoot.TopMost = $true
        $DateiAuswahl = New-Object System.Windows.Forms.SaveFileDialog
        $DateiAuswahl.Title = "JR Proxytool - Zieldatei auswählen:"
        $DateiAuswahl.InitialDirectory = "$env:USERPROFILE\Desktop\"
        $DateiAuswahl.Filter = "mp4 Proxy-Clip (*.mp4)|*.mp4"
                if ($DateiAuswahl.ShowDialog($DateiAuswahlRoot) -eq [System.Windows.Forms.DialogResult]::OK){
	            return $DateiAuswahl.FileName
            } else {
                exit
            }	
    }

    $ZielDatei = ZielDateiAuswahl
    $ZielDateiName = $ZielDatei.split('\.')[-2]
    $ZielDateiPfad = $ZielDatei.Replace("\$ZielDateiName.mp4", "")


    function MTSproxy {
        $Global:DatumUhrzeit1 = Get-Date -format "dd.MM.yyyy HH-mm-ss"
        md "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"
        for ($i=0; $i -lt $MTSinput.Count; $i++) {
        $Eingabe = $MTSinput[$i]
        $Ausgabe = $DateiNamen[$i]

            $ExifOutput = (C:\Tools\exiftool.exe -a $Eingabe | findstr /c:"Time Code")
            foreach($str in $ExifOutput) {
                $ExifOutput = ($ExifOutput.TrimStart("Time Code"))
                $ExifOutput = $ExifOutput.TrimStart(": ")
                $ExifTimecode = $ExifOutput.Split(":")
                $ExifStunde = $ExifTimecode[0]
                $ExifMinute = $ExifTimecode[1]
                $ExifSekunde = $ExifTimecode[2]
                $ExifFrame = $ExifTimecode[3]
                }

                    #$font = "/TOOLS/arial.ttf"
                    $font = "/Windows/Fonts/arial.ttf"
                    $timecode_ausgelesen = "$ExifStunde\:$ExifMinute\:$ExifSekunde\:$ExifFrame" 
                    $timecode_concatenating = "$ExifStunde-$ExifMinute-$ExifSekunde-$ExifFrame"
                    $tc = "drawtext=fontfile=${font}: timecode='$timecode_ausgelesen' :r=25 :x=5 :y=10 :fontcolor=white :fontsize=35 :box=1 :boxcolor=0x00000099"
                    $branding = "drawtext=fontfile=${font} :text='proxytool written by johannes.ramson@thommtv.de' :x=5 :y=275 :fontcolor=white@0.7 :fontsize=10 :box=1 :boxcolor=0x00000099@0.7"
                    $filename = "drawtext=fontfile=${font} :text='Source\: $Ausgabe.MTS' :x=5 :y=36 :fontcolor=white :fontsize=10 :box=1 :boxcolor=0x00000099"

                       C:\TOOLS\ffmpeg\bin\ffmpeg -i $Eingabe -b:v 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -vcodec mpeg4 -acodec aac -strict -2 -b:a 96k -y -aspect 16:9 -vf "[in]scale=512:288, $tc, $filename, $branding[out]" "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\${timecode_concatenating}_TEMP.mp4"
        }
    }


    function MXFproxy {
        $Global:DatumUhrzeit1 = Get-Date -format "dd.MM.yyyy HH-mm-ss"
        md "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"
        for ($i=0; $i -lt $MXFinput.Count; $i++) {
        $Eingabe = $MXFinput[$i]
        $Ausgabe = $DateiNamen[$i]

            $ffprobeOutput = (C:\TOOLS\ffmpeg\bin\ffprobe $Eingabe 2>&1 | findstr timecode)
            foreach($str in $ffprobeOutput) {
                $ffprobeTimecode = $ffprobeOutput.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart("timecode")
                $ffprobeTimecode = $ffprobeTimecode.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart(": ")
                $ffprobeTimecode = $ffprobeTimecode.Split(":")
                $ffprobeStunde = $ffprobeTimecode[0]
                $ffprobeMinute = $ffprobeTimecode[1]
                $ffprobeSekunde = $ffprobeTimecode[2]
                $ffprobeFrame = $ffprobeTimecode[3]
                }

                    #$font = "/TOOLS/arial.ttf"
                    $font = "/Windows/Fonts/arial.ttf"
                    $timecode_ausgelesen = "$ffprobeStunde\:$ffprobeMinute\:$ffprobeSekunde\:$ffprobeFrame"
                    $timecode_concatenating = "$ffprobeStunde-$ffprobeMinute-$ffprobeSekunde-$ffprobeFrame"
                    $tc = "drawtext=fontfile=${font}: timecode='$timecode_ausgelesen' :r=25 :x=5 :y=10 :fontcolor=white :fontsize=35 :box=1 :boxcolor=0x00000099"
                    $branding = "drawtext=fontfile=${font} :text='proxytool written by johannes.ramson@thommtv.de' :x=5 :y=275 :fontcolor=white@0.7 :fontsize=10 :box=1 :boxcolor=0x00000099@0.7"
                    $filename = "drawtext=fontfile=${font} :text='Source\: $Ausgabe.mxf' :x=5 :y=36 :fontcolor=white :fontsize=10 :box=1 :boxcolor=0x00000099"
                       C:\TOOLS\ffmpeg\bin\ffmpeg -i $Eingabe -b:v 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -vcodec mpeg4 -acodec aac -strict -2 -b:a 96k -y -aspect 16:9 -vf "[in]scale=512:288, $tc, $filename, $branding[out]" "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\${timecode_concatenating}_TEMP.mp4"
        }
    }


    function MOVproxy {
        $Global:DatumUhrzeit1 = Get-Date -format "dd.MM.yyyy HH-mm-ss"
        md "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"
        for ($i=0; $i -lt $MOVinput.Count; $i++) {
        $Eingabe = $MOVinput[$i]
        $Ausgabe = $DateiNamen[$i]

            $ffprobeOutput = (C:\TOOLS\ffmpeg\bin\ffprobe $Eingabe 2>&1 | findstr timecode)
            foreach($str in $ffprobeOutput) {
                $ffprobeTimecode = $ffprobeOutput.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart("timecode")
                $ffprobeTimecode = $ffprobeTimecode.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart(": ")
                $ffprobeTimecode = $ffprobeTimecode.Split(":")
                $ffprobeStunde = $ffprobeTimecode[0]
                $ffprobeMinute = $ffprobeTimecode[1]
                $ffprobeSekunde = $ffprobeTimecode[2]
                $ffprobeFrame = $ffprobeTimecode[3]
                }

                    #$font = "/TOOLS/arial.ttf"
                    $font = "/Windows/Fonts/arial.ttf"
                    $timecode_ausgelesen = "$ffprobeStunde\:$ffprobeMinute\:$ffprobeSekunde\:$ffprobeFrame" 
                    $timecode_concatenating = "$ffprobeStunde-$ffprobeMinute-$ffprobeSekunde-$ffprobeFrame"
                    $tc = "drawtext=fontfile=${font}: timecode='$timecode_ausgelesen' :r=25 :x=5 :y=10 :fontcolor=white :fontsize=35 :box=1 :boxcolor=0x00000099"
                    $branding = "drawtext=fontfile=${font} :text='proxytool written by johannes.ramson@thommtv.de' :x=5 :y=275 :fontcolor=white@0.7 :fontsize=10 :box=1 :boxcolor=0x00000099@0.7"
                    $filename = "drawtext=fontfile=${font} :text='Source\: $Ausgabe.mov' :x=5 :y=36 :fontcolor=white :fontsize=10 :box=1 :boxcolor=0x00000099"

                       C:\TOOLS\ffmpeg\bin\ffmpeg -i $Eingabe -b:v 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -vcodec mpeg4 -acodec aac -strict -2 -b:a 96k -y -aspect 16:9 -vf "[in]scale=512:288, $tc, $filename, $branding[out]" "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\${timecode_concatenating}_TEMP.mp4"
        }
    }



    # MTS Proxies rechnen
    if ($MTSinput.Count -gt 0) {
        MTSproxy
    }

    # MXF Proxies rechnen
    if ($MXFinput.Count -gt 0) {
        MXFproxy
    }

    # MOV Proxies rechnen
    if ($MOVinput.Count -gt 0) {
        MOVproxy
    }
    
    

    function proxyConcat {
        (Get-ChildItem "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1" -recurse -exclude *.txt).Fullname | %{"file '$_'"} > ($ConcatListe_TEMP = "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\ConcatListe_TEMP.txt")
        (Get-Content "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\ConcatListe_TEMP.txt" | sort) | out-file ($ConcatListe = "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\ConcatListe.txt") -encoding ASCII
        C:\TOOLS\ffmpeg\bin\ffmpeg -f concat -i $ConcatListe -c copy -y "$ZielDateiPfad\${ZielDateiName}.mp4" 2>&1 | tee ($Script:ErrorLogTemp = "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1\JR ProxyTool - ErrorLog $DatumUhrzeit1.txt")
    }
    proxyConcat



    if ((Get-Content $ErrorLogTemp) -match "Invalid data found when processing input"){
        $DatumUhrzeit4 = Get-Date -format "dd.MM.yyyy HH:mm:ss"
        [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
        $form4 = New-Object System.Windows.Forms.Form
        $form4.topmost = $true    
            [System.Windows.Forms.MessageBox]::Show($form4,"Vorgang fehlgechlagen! `nIm Anschluss wird das LogFile geöffnet.","JR Proxytool - $DatumUhrzeit4",
            [Windows.Forms.MessageBoxButtons]::OK,[Windows.Forms.MessageBoxIcon]::Warning)
            # Logfile öffnen
            Invoke-Item $ErrorLogTemp
            Exit
    }


    # Temp Ordner löschen
    # Remove-Item -Recurse -Force "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"


    # Abschluss Meldung
    $DatumUhrzeit2 = Get-Date -format "dd.MM.yyyy HH:mm:ss"
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
    $form1 = New-Object System.Windows.Forms.Form
    $form1.topmost = $true    
        [System.Windows.Forms.MessageBox]::Show($form1,"$ZielDateiPfad\${ZielDateiName}.mp4 `nwurde erfolgreich gerechnet.","JR Proxytool - $DatumUhrzeit2",
        [Windows.Forms.MessageBoxButtons]::OK,[Windows.Forms.MessageBoxIcon]::Asterisk)
            # Zielordner öffnen
            # Invoke-Item $ZielDateiPfad
}


function ClipsEinzeln {

    function ZielOrdnerAuswahl {
    # Datei-Auswahl-Dialog

        [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
        $OrdnerAuswahlRoot = New-Object System.Windows.Forms.Form
        $OrdnerAuswahlRoot.TopMost = $true
        $OrdnerAuswahl = New-Object System.Windows.Forms.FolderBrowserDialog
        $OrdnerAuswahl.Description = "JR Proxytool - Zielordner auswählen:"
        $OrdnerAuswahl.SelectedPath = "$env:USERPROFILE\Desktop\"
                if ($OrdnerAuswahl.ShowDialog($OrdnerAuswahlRoot) -eq [System.Windows.Forms.DialogResult]::OK){
	            return $OrdnerAuswahl.SelectedPath
            } else {
                exit
            }	
    }

    $ZielOrdner = ZielOrdnerAuswahl


    function MTSproxy {
        $Global:DatumUhrzeit1 = Get-Date -format "dd.MM.yyyy HH-mm-ss"
        # md "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"
        for ($i=0; $i -lt $MTSinput.Count; $i++) {
        $Eingabe = $MTSinput[$i]
        $Ausgabe = $MTSinput.BaseName[$i]

            $ExifOutput = (C:\Tools\exiftool.exe -a $Eingabe | findstr /c:"Time Code")
            foreach($str in $ExifOutput) {
                $ExifOutput = ($ExifOutput.TrimStart("Time Code"))
                $ExifOutput = $ExifOutput.TrimStart(": ")
                $ExifTimecode = $ExifOutput.Split(":")
                $ExifStunde = $ExifTimecode[0]
                $ExifMinute = $ExifTimecode[1]
                $ExifSekunde = $ExifTimecode[2]
                $ExifFrame = $ExifTimecode[3]
                }

                    #$font = "/TOOLS/arial.ttf"
                    $font = "/Windows/Fonts/arial.ttf"
                    $timecode_ausgelesen = "$ExifStunde\:$ExifMinute\:$ExifSekunde\:$ExifFrame" 
                    $timecode_concatenating = "$ExifStunde-$ExifMinute-$ExifSekunde-$ExifFrame"
                    $tc = "drawtext=fontfile=${font}: timecode='$timecode_ausgelesen' :r=25 :x=5 :y=10 :fontcolor=white :fontsize=35 :box=1 :boxcolor=0x00000099"
                    $branding = "drawtext=fontfile=${font} :text='proxytool written by johannes.ramson@thommtv.de' :x=5 :y=275 :fontcolor=white@0.7 :fontsize=10 :box=1 :boxcolor=0x00000099@0.7"
                    $filename = "drawtext=fontfile=${font} :text='Source\: $Ausgabe.MTS' :x=5 :y=36 :fontcolor=white :fontsize=10 :box=1 :boxcolor=0x00000099"

                       C:\TOOLS\ffmpeg\bin\ffmpeg -i $Eingabe -b:v 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -vcodec mpeg4 -acodec aac -strict -2 -b:a 96k -y -aspect 16:9 -vf "[in]scale=512:288, $tc, $filename, $branding[out]" "$ZielOrdner\$Ausgabe.mp4"
        }
    }


    function MXFproxy {
        $Global:DatumUhrzeit1 = Get-Date -format "dd.MM.yyyy HH-mm-ss"
        # md "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"
        for ($i=0; $i -lt $MXFinput.Count; $i++) {
        $Eingabe = $MXFinput[$i]
        $Ausgabe = $MXFinput.BaseName[$i]

            $ffprobeOutput = (C:\TOOLS\ffmpeg\bin\ffprobe $Eingabe 2>&1 | findstr timecode)
            foreach($str in $ffprobeOutput) {
                $ffprobeTimecode = $ffprobeOutput.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart("timecode")
                $ffprobeTimecode = $ffprobeTimecode.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart(": ")
                $ffprobeTimecode = $ffprobeTimecode.Split(":")
                $ffprobeStunde = $ffprobeTimecode[0]
                $ffprobeMinute = $ffprobeTimecode[1]
                $ffprobeSekunde = $ffprobeTimecode[2]
                $ffprobeFrame = $ffprobeTimecode[3]
                }

                    #$font = "/TOOLS/arial.ttf"
                    $font = "/Windows/Fonts/arial.ttf"
                    $timecode_ausgelesen = "$ffprobeStunde\:$ffprobeMinute\:$ffprobeSekunde\:$ffprobeFrame"
                    $timecode_concatenating = "$ffprobeStunde-$ffprobeMinute-$ffprobeSekunde-$ffprobeFrame"
                    $tc = "drawtext=fontfile=${font}: timecode='$timecode_ausgelesen' :r=25 :x=5 :y=10 :fontcolor=white :fontsize=35 :box=1 :boxcolor=0x00000099"
                    $branding = "drawtext=fontfile=${font} :text='proxytool written by johannes.ramson@thommtv.de' :x=5 :y=275 :fontcolor=white@0.7 :fontsize=10 :box=1 :boxcolor=0x00000099@0.7"
                    $filename = "drawtext=fontfile=${font} :text='Source\: $Ausgabe.mxf' :x=5 :y=36 :fontcolor=white :fontsize=10 :box=1 :boxcolor=0x00000099"
                       C:\TOOLS\ffmpeg\bin\ffmpeg -i $Eingabe -b:v 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -vcodec mpeg4 -acodec aac -strict -2 -b:a 96k -y -aspect 16:9 -vf "[in]scale=512:288, $tc, $filename, $branding[out]" "$ZielOrdner\$Ausgabe.mp4"
        }
    }


    function MOVproxy {
        $Global:DatumUhrzeit1 = Get-Date -format "dd.MM.yyyy HH-mm-ss"
        # md "C:\Tools\TEMP\Proxy_TEMP $DatumUhrzeit1"
        for ($i=0; $i -lt $MOVinput.Count; $i++) {
        $Eingabe = $MOVinput[$i]
        $Ausgabe = $MOVinput.BaseName[$i]

            $ffprobeOutput = (C:\TOOLS\ffmpeg\bin\ffprobe $Eingabe 2>&1 | findstr timecode)
            foreach($str in $ffprobeOutput) {
                $ffprobeTimecode = $ffprobeOutput.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart("timecode")
                $ffprobeTimecode = $ffprobeTimecode.Trim()
                $ffprobeTimecode = $ffprobeTimecode.TrimStart(": ")
                $ffprobeTimecode = $ffprobeTimecode.Split(":")
                $ffprobeStunde = $ffprobeTimecode[0]
                $ffprobeMinute = $ffprobeTimecode[1]
                $ffprobeSekunde = $ffprobeTimecode[2]
                $ffprobeFrame = $ffprobeTimecode[3]
                }

                    #$font = "/TOOLS/arial.ttf"
                    $font = "/Windows/Fonts/arial.ttf"
                    $timecode_ausgelesen = "$ffprobeStunde\:$ffprobeMinute\:$ffprobeSekunde\:$ffprobeFrame" 
                    $timecode_concatenating = "$ffprobeStunde-$ffprobeMinute-$ffprobeSekunde-$ffprobeFrame"
                    $tc = "drawtext=fontfile=${font}: timecode='$timecode_ausgelesen' :r=25 :x=5 :y=10 :fontcolor=white :fontsize=35 :box=1 :boxcolor=0x00000099"
                    $branding = "drawtext=fontfile=${font} :text='proxytool written by johannes.ramson@thommtv.de' :x=5 :y=275 :fontcolor=white@0.7 :fontsize=10 :box=1 :boxcolor=0x00000099@0.7"
                    $filename = "drawtext=fontfile=${font} :text='Source\: $Ausgabe.mov' :x=5 :y=36 :fontcolor=white :fontsize=10 :box=1 :boxcolor=0x00000099"

                       C:\TOOLS\ffmpeg\bin\ffmpeg -i $Eingabe -b:v 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -vcodec mpeg4 -acodec aac -strict -2 -b:a 96k -y -aspect 16:9 -vf "[in]scale=512:288, $tc, $filename, $branding[out]" "$ZielOrdner\$Ausgabe.mp4"
        }
    }



    # MTS Proxies rechnen
    if ($MTSinput.Count -gt 0) {
        MTSproxy
    }

    # MXF Proxies rechnen
    if ($MXFinput.Count -gt 0) {
        MXFproxy
    }

    # MOV Proxies rechnen
    if ($MOVinput.Count -gt 0) {
        MOVproxy
    }
    
    
    # Abschluss Meldung
    $DatumUhrzeit2 = Get-Date -format "dd.MM.yyyy HH:mm:ss"
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
    $form1 = New-Object System.Windows.Forms.Form
    $form1.topmost = $true    
        [System.Windows.Forms.MessageBox]::Show($form1,"Vorgang abgeschlossen.","JR Proxytool - $DatumUhrzeit2",
        [Windows.Forms.MessageBoxButtons]::OK,[Windows.Forms.MessageBoxIcon]::Asterisk)
            # Zielordner öffnen
            # Invoke-Item $ZielDateiPfad
}


[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
$Date = Get-Date -format "dd.MM.yyyy HH:mm:ss"
$objForm = New-Object System.Windows.Forms.Form 
$objForm.Text = "JR Proxytool - $Date”
$objForm.Size = New-Object System.Drawing.Size(300,150) 
$objForm.minimumSize = New-Object System.Drawing.Size(300,150) 
$objForm.maximumSize = New-Object System.Drawing.Size(300,150)
$objForm.FormBorderStyle = "FixedDialog"
$objForm.StartPosition = "CenterScreen"
$objForm.Topmost = $true
$objForm.Add_Shown({$ZusammenFassenButton.focus()})

# Enter und Ecape definieren
$objForm.KeyPreview = $true
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") 
    {ClipsZusammenfassen;$objForm.close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") 
    {$objForm.Close()}})

$ZusammenFassenButton = New-Object System.Windows.Forms.Button
$ZusammenFassenButton.Location = New-Object System.Drawing.Size(20,50)
$ZusammenFassenButton.Size = New-Object System.Drawing.Size(125,50)
$ZusammenFassenButton.Text = "Ausgewählte Clips zusammenfassen"
$ZusammenFassenButton.Add_Click({ClipsZusammenfassen;$objForm.close()})
$objForm.Controls.Add($ZusammenFassenButton)
$EinzelnButton = New-Object System.Windows.Forms.Button
$EinzelnButton.Location = New-Object System.Drawing.Size(150,50)
$EinzelnButton.Size = New-Object System.Drawing.Size(125,50)
$EinzelnButton.Text = "Jeden Clip einzeln rechnen"
$EinzelnButton.Add_Click({ClipsEinzeln;$objForm.close})
$objForm.Controls.Add($EinzelnButton)

$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(35,20) 
$objLabel.Size = New-Object System.Drawing.Size(280,20) 
$objLabel.Text = "Wie sollen die ProxyClips gerechnet werden?"
$objForm.Controls.Add($objLabel) 

[void] $objForm.ShowDialog()

Was mache ich falsch?

Script mit einer Schleife

$
0
0

Hallo zusammen,

ich möchte parallell zu einer Installation ein PS-Script starten und überwachen, ob der Installer ein Programm im Systemkontext startet. Dies muss beendet werden, damit die installation abgeschlossen werden kann. Taskkill und Co. geht zwar. die Prozesse eines Benutzers dürfen nicht beendet wird. Er bekommt eine Aufforderung das Programm zu schließen. 

Die Idee ist in 3-Sekunden Takt zu prüfen, ob das Program am Laufen ist:

get-process outlook | where-object {$_.SessionId -eq 0}

Was offen ist, wie mache ich ein Counter mit der Schleife und Abfrage zum Beenden des Prozesses?

Das Script sollte nach einem Timeout von z.B. 10 Minuten beendet werden.

Danke für alle Ideen!


Powershell / Excel - Löschen einer leeren Reihe (Column)

$
0
0

Hallo zusammen.
Ich habe folgendes Problem. Ich finde zwar bereits im Internet diverse Beispielcodes und Hilfen, aber leider ist noch nicht die perfekte, bzw. fehlerfreie Lösung dabei.
Ich habe ein Exceldokument, was ich mit Powershell öffne/bearbeite. Das klappt auch soweit einwandfrei. Nur habe ich in der Tabelle Reihen, die keine Daten enthalten und demnach gelöscht werden müssen, um eine bessere Übersichtlichkeit zu erreichen. Die bisherigen Codes löschen entweder gar nichts oder löschen alles.

Ich habe mal als Beispiel ein Screenshot der Exceltabelle angehängt und ein paar dieser leeren Reihen mit einem Pfeil gekennzeichnet. Exceltabelle

Hier dazu der Code, der leider nicht so funktioniert, wie ich es benötige.

#delete columns

$xlCellTypeLastCell = 11
$used = $worksheet.usedRange
$lastCell = $used.SpecialCells($xlCellTypeLastCell)
$Column = $lastCell.Column

for ($i = 1; $i -le $Column; $i++)
{
	while ($worksheet.Cells.Item(1, 5).Value() -eq $Null)
	{
		$Range = $worksheet.Cells.Item(1, 5).EntireColumn
		$Range.Delete([Microsoft.office.interop.excel.xldeleteshiftdirection]::xlShiftToLeft)
	}
}
Wunsch wäre, dass die mit dem Pfeil gekennzeichneten Reihen entsprechend gelöscht werden, wenn die Zellen in den Reihen keine Daten enthalten, was in diesem Fall immer zu 99,9% der Fall ist.

Vielen Dank!!!

Powershell / Excel - Löschen von leeren Spalten (Column)

$
0
0

Hallo zusammen.
Ich habe folgendes Problem. Ich finde zwar bereits im Internet diverse Beispielcodes und Hilfen, aber leider ist noch nicht die perfekte, bzw. fehlerfreie Lösung dabei.
Ich habe ein Exceldokument, was ich mit Powershell öffne/bearbeite. Das klappt auch soweit einwandfrei. Nur habe ich in der Tabelle Reihen, die keine Daten enthalten und demnach gelöscht werden müssen, um eine bessere Übersichtlichkeit zu erreichen. Die bisherigen Codes löschen entweder gar nichts oder löschen alles.

Ich habe mal als Beispiel ein Screenshot der Exceltabelle angehängt und ein paar dieser leeren Reihen mit einem Pfeil gekennzeichnet. Exceltabelle

Hier dazu der Code, der leider nicht so funktioniert, wie ich es benötige.

#delete columns

$xlCellTypeLastCell = 11
$used = $worksheet.usedRange
$lastCell = $used.SpecialCells($xlCellTypeLastCell)
$Column = $lastCell.Column

for ($i = 1; $i -le $Column; $i++)
{
	while ($worksheet.Cells.Item(1, 5).Value() -eq $Null)
	{
		$Range = $worksheet.Cells.Item(1, 5).EntireColumn
		$Range.Delete([Microsoft.office.interop.excel.xldeleteshiftdirection]::xlShiftToLeft)
	}
}
Wunsch wäre, dass die mit dem Pfeil gekennzeichneten Reihen entsprechend gelöscht werden, wenn die Zellen in den Reihen keine Daten enthalten, was in diesem Fall immer zu 99,9% der Fall ist.

Vielen Dank!!!



Wie kann ich eine Textdatei zeilenweise editieren

$
0
0

Hallo zusammen,

ich habe eine große Datei, die ich einlese

$datei=get-content Test.txt

Dann gehe ich zeilenweise durch die Datei und modifiziere diese ganz wüst

also

foreach ($zeile in $datei) {

   jetzt kommt gaaanz viel Code mit beliebig vielen funktionsaufrufen usw.

   am ende ist in $zeile die richtige modifizierte Zeile drin

}

Wie bekomme ich das jetzt in eine Datei zurück?

foreach-object ist, denke ich, nicht das richtige, weil hier zu Kontrollzwecken auch 1000e Ausgaben mit write-host gemacht werden sollen.

Help is needed


Greetings/Grüße Gernot

Csv modifizieren

$
0
0

Aus einem Messgerät fließen eine bestimmte Anzahl von Daten durch Messungen. Wegen der ggf. Masse an Dateien, importieren wir aktuell die Dateien per Hand in Excel und ändern dann auch alles per Hand in Excel.
Um das zu automatisieren und viel schneller handeln zu können, würde ich gerne mit Powershell dieses umsetzen.

Ich habe also eine Textdatei, die von einem Instrument ausgegeben wird, um sie dann nach Wunsch in Excel zu öffnen.

Diese Datei sieht nach der Ausgabe durch das Instrument z.B. so aus:

,,,,,,,,,,,,,,,,,,,,  21,,  22,,  40,,  57,,  59,,  80,, 102,, 158,, 210,, 220,, 311,, 312,, 313,, 413,, 418,, 435,, 452,, 510,, 570,, 588,, 661,, 678,, 684,, 686,, 690,, 691,, 698,, 701,, 708,, 712,, 714,, 731,, 734,, 750,, 767,, 781,, 798,, 989,, 990,, 991,, 992,, 993,, 994,
,,,,,,,,,,,,,,,,,,,,C,,C,,C,,C,,C,,C,,,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,,C,
,,,,,,,,,,,,,,,,,,,,1,,1,,1,,1,,1,,1,,,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,,1,
R_Type1,R_Type2,S_Type,S_No.,R_No.,Pos,S_ID,M_Date,Age,Unit,Sex,S_Date,C1,C2,C3,C4,C5,Cup,Ope_D,N,U/L   ,,U/L   ,,mmol/L,,U/L   ,,mmol/L,,U/L   ,,ug/mL ,,U/L   ,,mg/L  ,,U/L   ,,U/L   ,,U/L   ,,U/L   ,,g/L   ,,mmol/L,,mmol/L,,umol/L,,kU/L  ,,U/L   ,,U/L   ,,umol/L,,g/L   ,,U/L   ,,U/L   ,,umol/L,,mmol/L,,mmol/L,,mmol/L,,mg/L  ,,umol/L,,mmol/L,,U/L   ,,umol/L,,mAbs  ,,mmol/L,,mmol/L,,mmol/L,,mmol/L,,mmol/L,,mmol/L,,,,,,,
1,1,1,    1, 1334,1,1            ,2014/07/30 13:41:00,,,,,                              ,                         ,                    ,               ,          ,1,,  8,,,,,,,,,,,,,,,    94,,,,    55,,,,,,,,,,,,,,,,,,,,  27.7,,,,,,    47,,    49,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,     8,,     6,,     2,
1,2,1,    1, 1334,1,1            ,2014/07/30 13:41:00,,,,,                              ,                         ,                    ,               ,          ,1,,  1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,  29.1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
1,1,1,    2, 1334,2,             ,2014/07/30 13:41:00,,,,,                              ,                         ,                    ,               ,          ,1,,  8,,,,,,,,,,,,,,,    95,,,,    55,,,,,,,,,,,,,,,,,,,,  28.1,,,,,,    46,,    48,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,     9,,     6,,     2,
1,1,1,    3, 1334,3,             ,2014/07/30 13:41:00,,,,,                              ,                         ,                    ,               ,          ,1,,  8,,,,,,,,,,,,,,,    95,,,,    55,,,,,,,,,,,,,,,,,,,,  27.8,,,,,,    47,,    47,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,     9,,     6,,     2,
1,1,1,    4, 1334,4,             ,2014/07/30 13:41:00,,,,,                              ,                         ,                    ,               ,          ,1,,  8,,,,,,,,,,,,,,,    94,,,,    55,,,,,,,,,,,,,,,,,,,,  27.8,,,,,,    47,,    48,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,     9,,     5,,     2,
1,1,1,    5, 1334,5,             ,2014/07/30 13:41:00,,,,,                              ,                         ,                    ,               ,          ,1,,  8,,,,,,,,,,,,,,,    95,,,,    56,,,,,,,,,,,,,,,,,,,,  27.9,,,,,,    46,,    48,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,     9,,     7,,     2,
1,1,1,    6, 1335,1,6            ,2014/07/30 11:09:00,,,,,                              ,                         ,                    ,               ,          ,1,, 15,,,,,,,,,,,,,,,,,,,,,,,,,,,  32.6,,  6.43,,,,,,,,    84,,,,,,  47.8,,,,,,    96,,,,  2.18,,,,,,  17.2,,  1.15,, 53.20,,,,,,  5.66,,  1.17,,  2.11,,   110,,  3.62,,  76.1,,,,,,,
1,1,1,    7, 1335,2,             ,2014/07/30 11:09:00,,,,,                              ,                         ,                    ,               ,          ,1,, 15,,,,,,,,,,,,,,,,,,,,,,,,,,,  32.5,,  6.52,,,,,,,,    86,,,,,,  48.4,,,,,,    97,,,,  2.15,,,,,,  16.9,,  1.13,, 53.83,,,,,,  5.71,,  1.18,,  2.12,,   112,,  3.67,,  77.7,,,,,,,
1,1,1,    8, 1335,3,             ,2014/07/30 11:09:00,,,,,                              ,                         ,                    ,               ,          ,1,, 15,,,,,,,,,,,,,,,,,,,,,,,,,,,  31.6,,  6.47,,,,,,,,    84,,,,,,  48.0,,,,,,    97,,,,  2.22,,,,,,  17.0,,  1.16,, 52.56,,,,,,  5.68,,  1.17,,  2.10,,   111,,  3.67,,  77.8,,,,,,,
1,1,1,    9, 1335,4,             ,2014/07/30 11:09:00,,,,,                              ,                         ,                    ,               ,          ,1,, 15,,,,,,,,,,,,,,,,,,,,,,,,,,,  32.1,,  6.38,,,,,,,,    85,,,,,,  47.2,,,,,,    96,,,,  2.15,,,,,,  16.7,,  1.15,, 53.21,,,,,,  5.60,,  1.18,,  2.10,,   112,,  3.69,,  77.9,,,,,,,
1,1,1,   10, 1335,5,             ,2014/07/30 11:09:00,,,,,                              ,                         ,                    ,               ,          ,1,, 15,,,,,,,,,,,,,,,,,,,,,,,,,,,  32.1,,  6.47,,,,,,,,    84,,,,,,  49.1,,,,,,    99,,,,  2.19,,,,,,  16.8,,  1.17,, 53.60,,,,,,  5.61,,  1.17,,  2.11,,   112,,  3.70,,  77.9,,,,,,,


Mein Problem ist nun aber folgendes.
Aus dieser Datei müssen vor dem Export nach Excel folgende Dinge verändert werden:
1) soll die 2. und 3. Zeile gelöscht werden
2) müssten die Zeichen wie R_Type1,R_Type2, ... und andere ebenso entfernt werden. Das Problem hierbei ist nun aber, dass auch die dann sich darunter befindlichen Werte mit gelöscht werden müssen, da sonst beim Öffnen in Excel die Spalten nicht mehr stimmen.
Also als Beispiel sollte nach dem Import aus der ersten Zeile z.B. die Zahl 158 mit dem Wert "u/L" aus der wegen Punkt 1) gelöschten Zeilen, dann Zeile 2 übereinanderstimmen, ebenso dann die entsprechenden Werte darunter, in dem Fall 94,95,95,95,94,95
3) dazu kommt, dass man sehen kann: es bestehen dort doppelte Kommas, die beim Import in Excel leere Spalten verursachen. Diese sollten ebenso vermieden werden.

Ich habe mal eine Datei soweit editiert, wie sie am Ende aussehen soll, damit man sie einfach in Excel importieren kann.

;;;;  21;  22;  40;  57;  59;  80; 102; 158; 210; 220; 311; 312; 313; 413; 418; 435; 452; 510; 570; 588; 661; 678; 684; 686; 690; 691; 698; 701; 708; 712; 714; 731; 734; 750; 767; 781; 798; 989; 990; 991; 992; 993; 994;
S_Type;S_No.;S_ID;M_Date;"U/L";"U/L";"mmol";"U/L";"mmol";"U/L";"ug/mL";"U/L";"mg/L";"U/L";"U/L";"U/L";"U/L";"g/L";"mmol/L";"mmol/L";"umol/L";"kU/L";"U/L";"U/L";"umol/L";"g/L";"U/L";"U/L";"umol/L";"mmol/L";"mmol/L";"mmol/L";"mg/L";"umol/L";"mmol/L";"U/L";"umol/L";"mAbs";"mmol/L";"mmol/L";"mmol/L";"mmol/L";"mmol/L";"mmol/L";;;
1;1;1;30/07/2014;;;;;;;;94;;55;;;;;;;;;;  27.7;;;47;49;;;;;;;;;;;;;;;;;8;6;2
1;1;1;30/07/2014;;;;;;;;;;;;;;;;;;;;  29.1;;;;;;;;;;;;;;;;;;;;;;;
1;2;             ;30/07/2014;;;;;;;;95;;55;;;;;;;;;;  28.1;;;46;48;;;;;;;;;;;;;;;;;9;6;2
1;3;             ;30/07/2014;;;;;;;;95;;55;;;;;;;;;;  27.8;;;47;47;;;;;;;;;;;;;;;;;9;6;2
1;4;             ;30/07/2014;;;;;;;;94;;55;;;;;;;;;;  27.8;;;47;48;;;;;;;;;;;;;;;;;9;5;2
1;5;             ;30/07/2014;;;;;;;;95;;56;;;;;;;;;;  27.9;;;46;48;;;;;;;;;;;;;;;;;9;7;2
1;6;6;30/07/2014;;;;;;;;;;;;;;  32.6;  6.43;;;;84;;;  47.8;;;96;;  2.18;;;  17.2;  1.15; 53.20;;;  5.66;  1.17;  2.11;110;  3.62;  76.1;;;
1;7;             ;30/07/2014;;;;;;;;;;;;;;  32.5;  6.52;;;;86;;;  48.4;;;97;;  2.15;;;  16.9;  1.13; 53.83;;;  5.71;  1.18;  2.12;112;  3.67;  77.7;;;
1;8;             ;30/07/2014;;;;;;;;;;;;;;  31.6;  6.47;;;;84;;;  48.0;;;97;;  2.22;;;  17.0;  1.16; 52.56;;;  5.68;  1.17;  2.10;111;  3.67;  77.8;;;
1;9;             ;30/07/2014;;;;;;;;;;;;;;  32.1;  6.38;;;;85;;;  47.2;;;96;;  2.15;;;  16.7;  1.15; 53.21;;;  5.60;  1.18;  2.10;112;  3.69;  77.9;;;
1;10;             ;30/07/2014;;;;;;;;;;;;;;  32.1;  6.47;;;;84;;;  49.1;;;99;;  2.19;;;  16.8;  1.17; 53.60;;;  5.61;  1.17;  2.11;112;  3.70;  77.9;;;

Ich habe zwar verschiedene Ansätze (get-content...) usw., aber leider bin ich in Powershell nicht so professionell drauf wie die meisten hier, um dieses zu einem Wunschergebis umsetzen zu können.

Kann mir hier jemand helfen ?.




rename lokal Windows 7 User

$
0
0

How can I change the username from a local user (username and fullname)? Is it possible?

Thanks for any help

Chris

Ein Popup im Powershell Skript wird nicht angezeigt, wenn man das Skript via Batch aufruft.

$
0
0

Hallo zusammen,

ein Powershell Skript (ohne Parameter) liest via Dateidialog eine Datei ein, um diese zu verarbeiten.

Das Skript funktioniert prima ;-).

Wenn ich dieses Skript durch eine BAT Datei starte (powershell.exe -executionpolicy unrestricted -file c:\temp\skript.ps1), dann kommt der Popup vom Dateidialog nicht. Was ist zu tun?

Ein bat außenrum ist aber nötig/sinnvoll, damit das Skript von einem "einfachen Benutzer" gestartet werden kann. Insbesondere auch, weil powershell x86 gestartet werden muss und nicht powershell.exe (64 Bit).

Help is needed!


Greetings/Grüße Gernot

Can't access named property of $obj.psobject.properties, please help.

$
0
0

Hello, I have a script that reads in XMP-data from images, the values are put into a custom object, as far as I understand. 

This is what I do using the Get-ImageMetaData-Module from Joel Bennett:

$datas = (ls C:\MyImage.jpg | Get-ImageMetaData )

Now everything works fine: when I do this afterwards:

$datas.psobject.properties

I get this output (excerpt):

MemberType : NoteProperty
IsSettable : True
IsGettable : True
Value : 3
TypeNameOfValue : System.String
Name : /xmp/xmp:Rating
IsInstance : True 

Now this is what I want to use in my script, I want to read the value of the member named "/xmp/xmp:Rating" into a variable. But I dont know how, because I don't know the way to adress the member named "/xmp/xmp:Rating".

I tried this

$a = $file.psobject.properties."/xmp/xmp:Rating".value

but that doesn't work. Could someone help me here, please? Thanks a lot! Martin.

Viewing all 2314 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>