{"id":255,"date":"2010-06-15T08:56:04","date_gmt":"2010-06-15T08:56:04","guid":{"rendered":"https:\/\/www.buarotti.ch\/?p=255"},"modified":"2010-06-27T08:59:55","modified_gmt":"2010-06-27T08:59:55","slug":"win-7-notizen-powershell","status":"publish","type":"post","link":"https:\/\/www.buarotti.ch\/?p=255","title":{"rendered":"Win 7 &#8211; Powershell Grundlagen"},"content":{"rendered":"<p><strong>Powershell Grundlagen<\/strong><\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nget-command *process*\r\nGet-Command *process* -type cmdlet\r\nGet-Process | Get-Member\r\nGet-ExecutionPolicy\r\nget-process | sort-Object CPU -Descending | Select-Object processname, cpu, id | format-Table -autosize\r\nget-service | where-object {$_.status -eq &quot;running&quot;}\r\nget-eventlog system | out-gridview\r\nget-eventlog system | where-object {$_.entrytype -eq &quot;error&quot;}\r\nget-eventlog system | where-object {$_.entrytype -eq &quot;error&quot;} | Select-Object -First 5\r\n<\/pre>\n<p><strong><!--more-->Powershell (service mit autostart, welche gestoppt sind)<\/strong><\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n&lt;address&gt;Get-Service spooler | format-list *\r\nGet-Service spooler | format-list *\r\nGet-Service | Get-Member\r\nGet-WmiObject win32_service\r\nGet-WmiObject win32_service | Where-Object {$_.state -eq  \u201cstopped\u201d -and $_.startmode-eq \u201cauto\u201d}\r\nGet-WmiObject win32_service | Where-Object {$_.state -eq  \u201cstopped\u201d -and $_.startmode-eq \u201cauto\u201d}\r\nGet-WmiObject win32_service | Where-Object {$_.state -eq  \u201cstopped\u201d -and $_.startmode-eq \u201cauto\u201d} | start-service\r\nGet-WmiObject win32_service | Where-Object {$_.state -eq  \u201cstopped\u201d -and $_.startmode-eq \u201cauto\u201d}\r\n<\/pre>\n<p><strong>Powershell Remotekonfiguration<\/strong><\/p>\n<p>Konfiguriere Powershell dazu remote verbindungen zu zu lassen.<\/p>\n<address><\/address>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">enable-psremoting<\/pre>\n<address> <\/address>\n<p>Weiter muss der Windows Service winRM eingerichtet werden.<br \/>\nDies geschiecht via folgendes CMD Command<\/p>\n<address><\/address>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">winrm \/quickconfig <\/pre>\n<p><strong>Powershell Scriptausf\u00fchrungs Security Policy<\/strong><\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nGet-ExecutionPolicy\r\nSet-ExecutionPolicy unrestricted\r\n<\/pre>\n<p><strong>Abfrage erstellen f\u00fcr mehrere PCs<br \/>\n<\/strong>&gt;&gt;&gt; CSV-fILE erstellen mit:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">Server,WMIObject\r\nlon-cl1,win32_service\r\nnyc-dc1,win32_bios\r\n<\/pre>\n<p><strong>Abfrage mit csv<br \/>\n<\/strong>&gt;&gt;&gt; Powershell befehl = Import-csv .\\liste.csv<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$liste = Import-csv .\\liste.csv\r\n$liste | foreach-object {get-wmiobject $_.wmiobject -computername $_.server}\r\n<\/pre>\n<p>Create_LocalUser.ps1<br \/>\n## Zum erstellen von Usern<br \/>\n## aus einem csv file<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nImport-Csv users.csv | ForEach-Object {\r\n$target = &#x5B;ADSI]&quot;WinNT:\/\/.&quot;\r\n$newuser = $target.Create(&quot;user&quot;, $_.Name)\r\n$newuser.SetPassword(&quot;Password1&quot;)\r\n$newuser.SetInfo()\r\n$newuser.psbase.InvokeSet('AccountDisabled', $false)\r\n$newuser.SetInfo()\r\n}\r\n<\/pre>\n<p>The CSV file is structured<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nName\r\nUser1\r\nUser2\r\nUser3\r\nUser4\r\nUser5\r\n<\/pre>\n<h3>Related Images:<\/h3>","protected":false},"excerpt":{"rendered":"<p>Powershell Grundlagen get-command *process* Get-Command *process* -type cmdlet Get-Process | Get-Member Get-ExecutionPolicy get-process | sort-Object CPU -Descending | Select-Object processname, cpu, id | format-Table -autosize get-service | where-object {$_.status -eq &quot;running&quot;} get-eventlog system | out-gridview get-eventlog system | where-object {$_.entrytype -eq &quot;error&quot;} get-eventlog system | where-object {$_.entrytype -eq &quot;error&quot;} | Select-Object -First 5 Related Images:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[14,15],"tags":[21,20,22,23,24],"class_list":["post-255","post","type-post","status-publish","format-standard","hentry","category-powershell","category-windows-7","tag-how-to","tag-powershell-2","tag-powershell-remote","tag-psremoting","tag-winrm"],"_links":{"self":[{"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=\/wp\/v2\/posts\/255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=255"}],"version-history":[{"count":56,"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=\/wp\/v2\/posts\/255\/revisions"}],"predecessor-version":[{"id":258,"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=\/wp\/v2\/posts\/255\/revisions\/258"}],"wp:attachment":[{"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buarotti.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}