{"id":2352,"date":"2013-12-25T00:01:00","date_gmt":"2013-12-25T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/12\/25\/twas-the-night-before-scripting-part-5\/"},"modified":"2013-12-25T00:01:00","modified_gmt":"2013-12-25T00:01:00","slug":"twas-the-night-before-scripting-part-5","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/twas-the-night-before-scripting-part-5\/","title":{"rendered":"&#8216;Twas the Night Before Scripting: Part 5"},"content":{"rendered":"<p><b>Summary<\/b>: Tonight, our Admin friend learns to migrate group memberships.<\/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<li><a href=\"\/b\/heyscriptingguy\/archive\/2013\/12\/24\/twas-the-night-before-scripting-part-4.aspx\" target=\"_blank\">&lsquo;Twas the Night of Before Scripting: Part&nbsp;4<\/a><\/li>\n<\/ul>\n<p>And now, our conclusion&hellip;<\/p>\n<p>During the past four days, we encountered a friend who (with the aid of Dr. Scripto) has learned some basic scripting to accomplish his holiday tasks far more readily. Now he is about to complete his work by deploying and migrating domains.<\/p>\n<p>And now we begin<\/p>\n<p>To work to the end,<\/p>\n<p>To aid in the help<\/p>\n<p>Of our good Admin friend.<\/p>\n<p>&nbsp;<\/p>\n<p>The users were ready,<\/p>\n<p>With their attributes set,<\/p>\n<p>And the PCs in AD<\/p>\n<p>Were ready to get.<\/p>\n<p>&nbsp;<\/p>\n<p>But one more task<\/p>\n<p>&lsquo;Twas there in the way,<\/p>\n<p>A simple wee thing<\/p>\n<p>To finish the day.<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;We must now migrate<\/p>\n<p>Your memberships here,<\/p>\n<p>To the new computers<\/p>\n<p>And get you all clear.<\/p>\n<p>&nbsp;<\/p>\n<p>You were close, I can see,<\/p>\n<p>With the cmdlet you chose,<\/p>\n<p>But &lsquo;twas the reverse,<\/p>\n<p>So I shall show you the close.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>Dr. Scripto sat down<\/p>\n<p>On his plastery knee,<\/p>\n<p>To show to Admin<\/p>\n<p>The final piece to set free.<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;With the info we have<\/p>\n<p>And Import-CSV,<\/p>\n<p>We can combine them as one,<\/p>\n<p>To get done in AD.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>To transfer the settings<\/p>\n<p>From and old to a new,<\/p>\n<p>He ran a cmdlet<\/p>\n<p>To get them all through.<\/p>\n<p>&nbsp;<\/p>\n<p>A cmdlet he typed<\/p>\n<p>On the blue world,<\/p>\n<p>To untangle adding to<\/p>\n<p>The group membership world:<\/p>\n<p style=\"margin-left:30px\">Add-ADGroupMember<\/p>\n<p>&nbsp;<\/p>\n<p>The Admin added Get-Help,<\/p>\n<p>To see examples on how<\/p>\n<p>To use this new cmdlet,<\/p>\n<p>On his screen there and now:<\/p>\n<p style=\"margin-left:30px\">GET-HELP ADD-ADGroupMember &ndash;examples<\/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\/6011.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\/6011.1.PNG\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>It seemed just too easy,<\/p>\n<p>He tried right away<\/p>\n<p>To add one adhoc,<\/p>\n<p>Went straight off to play!<\/p>\n<p style=\"margin-left:30px\">ADD-ADGroupMember &ndash;identity &ldquo;RDPEnabled&rdquo; &ndash;members &ldquo;STATION003&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>But he blinked in dismay,<\/p>\n<p>At what he now saw,<\/p>\n<p>It just didn&rsquo;t work,<\/p>\n<p>He fell back in awe.<\/p>\n<p>&nbsp;<\/p>\n<p>Dr. Scripto, he smiled,<\/p>\n<p>&ldquo;A moment, my friend,<\/p>\n<p>The answer was close,<\/p>\n<p>Almost the end!<\/p>\n<p>&nbsp;<\/p>\n<p>The trick, the cmdlet,<\/p>\n<p>In the examples you see,<\/p>\n<p>Is use the SAM property,<\/p>\n<p>Of the computer PC.&rdquo;&nbsp;<\/p>\n<p style=\"margin-left:30px\">ADD-ADGroupMember &ndash;identity &ldquo;RDPEnabled&rdquo; &ndash;members &ldquo;STATION003$&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;Now all we need do<\/p>\n<p>Is combine the two things,<\/p>\n<p>Your list of computers,<\/p>\n<p>And the membership things!&rdquo;&nbsp;<\/p>\n<\/p>\n<p style=\"margin-left:30px\">$Computerlist=IMPORT-CSV computers.csv&nbsp;<\/p>\n<p style=\"margin-left:30px\">Foreach ($PC in $Computerlist)<\/p>\n<p style=\"margin-left:30px\">{<\/p>\n<p style=\"margin-left:30px\">$Groups=(GET-ADComputer $PC.Oldname &ndash;properties memberof).memberof<\/p>\n<p style=\"margin-left:30px\">$SamName=$PC.Newname+&rdquo;$&rdquo;<\/p>\n<p style=\"margin-left:30px\">$Groups | ADD-ADGroupMember &ndash;member $Samname<\/p>\n<p style=\"margin-left:30px\">}<\/p>\n<p>&nbsp;<\/p>\n<p>The Admin, he saved<\/p>\n<p>And ran that in a lick,<\/p>\n<p>In moments the groups<\/p>\n<p>Were transferred so quick.<\/p>\n<p>&nbsp;<\/p>\n<p>He looked at the clock,<\/p>\n<p>And realized the time<\/p>\n<p>Had barely been moved,<\/p>\n<p>Not such a crime!<\/p>\n<p>&nbsp;<\/p>\n<p>500 users were done,<\/p>\n<p>And PCs were set,<\/p>\n<p>No effort required,<\/p>\n<p>And still much time yet.<\/p>\n<p>&nbsp;<\/p>\n<p>To visit his family,<\/p>\n<p>And resting the ways<\/p>\n<p>Of all well-earned time,<\/p>\n<p>And good holidays.<\/p>\n<p>&nbsp;<\/p>\n<p>&ldquo;Dr. Scripto,&rdquo; he reached<\/p>\n<p>Out to thank him away,<\/p>\n<p>But the mythical, magical man<\/p>\n<p>Had vanished away.<\/p>\n<p>&nbsp;<\/p>\n<p>A note on his screen<\/p>\n<p>Is all that was found,<\/p>\n<p>&ldquo;Just Bing me on TechNet,<\/p>\n<p>I&rsquo;m always around.<\/p>\n<p>&nbsp;<\/p>\n<p>I live in the spirit<\/p>\n<p>Of the blogs of the net,<\/p>\n<p>Just use #powershell,<\/p>\n<p>Never you fret.<\/p>\n<p>&nbsp;<\/p>\n<p>MVPs and the like,<\/p>\n<p>Community as well,<\/p>\n<p>Are all that I am,<\/p>\n<p>Just ring on their bell.&rdquo;<\/p>\n<p>&nbsp;<\/p>\n<p>A final line was left<\/p>\n<p>For him to read:<\/p>\n<p><a href=\"http:\/\/www.scriptingguys.com\/\" target=\"_blank\">www.scriptingguys.com<\/a>,<\/p>\n<p>Should you feel need.<\/p>\n<p>&nbsp;<\/p>\n<p>The Admin, he smiled,<\/p>\n<p>Logged his system on down,<\/p>\n<p>Headed outside,<\/p>\n<p>With nary a frown<\/p>\n<p>&nbsp;<\/p>\n<p>For now, armed with a<\/p>\n<p>Scripting skill set,<\/p>\n<p>He&rsquo;d always have time,<\/p>\n<p>And never would fret.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Happy Holidays from the Scripting Guys!<\/strong><\/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&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Tonight, our Admin friend learns to migrate group memberships. 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 of Before Scripting: Part 2 &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-2352","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: Tonight, our Admin friend learns to migrate group memberships. 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 of Before Scripting: Part 2 &lsquo;Twas the Night [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2352","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=2352"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2352\/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=2352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}