<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	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/"
		>
<channel>
	<title>Comments on: How to find a needle in the Array stack</title>
	<atom:link href="http://www.powershellpro.com/how-to-find-a-needle-in-the-array-stack/658/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powershellpro.com/how-to-find-a-needle-in-the-array-stack/658/</link>
	<description>Sharing the Experience</description>
	<lastBuildDate>Fri, 03 Feb 2012 08:09:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Automation System</title>
		<link>http://www.powershellpro.com/how-to-find-a-needle-in-the-array-stack/658/comment-page-1/#comment-653</link>
		<dc:creator>Automation System</dc:creator>
		<pubDate>Tue, 19 Jul 2011 20:39:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/?p=658#comment-653</guid>
		<description>I have a file with ItemNumber and Count
I have another file with range of ItemNumbers with corresponding Itemtype
Example: input.csv file looks like
ItemNumber,Count
1221,10
1543,14
4321,21
5411,15
5123,20
2412,19

helper.csv file looks like
start,end,type
0,1000,TypeA
1001,2000,TypeB
2001,3000,TypeC
3001,4000,TypeD
4001,5000,TypeE
5001,6000,TypeF

Output.csv is expected to be
Type,Total
TypeF,35
TypeB,24
TypeE,21
TypeC,19

How can I do this effeciently if helper file has about 111800 rows and the input file has about 5000 rows. 
I tried using do while loops looping inside helper file for each row in input file and that took more than 6 hours to complete. While in the loop, the script checks if(($itemnumber -ge $start) -and ($itemnumber -le $end))
it&#039;s almost like finding needle in a haystack, except for I have 5000 needles and my haystack is more than 100,000 rows. Any help would be appreciated. Thanks.</description>
		<content:encoded><![CDATA[<p>I have a file with ItemNumber and Count<br />
I have another file with range of ItemNumbers with corresponding Itemtype<br />
Example: input.csv file looks like<br />
ItemNumber,Count<br />
1221,10<br />
1543,14<br />
4321,21<br />
5411,15<br />
5123,20<br />
2412,19</p>
<p>helper.csv file looks like<br />
start,end,type<br />
0,1000,TypeA<br />
1001,2000,TypeB<br />
2001,3000,TypeC<br />
3001,4000,TypeD<br />
4001,5000,TypeE<br />
5001,6000,TypeF</p>
<p>Output.csv is expected to be<br />
Type,Total<br />
TypeF,35<br />
TypeB,24<br />
TypeE,21<br />
TypeC,19</p>
<p>How can I do this effeciently if helper file has about 111800 rows and the input file has about 5000 rows.<br />
I tried using do while loops looping inside helper file for each row in input file and that took more than 6 hours to complete. While in the loop, the script checks if(($itemnumber -ge $start) -and ($itemnumber -le $end))<br />
it&#8217;s almost like finding needle in a haystack, except for I have 5000 needles and my haystack is more than 100,000 rows. Any help would be appreciated. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Hamrick</title>
		<link>http://www.powershellpro.com/how-to-find-a-needle-in-the-array-stack/658/comment-page-1/#comment-378</link>
		<dc:creator>Jesse Hamrick</dc:creator>
		<pubDate>Fri, 17 Jul 2009 00:09:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/?p=658#comment-378</guid>
		<description>Dean,
I am assuming your list of usernames are the SAM account name of the user and that the list is a text file with each username entered on their own line, separated by a carriage return.
CODE:
# ==================================================================
$Users = Get-Content &quot;C:\NameOfFile.txt&quot;

$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]&quot;&quot;)

foreach($User in $users){
	$Search.Filter=&quot;(&amp;(objectClass=User)(sAMAccountName=$User))&quot;
	$objUsers = $Search.FindAll()	
	$objUsers
}
# ===================================================================

That will return the users who are in AD.

Hope that helps,</description>
		<content:encoded><![CDATA[<p>Dean,<br />
I am assuming your list of usernames are the SAM account name of the user and that the list is a text file with each username entered on their own line, separated by a carriage return.<br />
CODE:<br />
# ==================================================================<br />
$Users = Get-Content &#8220;C:\NameOfFile.txt&#8221;</p>
<p>$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]&#8220;&#8221;)</p>
<p>foreach($User in $users){<br />
	$Search.Filter=&#8221;(&amp;(objectClass=User)(sAMAccountName=$User))&#8221;<br />
	$objUsers = $Search.FindAll()<br />
	$objUsers<br />
}<br />
# ===================================================================</p>
<p>That will return the users who are in AD.</p>
<p>Hope that helps,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dean</title>
		<link>http://www.powershellpro.com/how-to-find-a-needle-in-the-array-stack/658/comment-page-1/#comment-377</link>
		<dc:creator>Dean</dc:creator>
		<pubDate>Thu, 16 Jul 2009 23:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/?p=658#comment-377</guid>
		<description>I am wondering if you have a script that that takes a list of usernames and determines if those usernames are still in AD.  and returns a list of just the names that are still in AD?

any help would be appreciated.</description>
		<content:encoded><![CDATA[<p>I am wondering if you have a script that that takes a list of usernames and determines if those usernames are still in AD.  and returns a list of just the names that are still in AD?</p>
<p>any help would be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.powershellpro.com/how-to-find-a-needle-in-the-array-stack/658/comment-page-1/#comment-362</link>
		<dc:creator>John</dc:creator>
		<pubDate>Mon, 22 Jun 2009 14:45:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/?p=658#comment-362</guid>
		<description>I have to verify group sync against  control files on a scheduled basis for certain process here and this is what i do:

get the current email addresses from the members of my DL and out put the results to a file: Current.txt

Get-DistributionGroupMember dl-xxxxx &#124; get-mailbox &#124; select primarysmtpaddress &gt;&gt; c:\work\current.txt

Then compare that output file to my Control file: Address.txt

diff $(get-content C:\work\Address.txt)  $(get-content C:\work\current.txt)

The format of the address must match, it will detect spaces as a difference if there are trailing spaces after the address.

diff -  as you can see does compare the array contents. 
I know you can compare the output of the first command to the input file.. I just haven&#039;t spent the time trying to isolate the key from the value of the array of hashes with a one liner.</description>
		<content:encoded><![CDATA[<p>I have to verify group sync against  control files on a scheduled basis for certain process here and this is what i do:</p>
<p>get the current email addresses from the members of my DL and out put the results to a file: Current.txt</p>
<p>Get-DistributionGroupMember dl-xxxxx | get-mailbox | select primarysmtpaddress &gt;&gt; c:\work\current.txt</p>
<p>Then compare that output file to my Control file: Address.txt</p>
<p>diff $(get-content C:\work\Address.txt)  $(get-content C:\work\current.txt)</p>
<p>The format of the address must match, it will detect spaces as a difference if there are trailing spaces after the address.</p>
<p>diff &#8211;  as you can see does compare the array contents.<br />
I know you can compare the output of the first command to the input file.. I just haven&#8217;t spent the time trying to isolate the key from the value of the array of hashes with a one liner.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

