{"id":147,"date":"2012-08-10T16:28:14","date_gmt":"2012-08-10T14:28:14","guid":{"rendered":"http:\/\/workplace.skyworker.de\/?p=147"},"modified":"2023-08-22T10:39:23","modified_gmt":"2023-08-22T08:39:23","slug":"auslesen-von-device-name-mac-adress-und-device-collection-aus-der-pvs-datenbank","status":"publish","type":"post","link":"http:\/\/workplace.skyworker.de\/?p=147","title":{"rendered":"Powershell: Auslesen von Device Name, MAC Adress und Device Collection aus der PVS Datenbank"},"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=\"147\" 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=\"147\" 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><div>\n<p style=\"text-align: justify;\">Um bestehende End-Systeme aus einer Provisioning Server Umgebung auszulesen, damit man diese in Empirum importieren kann, kann das folgende PowerShell Skript verwendet.<\/p>\n<p style=\"text-align: justify;\">Dieses Skript liest den PC Namen, die Mac Adresse und die Device Collection eines jeden End-Systems aus und schreibt diese Kommagetrennt in eine Ausgabedatei. Bei der MAC Adresse werden zus\u00e4tzlich noch die Bindestriche herausgefiltert, um diese f\u00fcr den Import in Empirum verwenden zu k\u00f6nnen.<!--more--><\/p>\n<\/div>\n<blockquote>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong><a href=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/bt-attention-icon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-91\" alt=\"bt-attention-icon\" src=\"http:\/\/workplace.skyworker.de\/wp-content\/uploads\/2013\/11\/bt-attention-icon.png\" width=\"32\" height=\"32\" \/><\/a> Hinweis<\/strong><\/span>: Das Skript sollte man direkt auf dem Provisioning Server ausf\u00fchren, da eine installierte Provisioning Server Console vorausgesetzt wird. Zus\u00e4tzlich muss die Powershell executionpolicy angepasst werden, damit das ausf\u00fchren von Skripten erlaubt wird.<\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">Um das Skript verwenden zu k\u00f6nnen, m\u00fcssen die folgenden 4 Variablen im Skript angepasst werden:<\/p>\n<blockquote><p>$servernameConnection = &#8222;<strong>IP Address of the PVS Server<\/strong>&#8220;<br \/>\n$username = &#8222;<strong>Domain Account with PVS Admin rights<\/strong>&#8220;<br \/>\n$domainNetBiosName = &#8222;<strong>Domain Name<\/strong>&#8220;<br \/>\n$password = &#8222;<strong>PVS Admin Account Password<\/strong>&#8222;<\/p><\/blockquote>\n<p style=\"text-align: justify;\">Wenn das Skript ausgef\u00fchrt wird, wird im Skriptordner eine Ausgabedatei mit dem folgenden Ausgabeformat angelegt:<\/p>\n<blockquote><p>PC0102,45012ABC494C,DC_Production,<br \/>\nPC0103,45012ABC4942,DC_Production,<br \/>\nPC0104,45012ABC6277,DC_Integration,<br \/>\nPC0001,45012ABC708A,DC_Installation,<br \/>\nPC0002,45012ABC70B0,DC_Test,<\/p><\/blockquote>\n<p>Powershell Skript:\u00a0\u00a0 [ddownload id=178]<\/p>\n<p>[php]#Variable##################################################################################<br \/>\n$servernameConnection = &quot;IP Address of the PVS Server&quot;<br \/>\n$username = &quot;Domain Account with PVS Admin rights&quot;<br \/>\n$domainNetBiosName = &quot;Domain Name&quot;<br \/>\n$password = &quot;PVS Admin Account Password&quot;<br \/>\n###########################################################################################<\/p>\n<p>#Register the PowerShell Snap-In<br \/>\n$installutil = $env:systemroot + &#8218;\\Microsoft.NET\\Framework\\v2.0.50727\\installutil.exe&#8216;<br \/>\n&amp;$installutil McliPSSnapIn.dll<\/p>\n<p>$installutil = $env:systemroot + &#8218;\\Microsoft.NET\\Framework64\\v2.0.50727\\installutil.exe&#8216;<br \/>\n&amp;$installutil McliPSSnapIn.dll<\/p>\n<p>#Loading PVS MCLI CmdLet#####<br \/>\nfunction LoadCmdLet_PVS (){<br \/>\nwrite-host &quot;Loading Citrix PVS MCLI, please wait&#8230;&quot;<\/p>\n<p>get-pssnapin -name McliPSSnapin<br \/>\nif ($? -eq &quot;True&quot;){<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0\u00a0 CtxPvsMCLI &#8211; Loading Citrix PVS MCLI exist &#8211; done&quot;<br \/>\n}<br \/>\nElse{<br \/>\nAdd-PSSnapin -Name McliPSSnapIn<br \/>\nIf ($? -eq &quot;True&quot;){<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0 CtxPvsMCLI &#8211; Loading Citrix PVS MCLI &#8211; done&quot;<br \/>\n}<br \/>\nElse{<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0\u00a0 CtxPvsMCLI &#8211; Loading Citrix PVS MCLI &#8211; failed&quot;<br \/>\nexit<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>#Connect to PVS server#####<br \/>\nfunction ConnectManagementServer_PVS (){<br \/>\nwrite-host &quot;Connecting to Citrix PVS server, please wait&#8230;&quot;<\/p>\n<p>Mcli-Run SetupConnection -p server=$servernameConnection, user=$username, domain=$domainNetBiosName, password=$password<br \/>\nIf ($? -eq &quot;True&quot;){<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0\u00a0 CtxPvsMCLI &#8211; Connecting to Citrix PVS server &#8211; done&quot;<br \/>\n}<br \/>\nElse {<br \/>\nwrite-host &quot;\u00a0\u00a0\u00a0\u00a0 CtxPvsMCLI &#8211; Connecting to Citrix PVS server &#8211; failed&quot;<br \/>\nexit<br \/>\n}<br \/>\n}<\/p>\n<p>#Get Script directory#####<br \/>\nfunction Get-ScriptDirectory{<br \/>\n$Invocation = (Get-Variable MyInvocation -Scope 1).Value<br \/>\nSplit-Path $Invocation.MyCommand.Path<br \/>\n}<\/p>\n<p>LoadCmdLet_PVS<br \/>\n#ConnectManagementServer_PVS<\/p>\n<p>#Output file#####<br \/>\n$OutPutFile = Join-Path (Get-ScriptDirectory) out_pvs.log<br \/>\nIf (test-path $OutPutFile) {Remove-Item $OutPutFile}<\/p>\n<p>#Get devicenames#####<br \/>\n$cc_devices = mcli-get device -f devicename | select-string devicename<\/p>\n<p>#Get information from devices#####<br \/>\nforeach ($cc_device in $cc_devices){<br \/>\n$cc_devicename_string = [string]$cc_device<br \/>\n$cc_devicename_string = $cc_devicename_string.substring(12)<br \/>\n$cc_deviceout = mcli-get device -p devicename=$cc_devicename_string -f devicename, devicemac, collectionname<\/p>\n<p>$cc_devicemac = $cc_deviceout | select-string devicemac<br \/>\n$cc_devicemac_string = [string]$cc_devicemac<br \/>\n$cc_devicemac_string = $cc_devicemac_string.substring(11)<br \/>\n$cc_devicemac_string = $cc_devicemac_string -replace &quot;-&quot;,&quot;&quot;<\/p>\n<p>$cc_devicecollectionname = $cc_deviceout | select-string collectionname<br \/>\n$cc_devicecollectionname_string = [string]$cc_devicecollectionname<br \/>\n$cc_devicecollectionname_string = $cc_devicecollectionname_string.substring(16)<\/p>\n<p>write-host $cc_devicename_string<br \/>\nwrite-host $cc_devicemac_string<br \/>\nwrite-host $cc_devicecollectionname_string<\/p>\n<p>$OutputLog = $cc_devicename_string + &quot;,&quot; + $cc_devicemac_string + &quot;,&quot; + $cc_devicecollectionname_string + &quot;,&quot; + [STRING]$cc_devicepers<\/p>\n<p>$OutputLog | out-file -Append $OutPutFile<br \/>\n}<\/p>\n<p>[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>0 0 Um bestehende End-Systeme aus einer Provisioning Server Umgebung auszulesen, damit man diese in Empirum importieren kann, kann das folgende PowerShell Skript verwendet. Dieses Skript liest den PC Namen, die Mac Adresse und die Device Collection eines jeden End-Systems aus und schreibt diese Kommagetrennt in eine Ausgabedatei. Bei der MAC Adresse werden zus\u00e4tzlich noch &hellip; <a href=\"http:\/\/workplace.skyworker.de\/?p=147\" class=\"more-link\"><span class=\"screen-reader-text\">\u201ePowershell: Auslesen von Device Name, MAC Adress und Device Collection aus der PVS Datenbank\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,16,11,3,38,130],"tags":[5,9,23],"_links":{"self":[{"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/147"}],"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=147"}],"version-history":[{"count":5,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions"}],"predecessor-version":[{"id":149,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=\/wp\/v2\/posts\/147\/revisions\/149"}],"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=147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=147"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/workplace.skyworker.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}