{"id":2359,"date":"2013-12-24T00:01:00","date_gmt":"2013-12-24T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/12\/24\/twas-the-night-before-scripting-part-4\/"},"modified":"2013-12-24T00:01:00","modified_gmt":"2013-12-24T00:01:00","slug":"twas-the-night-before-scripting-part-4","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/twas-the-night-before-scripting-part-4\/","title":{"rendered":"&#8216;Twas the Night Before Scripting: Part 4"},"content":{"rendered":"<p><b>Summary<\/b>: Dr. Scripto shows our Admin friend how to determine which groups a computer is a member of.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, here. If you missed it, be sure to watch Sean&rsquo;s video:&nbsp;<a href=\"https:\/\/www.youtube.com\/watch?v=v8XuDXyt9YE&amp;feature=share&amp;list=UUQwtf2q4LnSyoVh4TNYFoNw\" target=\"_blank\">Just Script It<\/a>! Also to catch up with our story, read:&nbsp;<\/p>\n<ul>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2013\/12\/21\/twas-the-night-of-before-scripting-part-1.aspx\" target=\"_blank\">&lsquo;Twas the Night of Before Scripting: Part 1<\/a><\/li>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2013\/12\/22\/twas-the-night-before-scripting-part-2.aspx\" target=\"_blank\">&lsquo;Twas the Night of Before Scripting: Part 2<\/a><\/li>\n<li><a href=\"\/b\/heyscriptingguy\/archive\/2013\/12\/23\/twas-the-night-before-scripting-part-3.aspx\" target=\"_blank\">&lsquo;Twas the Night of Before Scripting: Part 3<\/a><\/li>\n<\/ul>\n<p>Take it away, Sean&hellip;<\/p>\n<p>When we last were within our reading, the good Dr. Scripto showed our former non-scripter how to find cmdlets within a module&mdash;and furthermore, how to obtain the necessary Help for basic use. The weight of the pressure had begun to ease off our happy admin. &nbsp;He actually foresaw being home with his family for the holidays.<\/p>\n<p>But now, let the rhyming begin anew!<\/p>\n<p>When last we did see<\/p>\n<p>Our new Admin guy,<\/p>\n<p>He was feeling his scripting<\/p>\n<p>Would be very fly.<\/p>\n<p>&nbsp;<\/p>\n<p>He learned how to find<\/p>\n<p>Cmdlets with ease.<\/p>\n<p>These PowerShell things<\/p>\n<p>Just working with ease.<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;So my good friend,&rdquo;<\/p>\n<p>Said Scripto the Doc,<\/p>\n<p>&ldquo;What&rsquo;s the next thing here,<\/p>\n<p>Upon our time clock?&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>The Admin looked,<\/p>\n<p>And saw on his task list,<\/p>\n<p>A nasty wee thing<\/p>\n<p>He almost had missed.<\/p>\n<p>&nbsp;<\/p>\n<p>He had to migrate<\/p>\n<p>Some accounts for PC<\/p>\n<p>Memberships of groups<\/p>\n<p>That needed to be.<\/p>\n<p>&nbsp;<\/p>\n<p>Carried over from an<\/p>\n<p>Old system now,<\/p>\n<p>If he didn&rsquo;t, the boss<\/p>\n<p>Just might have a cow.<\/p>\n<p>&nbsp;<\/p>\n<p>But he realized and thought<\/p>\n<p>An answer quite quick,<\/p>\n<p>A solution presented<\/p>\n<p>Itself in a tic!<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;Why, all of the names<\/p>\n<p>For computers to be<\/p>\n<p>Are sitting right here<\/p>\n<p>In computer.csv.<\/p>\n<p>&nbsp;<\/p>\n<p>I wonder if can use<\/p>\n<p>The feature from last<\/p>\n<p>Import-CSV,<\/p>\n<p>From the script from the past.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>The good doctor nodded<\/p>\n<p>And said, &ldquo;Give it a try.<\/p>\n<p>You&rsquo;ve nothing to lose,<\/p>\n<p>And I&rsquo;ll bet you&rsquo;ll get by.<\/p>\n<p>&nbsp;<\/p>\n<p>But even more, I suspect<\/p>\n<p>If you try this and get done,<\/p>\n<p>You&rsquo;ll be able to access<\/p>\n<p>It, and get yourself done.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>The Admin sat down<\/p>\n<p>And examined his stuff,<\/p>\n<p>The data from old<\/p>\n<p>Computers and fluff.&nbsp;<\/p>\n<p style=\"margin-left:30px\">OLDNAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEWNAME<\/p>\n<p style=\"margin-left:30px\">EOT-DABOSS&nbsp;&nbsp;&nbsp;&nbsp; STATION001<\/p>\n<p style=\"margin-left:30px\">EOT-PICKLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STATION002<\/p>\n<p style=\"margin-left:30px\">EOT-SURFACE&nbsp;&nbsp;&nbsp; STATION003<\/p>\n<p style=\"margin-left:30px\">EOT-99 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STATION004<\/p>\n<p style=\"margin-left:30px\">EOT-JERRY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STATION005<\/p>\n<p style=\"margin-left:30px\">&nbsp;$list=IMPORT-CSV computers.csv<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;Now my next challenge<\/p>\n<p>With this imported list<\/p>\n<p>Is to migrate groups,<\/p>\n<p>Make sure none are missed.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>He wondered if a<\/p>\n<p>Cmdlet was there,<\/p>\n<p>To show group memberships,<\/p>\n<p>All without care.<\/p>\n<p style=\"margin-left:30px\">&nbsp;GET-COMMAND &ndash;module ActiveDirectory *group*<\/p>\n<p>&nbsp;<\/p>\n<p>He look and blinked<\/p>\n<p>At the answers outlaid,<\/p>\n<p>Wondering if they would<\/p>\n<p>Solve and provide aid.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/6283.1.PNG\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/6283.1.PNG\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>He tried the one out,<\/p>\n<p>It seemed obvious to he,<\/p>\n<p>GET-ADGROUPMember,<\/p>\n<p>It would probably be.<\/p>\n<p style=\"margin-left:30px\">GET-ADGroupmember MicrosoftWord<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/1641.2.PNG\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/1641.2.PNG\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a>&nbsp;<\/p>\n<p>He smiled at the result,<\/p>\n<p>It seemed quite a tease,<\/p>\n<p>&ldquo;But I need to know<\/p>\n<p>The groups for PCs.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;I think I can show you<\/p>\n<p>Just what you need,<\/p>\n<p>You need the property<\/p>\n<p>Of the PC indeed.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>Dr. Scripto pulled up<\/p>\n<p>The info at hand,<\/p>\n<p>Of a computer within<\/p>\n<p>The old AD land.<\/p>\n<p style=\"margin-left:30px\">GET-ADComputer EOT-SURFACE &ndash;properties memberof<\/p>\n<p>&nbsp;<a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/1376.3.PNG\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/1376.3.PNG\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>&ldquo;See how <b>MemberOf<\/b><\/p>\n<p>From the object AD,<\/p>\n<p>Contains the groups<\/p>\n<p>Joined by PC?<\/p>\n<p>&nbsp;<\/p>\n<p>To get this list out<\/p>\n<p>And useful to you,<\/p>\n<p>We can simply extract it,<\/p>\n<p>So easy to do.&rdquo;<\/p>\n<p style=\"margin-left:30px\">(GET-ADComputer EOT-SURFACE &ndash;properties memberof).memberof<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/4.PNG\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/prod.evol.blogs.technet.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/76\/18\/4.PNG\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The Admin blinked and saw<\/p>\n<p>Victory in sight,<\/p>\n<p>&ldquo;Perhaps I&rsquo;ll be done with<\/p>\n<p>All this tonight!&rdquo;<\/p>\n<\/p>\n<p>Pop in tomorrow for more silly holiday rhymes and a little more Windows PowerShell goodness!<\/p>\n<p>I invite you to follow the Scripting Guys on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Sean Kearney<\/b>, Honorary Scripting Guy and Windows PowerShell MVP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Dr. Scripto shows our Admin friend how to determine which groups a computer is a member of. Microsoft Scripting Guy, Ed Wilson, here. If you missed it, be sure to watch Sean&rsquo;s video:&nbsp;Just Script It! Also to catch up with our story, read:&nbsp; &lsquo;Twas the Night of Before Scripting: Part 1 &lsquo;Twas the Night [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,154,45],"class_list":["post-2359","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Dr. Scripto shows our Admin friend how to determine which groups a computer is a member of. Microsoft Scripting Guy, Ed Wilson, here. If you missed it, be sure to watch Sean&rsquo;s video:&nbsp;Just Script It! Also to catch up with our story, read:&nbsp; &lsquo;Twas the Night of Before Scripting: Part 1 &lsquo;Twas the Night [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2359"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2359\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}