{"id":520,"date":"2014-02-27T18:38:44","date_gmt":"2014-02-27T16:38:44","guid":{"rendered":"http:\/\/workplace.skyworker.de\/?p=520"},"modified":"2023-08-22T10:39:21","modified_gmt":"2023-08-22T08:39:21","slug":"powershell-auslesen-welche-software-sich-in-welcher-softwareklasse-befindet","status":"publish","type":"post","link":"http:\/\/workplace.skyworker.de\/?p=520","title":{"rendered":"Powershell: Auslesen welche Empirum Software sich in welcher Empirum Softwareklasse befindet"},"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=\"520\" 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=\"520\" 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 style=\"text-align: justify;\">F\u00fcr die, die in Empirum mit sehr vielen Softwareklassen arbeiten habe ich ein kleines PowerShell Skript geschrieben, \u00fcber das gepr\u00fcft werden kann, in welchen Softwareklassen sich eine Software befindet.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2014\/02\/ps_sc_001.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-523\" src=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2014\/02\/ps_sc_001-300x121.jpg\" alt=\"ps_sc_001\" width=\"300\" height=\"121\" srcset=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2014\/02\/ps_sc_001-300x121.jpg 300w, http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2014\/02\/ps_sc_001.jpg 606w\" sizes=\"(max-width: 300px) 85vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\"><!--more--><\/p>\n<p style=\"text-align: justify;\">Um das Skript verwenden zu k\u00f6nnen, muss die Variable <strong><span style=\"color: #0000ff;\">$global:cc_database_server<\/span><\/strong>\u00a0 mit dem Namen des Datenbankservers (Dantenbankservername\\Instanzname), sowie die Variable <span style=\"color: #0000ff;\"><strong>$global:cc_database_db<\/strong><\/span> mit dem Namen der Datenbank bef\u00fcllt werden.<\/p>\n<pre>#-----Variablen-------------------------------------------------------------\r\n$global:cc_database_server = \"<strong>EmpirumServer\\SQLExpress<\/strong>\"\r\n$global:cc_database_db = \"<strong>EmpirumDB<\/strong>\"<\/pre>\n<p style=\"text-align: justify;\">Powershell Skript:\u00a0\u00a0 [ddownload id=522]<\/p>\n<p>[php]cls<\/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_database_server = &quot;empirumserver\\instanz&quot;<br \/>\n$global:cc_database_db = &quot;Empirum&quot;<br \/>\n$global:cc_multi_output1 = &quot;&quot;<br \/>\n$global:cc_multi_output2 = &quot;&quot;<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;Auslesen des Skriptpfades&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n$global:ScriptDir = Split-Path<br \/>\n$MyInvocation.MyCommand.Path \u2013Parent<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;-Datenbankzugriff \/ Auslesen der Pakete \/ Ablage in Datei&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nfunction execute-sql-multi-output1 {<br \/>\nparam (<br \/>\n[string]$dbserver,<br \/>\n[string]$db,<br \/>\n[string]$SQLCommand<br \/>\n)<\/p>\n<p>#Connection to SQL-Server \u00a0$SqlConnection = New-Object System.Data.SqlClient.SqlConnection \u00a0$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 $SqlAdapter.SelectCommand = $SqlCmd<\/p>\n<p>$global:cc_multi_output1 = New-Object System.Data.DataSet \u00a0$SqlAdapter.Fill($global:cc_multi_output1) \u00a0$SqlConnection.Close() \u00a0 }<\/p>\n<p>$cc_output_count = execute-sql-multi-output1 &quot;$global:cc_database_server&quot; &quot;$global:cc_database_db&quot; &quot;SELECT * FROM Classes&quot;<br \/>\n$global:cc_ClassesInfo = $global:cc_multi_output1 \u00a0 $global:cc_multi_output1 = &quot;&quot;<\/p>\n<p>$cc_output_count = execute-sql-multi-output1 &quot;$global:cc_database_server&quot; &quot;$global:cc_database_db&quot; &quot;SELECT * FROM ClassesToSoftware&quot;<br \/>\n$global:cc_ClassesToSoftware = $global:cc_multi_output1 \u00a0 $global:cc_multi_output1 = &quot;&quot;<\/p>\n<p>$cc_output_count = execute-sql-multi-output1 &quot;$global:cc_database_server&quot; &quot;$global:cc_database_db&quot; &quot;SELECT * FROM Software&quot;<br \/>\n$global:cc_Software = $global:cc_multi_output1 \u00a0 $global:cc_multi_output1 = &quot;&quot;<\/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>function fu_search () {<br \/>\n$Global:SelectedSoftware = $objComboBox.SelectedItem.ToString()<br \/>\n$Global:ClassesIDArray = @()<br \/>\n$Global:ClassesNameArray = @()<br \/>\n$global:output = &quot;&quot;<\/p>\n<p>$h=0<br \/>\nforeach ($entry in $global:cc_Software.Tables[0]){<br \/>\n$cc_Software_SoftwareID = $global:cc_Software.Tables[0].Rows[$h][0]<br \/>\n$cc_Software_SoftwareName = $global:cc_Software.Tables[0].Rows[$h][3]<br \/>\nIf ($cc_Software_SoftwareName -eq $Global:SelectedSoftware){<br \/>\nbreak<br \/>\n}<br \/>\n$h++<br \/>\n}<\/p>\n<p>$h=0<br \/>\nforeach ($entry in $global:cc_ClassesToSoftware.Tables[0]){<br \/>\n$cc_ClassesToSoftware_ClassesID = $global:cc_ClassesToSoftware.Tables[0].Rows[$h][0]<br \/>\n$cc_ClassesToSoftware_SoftwareID = $global:cc_ClassesToSoftware.Tables[0].Rows[$h][1]<br \/>\nIf ($cc_ClassesToSoftware_SoftwareID -eq $cc_Software_SoftwareID){<br \/>\n$Global:ClassesIDArray += $cc_ClassesToSoftware_ClassesID<br \/>\n}<br \/>\n$h++<br \/>\n}<\/p>\n<p>$h=0<br \/>\nforeach ($entry in $global:cc_ClassesInfo.Tables[0]){<br \/>\n$cc_Classes_ClassesID = $global:cc_ClassesInfo.Tables[0].Rows[$h][0]<br \/>\n$cc_Classes_Name = $global:cc_ClassesInfo.Tables[0].Rows[$h][2]<br \/>\nforeach ($value in $Global:ClassesIDArray){<br \/>\nIf ($value -eq $cc_Classes_ClassesID){<br \/>\n$Global:ClassesNameArray += $cc_Classes_Name<br \/>\n}<br \/>\n}<br \/>\n$h++<br \/>\n}<\/p>\n<p>foreach ($entry in $Global:ClassesNameArray){<br \/>\n$global:output = $global:output + $entry + &quot;`r`n&quot;<br \/>\n}<\/p>\n<p>If ($global:output) {$objTextBox1.Text = &quot;$global:output&quot;}<br \/>\nElse {$objTextBox1.Text = &quot;Keine Zuweisung&quot;}<\/p>\n<p>$objForm.Update()<\/p>\n<p>}<\/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;&#8211;GUI&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- \u00a0 [void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Drawing&quot;) \u00a0 [void] [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;)<\/p>\n<p>$objForm = New-Object System.Windows.Forms.Form \u00a0 $objForm.Text = &quot;Matrix42 Empirum Software Classes&quot; \u00a0 $objForm.Size = New-Object System.Drawing.Size(600,240) \u00a0 $objForm.StartPosition = &quot;CenterScreen&quot; \u00a0 $objForm.autoscroll = $false \u00a0 $objForm.FormBorderStyle = 3<\/p>\n<p>$objForm.KeyPreview = $True \u00a0 $objForm.Add_KeyDown({if ($_.KeyCode -eq &quot;Enter&quot;){fu_search}}) \u00a0 $objForm.Add_KeyDown({if ($_.KeyCode -eq &quot;Escape&quot;){$objForm.Close()}})<\/p>\n<p>$objLabel = New-Object System.Windows.Forms.Label<br \/>\n$objLabel.Location = New-Object System.Drawing.Size(10,32)<br \/>\n$objLabel.Size = New-Object System.Drawing.Size(120,20)<br \/>\n$objLabel.Font = new-object System.Drawing.Font(&quot;Arial&quot;,11,[Drawing.FontStyle]&#8217;regular&#8216; ) \u00a0 $objLabel.Text = &quot;Softwarename&quot;<br \/>\n$objForm.Controls.Add($objLabel)<\/p>\n<p>$objComboBox = new-object System.Windows.Forms.ComboBox<br \/>\n$objComboBox.Location = new-object System.Drawing.Size(130,32)<br \/>\n$objComboBox.Size = new-object System.Drawing.Size(420,20)<br \/>\n$objComboBox.Font = new-object System.Drawing.Font(&quot;Arial&quot;,9 )<br \/>\n$j=0<br \/>\nforeach ($entry in $global:cc_Software.Tables[0]){<br \/>\n$cc_Software_SoftwareName = $global:cc_Software.Tables[0].Rows[$j][3]<br \/>\n$objComboBox.Items.Add($cc_Software_SoftwareName) \u00a0$j++ \u00a0 }<br \/>\n$objComboBox.Sorted = $true<br \/>\n$objForm.Controls.Add($objComboBox)<\/p>\n<p>$SearchButton = New-Object System.Windows.Forms.Button<br \/>\n$SearchButton.Location = New-Object System.Drawing.Size(260,60)<br \/>\n$SearchButton.Size = New-Object System.Drawing.Size(80,23)<br \/>\n$SearchButton.Font = new-object System.Drawing.Font(&quot;Arial&quot;,10,[Drawing.FontStyle]&#8217;bold&#8216; ) \u00a0 $SearchButton.Text = &quot;Suchen&#8230;&quot;<br \/>\n$SearchButton.Add_Click({fu_search})<br \/>\n$objForm.Controls.Add($SearchButton)<\/p>\n<p>$objTextBox1 = New-Object System.Windows.Forms.TextBox<br \/>\n$objTextBox1.Location = New-Object System.Drawing.Size(10,100)<br \/>\n$objTextBox1.Size = New-Object System.Drawing.Size(450,100)<br \/>\n$objTextBox1.Multiline = $true<br \/>\n$objTextBox1.ScrollBars = &quot;Vertical&quot;<br \/>\n$objTextBox1.Text = &quot;&quot;<br \/>\n$objForm.Controls.Add($objTextBox1)<\/p>\n<p>$CancelButton = New-Object System.Windows.Forms.Button<br \/>\n$CancelButton.Location = New-Object System.Drawing.Size(500,177)<br \/>\n$CancelButton.Size = New-Object System.Drawing.Size(80,23)<br \/>\n$CancelButton.Font = new-object System.Drawing.Font(&quot;Arial&quot;,10,[Drawing.FontStyle]&#8217;bold&#8216; ) \u00a0 $CancelButton.Text = &quot;Close&quot;<br \/>\n$CancelButton.Add_Click({$objForm.Close()})<br \/>\n$objForm.Controls.Add($CancelButton)<\/p>\n<p>$objForm.Topmost = $True<\/p>\n<p>$objForm.Add_Shown({$objForm.Activate()})<br \/>\n[void] $objForm.ShowDialog()<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<p style=\"text-align: justify;\">\n","protected":false},"excerpt":{"rendered":"<p>0 0 F\u00fcr die, die in Empirum mit sehr vielen Softwareklassen arbeiten habe ich ein kleines PowerShell Skript geschrieben, \u00fcber das gepr\u00fcft werden kann, in welchen Softwareklassen sich eine Software befindet.<\/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":[128,9],"_links":{"self":[{"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/520"}],"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=520"}],"version-history":[{"count":9,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/520\/revisions"}],"predecessor-version":[{"id":1835,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/520\/revisions\/1835"}],"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=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}