{"id":79,"date":"2018-04-12T20:03:16","date_gmt":"2018-04-12T20:03:16","guid":{"rendered":"https:\/\/www.atlanta247.com\/blog\/?p=79"},"modified":"2018-12-26T20:17:51","modified_gmt":"2018-12-26T20:17:51","slug":"powershell-useful-snippits-of-code","status":"publish","type":"post","link":"https:\/\/www.atlanta247.com\/blog\/2018\/04\/12\/powershell-useful-snippits-of-code\/","title":{"rendered":"Powershell &#8211; Useful snippits of code"},"content":{"rendered":"\n<p>I find myself using some pieces of code frequently.   As I work, I often look back and copy something so that I can save time.  I have long since lost the references online from which I may have learned &#8211; but I give full credit to those wonderful folks online who post stuff..  so here are some of my favorites. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#<br> Comparing strings<br> #<br> $ARR_ERSAPPLIST = $ARR_ERSAPPLIST | Sort-Object<br> $ARR_NPGAPPLIST = $ARR_NPGAPPLIST | Sort-Object<br> $ARR_APPLIST = Compare-Object $ARR_ERSAPPLIST -DifferenceObject $ARR_NPGAPPLIST -PassThru<br> $ARR_APPLIST2 = Compare-Object -ReferenceObject $ARR_NPGAPPLIST -DifferenceObject $ARR_ERSAPPLIST -PassThru<br> $ERSfromNPG = $ARR_ERSAPPLIST |% {if ($ARR_NPGAPPLIST -contains $_) { $_ }}  <br> $NPGfromERS = $ARR_NPGAPPLIST |% {if ($ARR_ERSAPPLIST -contains $_) { $_ }}  <br><br>#<br> create a hash table object<br> #<br> $myObject2 = New-Object BOB -TypeName PSObject<br> $myObject2 | Add-Member -type NoteProperty -name Name -Value \"Doug_PC\"<br> $myObject2 | Add-Member -type NoteProperty -name Manufacturer -Value \"Dell\"<br> $myObject2 | Add-Member -type NoteProperty -name ProcessorSpeed -Value \"2.6 Ghz\"<br> $myObject2 | Add-Member -type NoteProperty -name Memory -Value \"131\"<br> $masterlist += $myObject2<br> <br><br>#<br> Yes No<br> #<br> YesNo<br>     $YesNo = [System.Windows.Forms.MessageBox]::Show(\"No User Name was entered. The script will exit\")<br> $a = new-object -comobject wscript.shell<br> $intAnswer = $a.popup(\"Do you want to delete these files?\", `<br> 0,\"Delete Files\",4)<br> If ($intAnswer -eq 6) {<br>   $a.popup(\"You answered yes.\")<br> } else {<br>   $a.popup(\"You answered no.\")<br> }<br><br><br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I find myself using some pieces of code frequently. As I work, I often look back and copy something so that I can save time. I have long since lost the references online from which I may have learned &#8211; but I give full credit to those wonderful folks online who post stuff.. so here &hellip; <a href=\"https:\/\/www.atlanta247.com\/blog\/2018\/04\/12\/powershell-useful-snippits-of-code\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Powershell &#8211; Useful snippits of code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[12,14,15],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-powershell","tag-compare","tag-hash-table","tag-powershell"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":1,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":80,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions\/80"}],"wp:attachment":[{"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.atlanta247.com\/blog\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}