{"id":151,"date":"2012-08-09T17:39:32","date_gmt":"2012-08-09T15:39:32","guid":{"rendered":"http:\/\/workplace.skyworker.de\/?p=151"},"modified":"2023-08-22T10:39:23","modified_gmt":"2023-08-22T08:39:23","slug":"powershell-auswertung-von-empirum-installationsauftraegen-fuer-einen-bestimmten-zeitraum-eines-rechners-oder-rechnergruppe","status":"publish","type":"post","link":"http:\/\/workplace.skyworker.de\/?p=151","title":{"rendered":"Powershell: Auswertung von Empirum Installationsauftr\u00e4gen f\u00fcr einen bestimmten Zeitraum eines Rechners, oder Rechnergruppe"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"151\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">0    <\/span>\r\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-dislike-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"151\" data-trigger-type=\"dislike\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-down\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\">0<\/span>\r\n<\/div><\/div><p>Im Kundenumfeld gab und gibt es oft die Anforderung, das man f\u00fcr einen Rechner, oder eine Rechnergruppe die \u00fcber Empirum durchgef\u00fchrten Installationen f\u00fcr einen Zeitraum x ermitteln soll, oder muss.<\/p>\n<p>Hierf\u00fcr habe ich ein Skript geschrieben welches die Paketinstallationen eines Rechners, oder einer Rechnergruppe f\u00fcr einen bestimmten Zeitraum auswertet. Dabei werden die Daten aus der Empirum Datenbank gelesen und in einem Excel Sheet aufbereitet zur Verf\u00fcgung gestellt.<!--more--><\/p>\n<p>Die Steuerung findet \u00fcber eine GUI statt.<br \/>\n<a href=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-165\" src=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_01.jpg\" alt=\"ps_auswertung_01\" width=\"418\" height=\"195\" srcset=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_01.jpg 418w, http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_01-300x139.jpg 300w\" sizes=\"(max-width: 418px) 85vw, 418px\" \/><\/a><\/p>\n<p>Bei der Auswertung werden die Benutzerteile eines Empirum Paketes herausgefiltert, so das nur die eigentlichen Paketinstallation \u00fcbrig bleiben.<\/p>\n<p><a href=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-166\" src=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_02.jpg\" alt=\"ps_auswertung_02\" width=\"863\" height=\"169\" srcset=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_02.jpg 863w, http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_02-300x58.jpg 300w, http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/ps_auswertung_02-624x122.jpg 624w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/a><\/p>\n<blockquote><p><span style=\"color: #000000;\"><strong><a href=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/Actions-help-about-icon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-136\" src=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/Actions-help-about-icon.png\" alt=\"Actions-help-about-icon\" width=\"32\" height=\"32\" \/><\/a> Tipp<\/strong><\/span>: \u00dcber die exclusion.ini k\u00f6nnen Pakete hinterlegt werden, die nicht in die Auswertung mit einbezogen werden sollen. Ebenfalls k\u00f6nnen die PatchInstallationen exkludiert werden.<\/p><\/blockquote>\n<p><em><strong>Hinweis: <\/strong>Im PowerShell Skript muss noch entsprechend der Datenbankserver und die Datenbank der Umgebung angepasst werden!<\/em><\/p>\n<p>Powershell Skript:\u00a0\u00a0 [ddownload id=163]<\/p>\n<p>[php]#&#8212;&#8211;Auslesen des Skriptpfad&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nfunction Get-ScriptDirectory {<br \/>\n$Invocation = (Get-Variable MyInvocation -Scope 1).Value<br \/>\nSplit-Path $Invocation.MyCommand.Path<br \/>\n}<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#&#8212;&#8211;Variablen&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n$global:cc_single_output = &quot;&quot;<br \/>\n$global:cc_multi_output = &quot;&quot;<br \/>\n$global:DataSet = &quot;&quot;<br \/>\n$cc_input_pcname = &quot;&quot;<br \/>\n$cc_input_datemin = &quot;&quot;<br \/>\n$cc_input_datemax = &quot;&quot;<br \/>\n$cc_input_customname = &quot;&quot;<br \/>\n$cc_input_checkpatches = &quot;no&quot;<br \/>\n$cc_input_checkexc = &quot;no&quot;<br \/>\n$cc_exclusion_file = Join-Path (Get-ScriptDirectory) exclusion.ini;<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#&#8212;&#8211;GUI&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n[void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Drawing&quot;)<br \/>\n[void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;)<\/p>\n<p>$objForm = New-Object System.Windows.Forms.Form<br \/>\n$objForm.Text = &quot;Empirum Auswertungs-Tool&quot;<br \/>\n$objForm.Size = New-Object System.Drawing.Size(600,280)<br \/>\n$objForm.StartPosition = &quot;CenterScreen&quot;<\/p>\n<p>$objForm.KeyPreview = $True<br \/>\n$objForm.Add_KeyDown({if ($_.KeyCode -eq &quot;Enter&quot;)<br \/>\n{$x=$objTextBox.Text;$objForm.Close()}})<br \/>\n$objForm.Add_KeyDown({if ($_.KeyCode -eq &quot;Escape&quot;)<br \/>\n{$objForm.Close()}})<\/p>\n<p>$OKButton = New-Object System.Windows.Forms.Button<br \/>\n$OKButton.Location = New-Object System.Drawing.Size(200,210)<br \/>\n$OKButton.Size = New-Object System.Drawing.Size(75,23)<br \/>\n$OKButton.Text = &quot;OK&quot;<br \/>\n$OKButton.Add_Click({$cc_input_customname=$objTextBox_Fname.Text; $cc_input_pcname=$objTextBox_PCName.Text;$cc_input_datemin=$objTextBox_startdate.Text;$cc_input_datemax=$objTextBox_enddate.Text;$objForm.Close()})<br \/>\n$objForm.Controls.Add($OKButton)<\/p>\n<p>$CancelButton = New-Object System.Windows.Forms.Button<br \/>\n$CancelButton.Location = New-Object System.Drawing.Size(320,210)<br \/>\n$CancelButton.Size = New-Object System.Drawing.Size(75,23)<br \/>\n$CancelButton.Text = &quot;Cancel&quot;<br \/>\n$CancelButton.Add_Click({$objForm.Close()})<br \/>\n$objForm.Controls.Add($CancelButton)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,20)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(400,20)<br \/>\n$objLabel.Text = &quot;PC Name\/n: (Mehrere PCs mit Semikolon trennen &gt;&gt; vm9900111;vm9900112)&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objTextBox_PCName = New-Object System.Windows.Forms.TextBox<br \/>\n$objTextBox_PCName.Location = New-Object System.Drawing.Size(10,40)<br \/>\n$objTextBox_PCName.Size = New-Object System.Drawing.Size(400,20)<br \/>\n$objForm.Controls.Add($objTextBox_PCName)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,70)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(120,20)<br \/>\n$FontBold = new-object System.Drawing.Font(&quot;Arial&quot;,8,[Drawing.FontStyle]&#8217;Bold&#8216; )<br \/>\n$objLabel.Font = $fontBold<br \/>\n$objLabel.Text = &quot;Auswertungszeitraum&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,90)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(160,20)<br \/>\n$objLabel.Text = &quot;Anfangsdatum (dd.mm.yyyy):&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objTextBox_startdate = New-Object System.Windows.Forms.TextBox<br \/>\n$objTextBox_startdate.Location = New-Object System.Drawing.Size(170,90)<br \/>\n$objTextBox_startdate.Size = New-Object System.Drawing.Size(100,20)<br \/>\n$objForm.Controls.Add($objTextBox_startdate)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(290,90)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(130,20)<br \/>\n$objLabel.Text = &quot;Enddatum (dd.mm.yyyy):&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objTextBox_Enddate = New-Object System.Windows.Forms.TextBox<br \/>\n$objTextBox_Enddate.Location = New-Object System.Drawing.Size(430,90)<br \/>\n$objTextBox_Enddate.Size = New-Object System.Drawing.Size(100,20)<br \/>\n$objForm.Controls.Add($objTextBox_Enddate)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,120)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(150,20)<br \/>\n$FontBold = new-object System.Drawing.Font(&quot;Arial&quot;,8,[Drawing.FontStyle]&#8217;Bold&#8216; )<br \/>\n$objLabel.Font = $fontBold<br \/>\n$objLabel.Text = &quot;Dateiname:&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objTextBox_Fname = New-Object System.Windows.Forms.TextBox<br \/>\n$objTextBox_Fname.Location = New-Object System.Drawing.Size(170,120)<br \/>\n$objTextBox_Fname.Size = New-Object System.Drawing.Size(100,20)<br \/>\n$objForm.Controls.Add($objTextBox_Fname)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(270,124)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(180,20)<br \/>\n$objLabel.Text = &quot;_01.01.2012_01.04.2012.xlsx&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,150)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(280,20)<br \/>\n$objLabel.Text = &quot;MS Patche in die Auswertung mit einbeziehen&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$Checkbox = new-object System.Windows.Forms.Checkbox<br \/>\n$Checkbox.Location = new-object System.Drawing.Size(290,150)<br \/>\n$Checkbox.size = new-object System.Drawing.Size(20,20)<br \/>\n$objForm.Controls.Add($Checkbox)<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,170)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(280,20)<br \/>\n$objLabel.Text = &quot;Paketausschl\u00fcsse in die Auswertung mit einbeziehen&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$CheckboxExc = new-object System.Windows.Forms.Checkbox<br \/>\n$CheckboxExc.Location = new-object System.Drawing.Size(290,170)<br \/>\n$CheckboxExc.size = new-object System.Drawing.Size(20,20)<br \/>\n$objForm.Controls.Add($CheckboxExc)<\/p>\n<p># Auswertung der Checkbox<br \/>\n$Checkbox.add_CheckStateChanged({<br \/>\nIf ($Checkbox.CheckState -eq &quot;unchecked&quot; )<br \/>\n{$cc_input_checkpatches = &quot;no&quot;}<br \/>\nElse<br \/>\n{$cc_input_checkpatches = &quot;yes&quot;}<br \/>\n})<\/p>\n<p># Auswertung der CheckboxExc<br \/>\n$CheckboxExc.add_CheckStateChanged({<br \/>\nIf ($CheckboxExc.CheckState -eq &quot;unchecked&quot; )<br \/>\n{$cc_input_checkexc = &quot;no&quot;}<br \/>\nElse<br \/>\n{$cc_input_checkexc = &quot;yes&quot;}<br \/>\n})<\/p>\n<p>$objForm.Topmost = $True<\/p>\n<p>$objForm.Add_Shown({$objForm.Activate()})<br \/>\n[void] $objForm.ShowDialog()<\/p>\n<p>#$cc_input_pcname = &quot;vm8700133&quot;<br \/>\n#$cc_input_datemin = &quot;20.03.2012&quot;<br \/>\n#$cc_input_datemax = &quot;24.04.2012&quot;<\/p>\n<p>If ($cc_input_pcname -eq &quot;&quot; -and $cc_input_datemin -eq &quot;&quot; -and $cc_input_datemax -eq &quot;&quot; -and $cc_input_customname -eq &quot;&quot;){<br \/>\nExit<br \/>\n}<\/p>\n<p>If ($cc_input_pcname -eq &quot;&quot;){<br \/>\n$wshshell = new-object -comobject wscript.shell<br \/>\n$Answer = $wshshell.popup(&quot;Es wurde kein PC Name angegeben. Die Auswertung wird abgebrochen!&quot;,30,&quot;Fehler&quot;,16)<br \/>\nExit<br \/>\n}<\/p>\n<p>If ($cc_input_datemin -eq &quot;&quot;){<br \/>\n$wshshell = new-object -comobject wscript.shell<br \/>\n$Answer = $wshshell.popup(&quot;Es wurde kein Startdatum angegeben. Die Auswertung wird abgebrochen!&quot;,30,&quot;Fehler&quot;,16)<br \/>\nExit<br \/>\n}<\/p>\n<p>If ($cc_input_datemax -eq &quot;&quot;){<br \/>\n$wshshell = new-object -comobject wscript.shell<br \/>\n$Answer = $wshshell.popup(&quot;Es wurde kein Enddatum angegeben. Die Auswertung wird abgebrochen!&quot;,30,&quot;Fehler&quot;,16)<br \/>\nExit<br \/>\n}<\/p>\n<p>If ($cc_input_customname -eq &quot;&quot;){<br \/>\n$wshshell = new-object -comobject wscript.shell<br \/>\n$Answer = $wshshell.popup(&quot;Es wurde kein Dateiname angegeben. Die Auswertung wird abgebrochen!&quot;,30,&quot;Fehler&quot;,16)<br \/>\nExit<br \/>\n}<\/p>\n<p>$cc_input_pcname_split = $cc_input_pcname.split(&quot;;&quot;)<\/p>\n<p>$cc_datum_date_min = get-date ($cc_input_datemin)<br \/>\n$cc_datum_date_max = get-date ($cc_input_datemax)<br \/>\n##Da der aktuelle Tag im Max wert nicht ber\u00fccksichtigt wird<br \/>\n$cc_datum_date_max = $cc_datum_date_max.AddDays(1)<\/p>\n<p>#&#8212;&#8211;Einlesen der ini Datei f\u00fcr die Paketausschl\u00fcsse&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nIf ($cc_input_checkexc -eq &quot;yes&quot;){<br \/>\nIf (test-path $cc_exclusion_file) {<br \/>\n$cc_input_exclusion = Get-Content $cc_exclusion_file<br \/>\n}<br \/>\nElse {<br \/>\n$wshshell = new-object -comobject wscript.shell<br \/>\n$Answer = $wshshell.popup(&quot;Ausschlussdatei exclusion.ini existiert nicht im Skriptverzeichnis. Die Auswertung wird abgebrochen!&quot;,30,&quot;Fehler&quot;,16)<br \/>\nExit<br \/>\n}<br \/>\n}<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>#&#8212;&#8211;Erstellen eines xlsx&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n$Excel = New-Object -ComObject excel.application<br \/>\n$Excel.visible = $false<br \/>\n$workbook = $Excel.workbooks.add()<\/p>\n<p>$excel.cells.item(1,1) = &quot;PC-Systeme&quot;<br \/>\n$excel.cells.item(1,2) = &quot;$cc_input_pcname&quot;<\/p>\n<p>$excel.cells.item(3,1) = &quot;Zeitraum&quot;<br \/>\n$excel.cells.item(3,2) = &quot;$cc_input_datemin bis $cc_input_datemax&quot;<\/p>\n<p>$excel.cells.item(5,1) = &quot;Anzahl an Auftr\u00e4gen&quot;<br \/>\n$excel.cells.item(5,3) = &quot;Benutzerteile ausgeschlossen!&quot;<\/p>\n<p>$excel.cells.item(7,1) = &quot;Nr.&quot;<br \/>\n$excel.cells.item(7,2) = &quot;Datum&quot;<br \/>\n$excel.cells.item(7,3) = &quot;PC Name&quot;<br \/>\n$excel.cells.item(7,4) = &quot;Software&quot;<br \/>\n$excel.cells.item(7,5) = &quot;Installationsmodus&quot;<br \/>\n$excel.cells.item(7,6) = &quot;Ergebnis&quot;<\/p>\n<p>$excel.cells.item(1,1).Font.Bold = $True<br \/>\n$excel.cells.item(3,1).Font.Bold = $True<br \/>\n$excel.cells.item(5,1).Font.Bold = $True<br \/>\n$excel.cells.item(7,1).Font.Bold = $True<br \/>\n$excel.cells.item(7,2).Font.Bold = $True<br \/>\n$excel.cells.item(7,3).Font.Bold = $True<br \/>\n$excel.cells.item(7,4).Font.Bold = $True<br \/>\n$excel.cells.item(7,5).Font.Bold = $True<br \/>\n$excel.cells.item(7,6).Font.Bold = $True<br \/>\n$excel.cells.item(5,3).Font.Italic = $True<\/p>\n<p>$excel.cells.item(1,2).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(3,2).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(5,2).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(7,1).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(7,2).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(7,3).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(7,4).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(7,5).Interior.ColorIndex = 37<br \/>\n$excel.cells.item(7,6).Interior.ColorIndex = 37<\/p>\n<p>#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#&#8212;-Datenbankzugriff \/ Auslesen der Pakete \/ Ablage in Datei&#8211;<br \/>\nfunction execute-sql-multi-output {<br \/>\nparam (<br \/>\n[string]$dbserver,<br \/>\n[string]$db,<br \/>\n[string]$SQLCommand<br \/>\n)<\/p>\n<p>#Connection to SQL-Server<br \/>\n$SqlConnection = New-Object System.Data.SqlClient.SqlConnection<br \/>\n$SqlConnection.ConnectionString = &quot;Server = $dbserver; Database = $db; Integrated Security = True&quot;<\/p>\n<p>$SqlCmd = New-Object System.Data.SqlClient.SqlCommand<br \/>\n$SqlCmd.CommandText = $SQLCommand<br \/>\n$SqlCmd.Connection = $SqlConnection<\/p>\n<p>$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter<br \/>\n$SqlAdapter.SelectCommand = $SqlCmd<\/p>\n<p>$global:cc_multi_output = New-Object System.Data.DataSet<br \/>\n$SqlAdapter.Fill($global:cc_multi_output)<br \/>\n$SqlConnection.Close()<br \/>\n}<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>$excel_line = 8<br \/>\nforeach ($cc_pcname in $cc_input_pcname_split){<br \/>\n#&#8212;&#8211;Ausf\u00fchren der Funktion zur Abfrage der Client ID&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n$cc_output_count = execute-sql-multi-output &quot;empirumpro&quot; &quot;empirumdb&quot; &quot;SELECT client_id FROM Clients where name = &#8218;$cc_pcname&#8217;&quot;<br \/>\n$h = 0<br \/>\n$cc_clientid = &quot;&quot;<br \/>\nforeach ($entry in $global:cc_multi_output.Tables[0]){<br \/>\n$cc_clientid = $global:cc_multi_output.Tables[0].Rows[$h][0]<br \/>\n$h++<br \/>\n}<\/p>\n<p>#Wenn der Name nicht gefunden wird, wird ein break ausgef\u00fchrt<br \/>\nIf ($cc_clientid -eq &quot;&quot;){<br \/>\ncls<br \/>\n#Ausgabetext<br \/>\nwrite-host &quot;&quot;<br \/>\nwrite-host &quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&quot;<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Bitte warten&#8230;&quot;<br \/>\nwrite-host &quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&quot;<br \/>\nwrite-host &quot;&quot;<br \/>\nwrite-host &quot;PC &quot; $cc_pcname &quot; wurde in der Datenbank nicht gefunden&quot;<br \/>\nstart-sleep -s 4<br \/>\nBreak<br \/>\n}<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#&#8212;&#8211;Ausf\u00fchren der Funktion zur Abfrage der Auftr\u00e4ge des entsprechenden Clients&#8211;<br \/>\n$cc_output_count = execute-sql-multi-output &quot;empirumpro&quot; &quot;empirumdb&quot; &quot;SELECT * FROM ArchiveDistJobs where ClientID = &#8218;$cc_clientid&#8217;&quot;<br \/>\n$i = 0<br \/>\nforeach ($entry in $global:cc_multi_output.Tables[0]){<br \/>\n$cc_clickdown = 0<br \/>\ncls<\/p>\n<p>#Formatierung der R\u00fcckgabewerte<br \/>\n$cc_datum = $global:cc_multi_output.Tables[0].Rows[$i][1]<br \/>\n$cc_software = $global:cc_multi_output.Tables[0].Rows[$i][7]<br \/>\n$cc_mode = $global:cc_multi_output.Tables[0].Rows[$i][11]<br \/>\n$cc_result = $global:cc_multi_output.Tables[0].Rows[$i][12]<\/p>\n<p>$cc_datum_str = [STRING]$cc_datum<br \/>\n$cc_datum_dd = &quot;{0:dd.MM.yyyy}&quot; -f [datetime]$cc_datum<br \/>\n$cc_software_str = [STRING]$cc_software<br \/>\n$cc_mode_str = [STRING]$cc_mode<br \/>\n$cc_result_str = [STRING]$cc_result<br \/>\n$cc_datum_date = get-date ($cc_datum)<\/p>\n<p>#Ausgabetext<br \/>\nwrite-host &quot;&quot;<br \/>\nwrite-host &quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&quot;<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Bitte warten&#8230;&quot;<br \/>\nwrite-host &quot;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&quot;<br \/>\nwrite-host &quot;&quot;<br \/>\nwrite-host &quot;\u00dcberpr\u00fcfung der Softwareauftr\u00e4ge in der Datenbank f\u00fcr PC &quot; $cc_pcname &quot;: &quot; $i<br \/>\nwrite-host $cc_software_str<\/p>\n<p>If ($cc_datum_date -gt $cc_datum_date_min){<br \/>\nIf ($cc_datum_date -le $cc_datum_date_max){<br \/>\nIf ($cc_mode -match &quot;User&quot;) {$cc_clickdown = 1}<br \/>\nIf ($cc_input_checkpatches -eq &quot;no&quot;) {<br \/>\nIf ($cc_software_str -match &quot;Security Update for&quot; -or $cc_software_str -match &quot;Update for Windows&quot; -or $cc_software_str -match &quot;Cumulative Security Update for&quot; -or $cc_software_str -match &quot;Critical Update for Office&quot; -or $cc_software_str -match &quot;Update for Office&quot; -or $cc_software_str -match &quot;Update for Microsoft&quot; -or $cc_software_str -match &quot;Microsoft Office Compatibility Pack Service&quot; -or $cc_software_str -match &quot;Service Pack 3 for Visio&quot; -or $cc_software_str -match &quot;co-install of .net 3.0 sp&quot; -or $cc_software_str -match &quot;Microsoft .NET Framework 2.0 Service Pack&quot; -or $cc_software_str -match &quot;Microsoft .NET Framework 3.0 Service Pack&quot; -or $cc_software_str -match &quot;Microsoft .NET Framework 3.5 Service Pack&quot; -or $cc_software_str -match &quot;Microsoft .NET Framework 3.5 Family Update&quot; -or $cc_software_str -match &quot;Service Pack 3 for Visio&quot;)<br \/>\n{$cc_clickdown = 1}<br \/>\n}<br \/>\nIf ($cc_input_checkexc -eq &quot;yes&quot;){<br \/>\nforeach ($cc_exclusion in $cc_input_exclusion) {<br \/>\nIf ($cc_exclusion -eq $cc_software_str){$cc_clickdown = 1}<br \/>\n}<br \/>\n}<\/p>\n<p>If ($cc_clickdown -eq 0){<br \/>\n$cc_nr = $excel_line &#8211; 7<br \/>\n$excel.cells.item($excel_line,1) = &quot;$cc_nr&quot;<br \/>\n$excel.cells.item($excel_line,2) = &quot;$cc_datum_dd&quot;<br \/>\n$excel.cells.item($excel_line,3) = &quot;$cc_pcname&quot;<br \/>\n$excel.cells.item($excel_line,4) = &quot;$cc_software_str&quot;<br \/>\n$excel.cells.item($excel_line,5) = &quot;$cc_mode_str&quot;<br \/>\n$excel.cells.item($excel_line,6) = &quot;$cc_result_str&quot;<br \/>\n$excel_line++<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n$i++<br \/>\n}<br \/>\n}<br \/>\n#&#8212;&#8211;Speichern des Excel Files&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n$cc_filename = &quot;Auswertungen\\&quot; + $cc_input_customname + &quot;_&quot; + $cc_input_datemin + &quot;_&quot; + $cc_input_datemax + &quot;.xlsx&quot;<br \/>\n$cc_xlsx_file = Join-Path (Get-ScriptDirectory) $cc_filename;<br \/>\n$excel.cells.item(5,2) = &quot;$cc_nr&quot;<br \/>\nIf (test-path $cc_xlsx_file) {Remove-Item $cc_xlsx_file}<br \/>\n$Excel.Cells.EntireColumn.AutoFit()<br \/>\n$workbook.saveas($cc_xlsx_file)<br \/>\n$Excel.Quit()<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#&#8212;&#8211;\u00d6ffnen des Excel Sheets&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nStart-Process Excel -ArgumentList $cc_xlsx_file<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>0 0 Im Kundenumfeld gab und gibt es oft die Anforderung, das man f\u00fcr einen Rechner, oder eine Rechnergruppe die \u00fcber Empirum durchgef\u00fchrten Installationen f\u00fcr einen Zeitraum x ermitteln soll, oder muss. Hierf\u00fcr habe ich ein Skript geschrieben welches die Paketinstallationen eines Rechners, oder einer Rechnergruppe f\u00fcr einen bestimmten Zeitraum auswertet. Dabei werden die Daten &hellip; <a href=\"http:\/\/workplace.skyworker.de\/?p=151\" class=\"more-link\"><span class=\"screen-reader-text\">\u201ePowershell: Auswertung von Empirum Installationsauftr\u00e4gen f\u00fcr einen bestimmten Zeitraum eines Rechners, oder Rechnergruppe\u201c<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":1829,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,11,3,38],"tags":[5,9],"_links":{"self":[{"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/151"}],"collection":[{"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151"}],"version-history":[{"count":14,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"predecessor-version":[{"id":1837,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions\/1837"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/media\/1829"}],"wp:attachment":[{"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}