<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for vmweaver.com</title>
	
	<link>http://vmweaver.com</link>
	<description>Mindless ramblings of a geek...</description>
	<lastBuildDate>Thu, 22 Jul 2010 20:54:26 -0400</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForVmweavercom" /><feedburner:info uri="commentsforvmweavercom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Comment on Powershell – Recursive Group Membership by Mark A. Weaver</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/DblfGJzyfao/</link>
		<dc:creator>Mark A. Weaver</dc:creator>
		<pubDate>Thu, 22 Jul 2010 20:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=146#comment-472</guid>
		<description>Thanks for the correction. I will update this to force typing on this parameter. 
-- Mark</description>
		<content:encoded><![CDATA[<p>Thanks for the correction. I will update this to force typing on this parameter.<br />
&#8211; Mark</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/DblfGJzyfao" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/08/powershell-recursive-group-membership/comment-page-1/#comment-472</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell – Recursive Group Membership by DK-Stefan</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/NI1VGpnrmWA/</link>
		<dc:creator>DK-Stefan</dc:creator>
		<pubDate>Thu, 22 Jul 2010 13:52:47 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=146#comment-471</guid>
		<description>There is an error in the script:
...[System.DirectoryServices.PropertyValueCollection] doesn't contain a method named 'Split'.

The function Convert-DNtoDNS ($DN) should be function Convert-DNtoDNS ([String]$DN), otherwise PowerShell thinks that the .split on the first line of the function is a method of the System.Dire....bla...bla thingy

:-)</description>
		<content:encoded><![CDATA[<p>There is an error in the script:<br />
&#8230;[System.DirectoryServices.PropertyValueCollection] doesn&#8217;t contain a method named &#8216;Split&#8217;.</p>
<p>The function Convert-DNtoDNS ($DN) should be function Convert-DNtoDNS ([String]$DN), otherwise PowerShell thinks that the .split on the first line of the function is a method of the System.Dire&#8230;.bla&#8230;bla thingy</p>
<p> <img src='http://vmweaver.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/NI1VGpnrmWA" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/08/powershell-recursive-group-membership/comment-page-1/#comment-471</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell – Recursive Group Membership by Mark A. Weaver</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/SA5y_gKqVQo/</link>
		<dc:creator>Mark A. Weaver</dc:creator>
		<pubDate>Thu, 24 Jun 2010 14:51:08 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=146#comment-470</guid>
		<description>Thanks very much. I hope to be posting more AD-related stuff soon, so stay tuned!
 -- Mark</description>
		<content:encoded><![CDATA[<p>Thanks very much. I hope to be posting more AD-related stuff soon, so stay tuned!<br />
 &#8212; Mark</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/SA5y_gKqVQo" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/08/powershell-recursive-group-membership/comment-page-1/#comment-470</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell – Recursive Group Membership by Chris Clemson</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/avcEGLX_ohM/</link>
		<dc:creator>Chris Clemson</dc:creator>
		<pubDate>Thu, 24 Jun 2010 14:15:28 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=146#comment-469</guid>
		<description>Very handy script, and a useful intro to PowerShell, thank you!</description>
		<content:encoded><![CDATA[<p>Very handy script, and a useful intro to PowerShell, thank you!</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/avcEGLX_ohM" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/08/powershell-recursive-group-membership/comment-page-1/#comment-469</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell and DFSR by Shane</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/69m4VQqzoj8/</link>
		<dc:creator>Shane</dc:creator>
		<pubDate>Fri, 21 May 2010 19:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=126#comment-468</guid>
		<description>I love the additions of having email notification sent out and that's scheduled once per day so thank you for that piece!!

I've also updated your script to run on my desktop and query the remote hub server so i can easily run it on the fly and without having to be logged in locally on the hub.</description>
		<content:encoded><![CDATA[<p>I love the additions of having email notification sent out and that&#8217;s scheduled once per day so thank you for that piece!!</p>
<p>I&#8217;ve also updated your script to run on my desktop and query the remote hub server so i can easily run it on the fly and without having to be logged in locally on the hub.</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/69m4VQqzoj8" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/04/powershell-and-dfsr/comment-page-1/#comment-468</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell and DFSR by Mark A. Weaver</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/MGP6tVb6IZQ/</link>
		<dc:creator>Mark A. Weaver</dc:creator>
		<pubDate>Thu, 20 May 2010 22:19:37 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=126#comment-467</guid>
		<description>Glad it worked out for you!  Let me know if you have suggestions on  how to improve it.
-- Mark</description>
		<content:encoded><![CDATA[<p>Glad it worked out for you!  Let me know if you have suggestions on  how to improve it.<br />
&#8211; Mark</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/MGP6tVb6IZQ" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/04/powershell-and-dfsr/comment-page-1/#comment-467</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell and DFSR by Kristoff Corvos</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/ozxhXjF0yK0/</link>
		<dc:creator>Kristoff Corvos</dc:creator>
		<pubDate>Thu, 20 May 2010 17:56:51 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=126#comment-466</guid>
		<description>Fantastic script, it was exactly what I needed.  Thanks!</description>
		<content:encoded><![CDATA[<p>Fantastic script, it was exactly what I needed.  Thanks!</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/ozxhXjF0yK0" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/04/powershell-and-dfsr/comment-page-1/#comment-466</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell and DFSR by Shane</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/kMlzDMoWLAs/</link>
		<dc:creator>Shane</dc:creator>
		<pubDate>Fri, 14 May 2010 16:48:51 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=126#comment-465</guid>
		<description>&lt;blockquote cite="#commentbody-464"&gt;
&lt;strong&gt;&lt;a href="#comment-464" rel="nofollow"&gt;Shane &lt;/a&gt; :&lt;/strong&gt;&lt;a href="#comment-445" rel="nofollow"&gt;@Steve &lt;/A&gt;
What do you mean by this because my emails have no formatting:
You will need to add the HTML Tags “” to HTML, BODY, and BR within the script.&lt;/blockquote&gt;

N/M I hadn't had my coffee for the morning yet =)</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-464"><p>
<strong><a href="#comment-464" rel="nofollow">Shane </a> :</strong><a href="#comment-445" rel="nofollow">@Steve </a><br />
What do you mean by this because my emails have no formatting:<br />
You will need to add the HTML Tags “” to HTML, BODY, and BR within the script.</p></blockquote>
<p>N/M I hadn&#8217;t had my coffee for the morning yet =)</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/kMlzDMoWLAs" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/04/powershell-and-dfsr/comment-page-1/#comment-465</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell and DFSR by Shane</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/lCpDuH9er2c/</link>
		<dc:creator>Shane</dc:creator>
		<pubDate>Fri, 14 May 2010 16:14:36 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=126#comment-464</guid>
		<description>&lt;a href="#comment-445" rel="nofollow"&gt;@Steve  &lt;/a&gt; 

What do you mean by this because my emails have no formatting:

You will need to add the HTML Tags “” to HTML, BODY, and BR within the script.</description>
		<content:encoded><![CDATA[<p><a href="#comment-445" rel="nofollow">@Steve  </a> </p>
<p>What do you mean by this because my emails have no formatting:</p>
<p>You will need to add the HTML Tags “” to HTML, BODY, and BR within the script.</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/lCpDuH9er2c" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/04/powershell-and-dfsr/comment-page-1/#comment-464</feedburner:origLink></item>
	<item>
		<title>Comment on Powershell – Recursive Group Membership by Mark A. Weaver</title>
		<link>http://feedproxy.google.com/~r/CommentsForVmweavercom/~3/Yt4l3L4fUK4/</link>
		<dc:creator>Mark A. Weaver</dc:creator>
		<pubDate>Sat, 20 Mar 2010 04:01:37 +0000</pubDate>
		<guid isPermaLink="false">http://vmweaver.com/?p=146#comment-463</guid>
		<description>Okay.. it is amazing how one little bracket/brace/parenthesis can wreak such havoc.

The error in the last run you did was from not closing the curly brace at the end.
Set-QADUser -Identity $user -ObjectAttributes @{primaryGroupID=@(222753)&lt;strong&gt;}&lt;/strong&gt;

I have also done some other things in the code below.  The Quest tools tend to spit out lots of data when setting objects or connecting to services, etc.  
If you want to see those outputs, remove the " &gt; $null" pieces from those lines.  Basically this says to redirect the console output to $null (or nothing).  This essentially suppresses the output from those cmdlets.  
I then have a few "write-host" lines to echo what is going on.

BTW: Another way to get credentials is with the Get-Credential cmdlet.   You could replace these lines:
    $un = read-Host “User Name domain\username” # Your domain and username
    $pw = read-host “Enter password” -AsSecureString # Your Password
       .
       .
    connect-QADService -service "xxx.com" -ConnectionAccount $un -ConnectionPassword $pw &gt; $null
   
with just this one:
   connect-QADService -service "xxx.com" -Credential (Get-Credential) &gt; $null

Let me know how it goes!
 -- Mark

#----Begin Code ------------------------------------#
#Get all users in the OU below 
$users = Get-QADUser -SearchRoot "OU=Enabled,OU=Users,OU=Partners,DC=xxx,DC=com" 

#Read in the user's credentials and store password as secure string
$un = read-Host “User Name domain\username” # Your domain and username
$pw = read-host “Enter password” -AsSecureString # Your Password

#Define the group to make my primary group
$group="CN=AllPartners,OU=Groups,OU=Partners,DC=xxx,DC=com"

#Connect to the domain with supplied credentials
connect-QADService -service "xxx.com" -ConnectionAccount $un -ConnectionPassword $pw &gt; $null

#Look at each user and see if they are already in the group
ForEach ($user in $Users) {
  #If they are not already a member, then we need to add them to the group
  if  ($user.Memberof -NotContains $group) 
   {
     Write-Host Adding $User.samaccountname to $group ...
     add-QADGroupMember -identity $group -member $user &gt; $null
     
    }
  #Set the primary group for the user 
  Write-host Setting primaryGroup...
  Set-QADUser -Identity $user -ObjectAttributes @{primaryGroupID=@(222753)} &gt; $null

  #Remove the user from "Domain Users" group
  Write-host Removing $user.samaccountname from Domain Users group...
  Remove-QADGroupMember -Identity "Domain USers" -Member $user &gt; $null
} 

#----END Code-----------------------------------#</description>
		<content:encoded><![CDATA[<p>Okay.. it is amazing how one little bracket/brace/parenthesis can wreak such havoc.</p>
<p>The error in the last run you did was from not closing the curly brace at the end.<br />
Set-QADUser -Identity $user -ObjectAttributes @{primaryGroupID=@(222753)<strong>}</strong></p>
<p>I have also done some other things in the code below.  The Quest tools tend to spit out lots of data when setting objects or connecting to services, etc.<br />
If you want to see those outputs, remove the &#8221; &gt; $null&#8221; pieces from those lines.  Basically this says to redirect the console output to $null (or nothing).  This essentially suppresses the output from those cmdlets.<br />
I then have a few &#8220;write-host&#8221; lines to echo what is going on.</p>
<p>BTW: Another way to get credentials is with the Get-Credential cmdlet.   You could replace these lines:<br />
    $un = read-Host “User Name domain\username” # Your domain and username<br />
    $pw = read-host “Enter password” -AsSecureString # Your Password<br />
       .<br />
       .<br />
    connect-QADService -service &#8220;xxx.com&#8221; -ConnectionAccount $un -ConnectionPassword $pw &gt; $null</p>
<p>with just this one:<br />
   connect-QADService -service &#8220;xxx.com&#8221; -Credential (Get-Credential) &gt; $null</p>
<p>Let me know how it goes!<br />
 &#8212; Mark</p>
<p>#&#8212;-Begin Code &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;#<br />
#Get all users in the OU below<br />
$users = Get-QADUser -SearchRoot &#8220;OU=Enabled,OU=Users,OU=Partners,DC=xxx,DC=com&#8221; </p>
<p>#Read in the user&#8217;s credentials and store password as secure string<br />
$un = read-Host “User Name domain\username” # Your domain and username<br />
$pw = read-host “Enter password” -AsSecureString # Your Password</p>
<p>#Define the group to make my primary group<br />
$group=&#8221;CN=AllPartners,OU=Groups,OU=Partners,DC=xxx,DC=com&#8221;</p>
<p>#Connect to the domain with supplied credentials<br />
connect-QADService -service &#8220;xxx.com&#8221; -ConnectionAccount $un -ConnectionPassword $pw &gt; $null</p>
<p>#Look at each user and see if they are already in the group<br />
ForEach ($user in $Users) {<br />
  #If they are not already a member, then we need to add them to the group<br />
  if  ($user.Memberof -NotContains $group)<br />
   {<br />
     Write-Host Adding $User.samaccountname to $group &#8230;<br />
     add-QADGroupMember -identity $group -member $user &gt; $null</p>
<p>    }<br />
  #Set the primary group for the user<br />
  Write-host Setting primaryGroup&#8230;<br />
  Set-QADUser -Identity $user -ObjectAttributes @{primaryGroupID=@(222753)} &gt; $null</p>
<p>  #Remove the user from &#8220;Domain Users&#8221; group<br />
  Write-host Removing $user.samaccountname from Domain Users group&#8230;<br />
  Remove-QADGroupMember -Identity &#8220;Domain USers&#8221; -Member $user &gt; $null<br />
} </p>
<p>#&#8212;-END Code&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;#</p>
<img src="http://feeds.feedburner.com/~r/CommentsForVmweavercom/~4/Yt4l3L4fUK4" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://vmweaver.com/index.php/2009/08/powershell-recursive-group-membership/comment-page-1/#comment-463</feedburner:origLink></item>
</channel>
</rss>
