Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Comparing arrays

Reply
 
Old 04-10-2009   #1 (permalink)
Mike


 
 

Comparing arrays

Hi all:

Working on a project to identify home folders that are associated with
a disabled AD account. I have 2 arrays, one has the list of home
folders, the other contains a list of user accounts, with home drive,
home directory, employee id, email address, etc that I gathered using
get-qaduser cmdlet. I've been successful in the past comparing 2
simple arrays, but I'm having problems with this one. I think the user
array is a multidimensional array, from what I've read, and that's
what's tripping me up. How can this be done?

Thanks in advance...

My System SpecsSystem Spec
Old 04-10-2009   #2 (permalink)
tojo2000


 
 

Re: Comparing arrays

On Apr 9, 9:48*pm, Mike <thelotu...@xxxxxx> wrote:
Quote:

> Hi all:
>
> Working on a project to identify home folders that are associated with
> a disabled AD account. I have 2 arrays, one has the list of home
> folders, the other contains a list of user accounts, with home drive,
> home directory, employee id, email address, etc that I gathered using
> get-qaduser cmdlet. I've been successful in the past comparing 2
> simple arrays, but I'm having problems with this one. I think the user
> array is a multidimensional array, from what I've read, and that's
> what's tripping me up. How can this be done?
>
> Thanks in advance...
This sounds like two arrays are the wrong data structures for the
task. Before we give you a push in the right direction, though, we
could use some more information. What you have described is not two
arrays, but either an array and a hash, or an array and an object.
Can you give us more information without revealing anytihng
confidential or proprietery?
My System SpecsSystem Spec
Old 04-13-2009   #3 (permalink)
Mike


 
 

Re: Comparing arrays

On Apr 10, 12:47*am, tojo2000 <tojo2...@xxxxxx> wrote:
Quote:

> On Apr 9, 9:48*pm, Mike <thelotu...@xxxxxx> wrote:
>
Quote:

> > Hi all:
>
Quote:

> > Working on a project to identify home folders that are associated with
> > a disabled AD account. I have 2 arrays, one has the list of home
> > folders, the other contains a list of user accounts, with home drive,
> > home directory, employee id, email address, etc that I gathered using
> > get-qaduser cmdlet. I've been successful in the past comparing 2
> > simple arrays, but I'm having problems with this one. I think the user
> > array is a multidimensional array, from what I've read, and that's
> > what's tripping me up. How can this be done?
>
Quote:

> > Thanks in advance...
>
> This sounds like two arrays are the wrong data structures for the
> task. *Before we give you a push in the right direction, though, we
> could use some more information. *What you have described is not two
> arrays, but either an array and a hash, or an array and an object.
> Can you give us more information without revealing anytihng
> confidential or proprietery?
Yes I think you're right. I'll put together some more detailed
information and post later today.
My System SpecsSystem Spec
Old 04-14-2009   #4 (permalink)
Mike


 
 

Re: Comparing arrays

On Apr 10, 12:47*am, tojo2000 <tojo2...@xxxxxx> wrote:
Quote:

> On Apr 9, 9:48*pm, Mike <thelotu...@xxxxxx> wrote:
>
Quote:

> > Hi all:
>
Quote:

> > Working on a project to identify home folders that are associated with
> > a disabled AD account. I have 2 arrays, one has the list of home
> > folders, the other contains a list of user accounts, with home drive,
> > home directory, employee id, email address, etc that I gathered using
> > get-qaduser cmdlet. I've been successful in the past comparing 2
> > simple arrays, but I'm having problems with this one. I think the user
> > array is a multidimensional array, from what I've read, and that's
> > what's tripping me up. How can this be done?
>
Quote:

> > Thanks in advance...
>
> This sounds like two arrays are the wrong data structures for the
> task. *Before we give you a push in the right direction, though, we
> could use some more information. *What you have described is not two
> arrays, but either an array and a hash, or an array and an object.
> Can you give us more information without revealing anytihng
> confidential or proprietery?
Here's some further detail. I was originally thinking along the same
lines as you, so I tried to export only the HomeDirectory field to
another array and compare it, but that seemed kinda hacky, and I'm
hoping there was a way to do this without creating another array. My
user object and home drive array details are below.

$UserAccountDetailList | Get-Member

TypeName: System.Management.Automation.PSCustomObject

Name MemberType Definition
---- ---------- ----------
Equals Method System.Boolean Equals(Object obj)
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
ToString Method System.String ToString()
AccountIsDisabled NoteProperty System.Boolean AccountIsDisabled=False
CanonicalName NoteProperty System.String CanonicalName=company.com/
Departments/branch0101/Users/Staff/000010101
cn NoteProperty System.String cn=000010101
company-userstatus NoteProperty System.String company-userstatus=A
createtimestamp NoteProperty System.DateTime
createtimestamp=8/23/2002 2:51:50 AM
DisplayName NoteProperty System.String DisplayName=Smith, James
E
Email NoteProperty System.String Email=jesmith@xxxxxx
HomeDirectory NoteProperty System.String HomeDirectory=\\br1-home
\home\JESmith
HomeDrive NoteProperty System.String HomeDrive=H:
LogonName NoteProperty System.String LogonName=JESmith

$ServerFoldersListWithSize | Get-Member

TypeName: System.String

Name MemberType Definition
---- ---------- ----------
Clone Method System.Object Clone()
CompareTo Method System.Int32 CompareTo(Object
value), System.Int32 CompareTo(String strB)
Contains Method System.Boolean Contains(String
value)
CopyTo Method System.Void CopyTo(Int32
sourceIndex, Char[] destination, Int32 destinationIndex, Int32 count)
EndsWith Method System.Boolean EndsWith(String
value), System.Boolean EndsWith(String value, StringComparison
comparisonType), System.Boolean EndsWith(String value, Boolean ...
Equals Method System.Boolean Equals(Object
obj), System.Boolean Equals(String value), System.Boolean Equals
(String value, StringComparison comparisonType)
GetEnumerator Method System.CharEnumerator
GetEnumerator()
GetHashCode Method System.Int32 GetHashCode()
GetType Method System.Type GetType()
GetTypeCode Method System.TypeCode GetTypeCode()
get_Chars Method System.Char get_Chars(Int32
index)
get_Length Method System.Int32 get_Length()
IndexOf Method System.Int32 IndexOf(Char
value), System.Int32 IndexOf(Char value, Int32 startIndex),
System.Int32 IndexOf(Char value, Int32 startIndex, Int32 count),
System...
IndexOfAny Method System.Int32 IndexOfAny(Char[]
anyOf), System.Int32 IndexOfAny(Char[] anyOf, Int32 startIndex),
System.Int32 IndexOfAny(Char[] anyOf, Int32 startIndex, Int32...
Insert Method System.String Insert(Int32
startIndex, String value)
IsNormalized Method System.Boolean IsNormalized(),
System.Boolean IsNormalized(NormalizationForm normalizationForm)
LastIndexOf Method System.Int32 LastIndexOf(Char
value), System.Int32 LastIndexOf(Char value, Int32 startIndex),
System.Int32 LastIndexOf(Char value, Int32 startIndex, Int32 co...
LastIndexOfAny Method System.Int32 LastIndexOfAny(Char
[] anyOf), System.Int32 LastIndexOfAny(Char[] anyOf, Int32
startIndex), System.Int32 LastIndexOfAny(Char[] anyOf, Int32 start...
Normalize Method System.String Normalize(),
System.String Normalize(NormalizationForm normalizationForm)
PadLeft Method System.String PadLeft(Int32
totalWidth), System.String PadLeft(Int32 totalWidth, Char paddingChar)
PadRight Method System.String PadRight(Int32
totalWidth), System.String PadRight(Int32 totalWidth, Char
paddingChar)
Remove Method System.String Remove(Int32
startIndex, Int32 count), System.String Remove(Int32 startIndex)
Replace Method System.String Replace(Char
oldChar, Char newChar), System.String Replace(String oldValue, String
newValue)
Split Method System.String[] Split(Params
Char[] separator), System.String[] Split(Char[] separator, Int32
count), System.String[] Split(Char[] separator, StringSplitOpti...
StartsWith Method System.Boolean StartsWith
(String value), System.Boolean StartsWith(String value,
StringComparison comparisonType), System.Boolean StartsWith(String
value, Bo...
Substring Method System.String Substring(Int32
startIndex), System.String Substring(Int32 startIndex, Int32 length)
ToCharArray Method System.Char[] ToCharArray(),
System.Char[] ToCharArray(Int32 startIndex, Int32 length)
ToLower Method System.String ToLower(),
System.String ToLower(CultureInfo culture)
ToLowerInvariant Method System.String ToLowerInvariant
()
ToString Method System.String ToString(),
System.String ToString(IFormatProvider provider)
ToUpper Method System.String ToUpper(),
System.String ToUpper(CultureInfo culture)
ToUpperInvariant Method System.String ToUpperInvariant
()
Trim Method System.String Trim(Params Char
[] trimChars), System.String Trim()
TrimEnd Method System.String TrimEnd(Params
Char[] trimChars)
TrimStart Method System.String TrimStart(Params
Char[] trimChars)
Chars ParameterizedProperty System.Char Chars(Int32 index)
{get;}
Length Property System.Int32 Length {get;}

My System SpecsSystem Spec
Old 04-14-2009   #5 (permalink)
Mike


 
 

Re: Comparing arrays

On Apr 14, 2:38*pm, Mike <thelotu...@xxxxxx> wrote:
Quote:

> On Apr 10, 12:47*am, tojo2000 <tojo2...@xxxxxx> wrote:
>
>
>
Quote:

> > On Apr 9, 9:48*pm, Mike <thelotu...@xxxxxx> wrote:
>
Quote:
Quote:

> > > Hi all:
>
Quote:
Quote:

> > > Working on a project to identify home folders that are associated with
> > > a disabled AD account. I have 2 arrays, one has the list of home
> > > folders, the other contains a list of user accounts, with home drive,
> > > home directory, employee id, email address, etc that I gathered using
> > > get-qaduser cmdlet. I've been successful in the past comparing 2
> > > simple arrays, but I'm having problems with this one. I think the user
> > > array is a multidimensional array, from what I've read, and that's
> > > what's tripping me up. How can this be done?
>
Quote:
Quote:

> > > Thanks in advance...
>
Quote:

> > This sounds like two arrays are the wrong data structures for the
> > task. *Before we give you a push in the right direction, though, we
> > could use some more information. *What you have described is not two
> > arrays, but either an array and a hash, or an array and an object.
> > Can you give us more information without revealing anytihng
> > confidential or proprietery?
>
> Here's some further detail. I was originally thinking along the same
> lines as you, so I tried to export only the HomeDirectory field to
> another array and compare it, but that seemed kinda hacky, and I'm
> hoping there was a way to do this without creating another array. My
> user object and home drive array details are below.
>
> $UserAccountDetailList | Get-Member
>
> * *TypeName: System.Management.Automation.PSCustomObject
>
> Name * * * * * * *MemberType * Definition
> ---- * * * * * * *---------- * ----------
> Equals * * * * * *Method * * * System.Boolean Equals(Object obj)
> GetHashCode * * * Method * * * System.Int32 GetHashCode()
> GetType * * * * * Method * * * System.Type GetType()
> ToString * * * * *Method * * * System.String ToString()
> AccountIsDisabled NoteProperty System.Boolean AccountIsDisabled=False
> CanonicalName * * NoteProperty System.String CanonicalName=company.com/
> Departments/branch0101/Users/Staff/000010101
> cn * * * * * * * *NoteProperty System.String cn=000010101
> company-userstatus * *NoteProperty System.String company-userstatus=A
> createtimestamp * NoteProperty System.DateTime
> createtimestamp=8/23/2002 2:51:50 AM
> DisplayName * * * NoteProperty System.String DisplayName=Smith, James
> E
> Email * * * * * * NoteProperty System.String Email=jesm...@xxxxxx
> HomeDirectory * * NoteProperty System.String HomeDirectory=\\br1-home
> \home\JESmith
> HomeDrive * * * * NoteProperty System.String HomeDrive=H:
> LogonName * * * * NoteProperty System.String LogonName=JESmith
>
> $ServerFoldersListWithSize | Get-Member
>
> * *TypeName: System.String
>
> Name * * * * * * MemberType * * * * * *Definition
> ---- * * * * * * ---------- * * * * * *----------
> Clone * * * * * *Method * * * * * * * *System..Object Clone()
> CompareTo * * * *Method * * * * * * * *System.Int32 CompareTo(Object
> value), System.Int32 CompareTo(String strB)
> Contains * * * * Method * * * * * * * *System.Boolean Contains(String
> value)
> CopyTo * * * * * Method * * * * * * * *System.Void CopyTo(Int32
> sourceIndex, Char[] destination, Int32 destinationIndex, Int32 count)
> EndsWith * * * * Method * * * * * * * *System.Boolean EndsWith(String
> value), System.Boolean EndsWith(String value, StringComparison
> comparisonType), System.Boolean EndsWith(String value, Boolean ...
> Equals * * * * * Method * * * * * * * *System.Boolean Equals(Object
> obj), System.Boolean Equals(String value), System.Boolean Equals
> (String value, StringComparison comparisonType)
> GetEnumerator * *Method * * * * * * * *System.CharEnumerator
> GetEnumerator()
> GetHashCode * * *Method * * * * * * * *System.Int32GetHashCode()
> GetType * * * * *Method * * * * * * * *System.Type GetType()
> GetTypeCode * * *Method * * * * * * * *System.TypeCode GetTypeCode()
> get_Chars * * * *Method * * * * * * * *System.Char get_Chars(Int32
> index)
> get_Length * * * Method * * * * * * * *System.Int32get_Length()
> IndexOf * * * * *Method * * * * * * * *System.Int32 IndexOf(Char
> value), System.Int32 IndexOf(Char value, Int32 startIndex),
> System.Int32 IndexOf(Char value, Int32 startIndex, Int32 count),
> System...
> IndexOfAny * * * Method * * * * * * * *System.Int32IndexOfAny(Char[]
> anyOf), System.Int32 IndexOfAny(Char[] anyOf, Int32 startIndex),
> System.Int32 IndexOfAny(Char[] anyOf, Int32 startIndex, Int32...
> Insert * * * * * Method * * * * * * * *System.String Insert(Int32
> startIndex, String value)
> IsNormalized * * Method * * * * * * * *System.BooleanIsNormalized(),
> System.Boolean IsNormalized(NormalizationForm normalizationForm)
> LastIndexOf * * *Method * * * * * * * *System.Int32LastIndexOf(Char
> value), System.Int32 LastIndexOf(Char value, Int32 startIndex),
> System.Int32 LastIndexOf(Char value, Int32 startIndex, Int32 co...
> LastIndexOfAny * Method * * * * * * * *System.Int32 LastIndexOfAny(Char
> [] anyOf), System.Int32 LastIndexOfAny(Char[] anyOf, Int32
> startIndex), System.Int32 LastIndexOfAny(Char[] anyOf, Int32 start...
> Normalize * * * *Method * * * * * * * *System.String Normalize(),
> System.String Normalize(NormalizationForm normalizationForm)
> PadLeft * * * * *Method * * * * * * * *System.String PadLeft(Int32
> totalWidth), System.String PadLeft(Int32 totalWidth, Char paddingChar)
> PadRight * * * * Method * * * * * * * *System.String PadRight(Int32
> totalWidth), System.String PadRight(Int32 totalWidth, Char
> paddingChar)
> Remove * * * * * Method * * * * * * * *System.String Remove(Int32
> startIndex, Int32 count), System.String Remove(Int32 startIndex)
> Replace * * * * *Method * * * * * * * *System.String Replace(Char
> oldChar, Char newChar), System.String Replace(String oldValue, String
> newValue)
> Split * * * * * *Method * * * * * * * *System..String[] Split(Params
> Char[] separator), System.String[] Split(Char[] separator, Int32
> count), System.String[] Split(Char[] separator, StringSplitOpti...
> StartsWith * * * Method * * * * * * * *System.Boolean StartsWith
> (String value), System.Boolean StartsWith(String value,
> StringComparison comparisonType), System.Boolean StartsWith(String
> value, Bo...
> Substring * * * *Method * * * * * * * *System.String Substring(Int32
> startIndex), System.String Substring(Int32 startIndex, Int32 length)
> ToCharArray * * *Method * * * * * * * *System.Char[] ToCharArray(),
> System.Char[] ToCharArray(Int32 startIndex, Int32 length)
> ToLower * * * * *Method * * * * * * * *System.String ToLower(),
> System.String ToLower(CultureInfo culture)
> ToLowerInvariant Method * * * * * * * *System.String ToLowerInvariant
> ()
> ToString * * * * Method * * * * * * * *System.String ToString(),
> System.String ToString(IFormatProvider provider)
> ToUpper * * * * *Method * * * * * * * *System.String ToUpper(),
> System.String ToUpper(CultureInfo culture)
> ToUpperInvariant Method * * * * * * * *System.String ToUpperInvariant
> ()
> Trim * * * * * * Method * * * * * * * *System..String Trim(Params Char
> [] trimChars), System.String Trim()
> TrimEnd * * * * *Method * * * * * * * *System.String TrimEnd(Params
> Char[] trimChars)
> TrimStart * * * *Method * * * * * * * *System.String TrimStart(Params
> Char[] trimChars)
> Chars * * * * * *ParameterizedProperty System.Char Chars(Int32 index)
> {get;}
> Length * * * * * Property * * * * * * *System.Int32 Length {get;}
By the way, here are some examples of what I have in
$ServerFoldersListWithSize. I'm using a split to compare the folder
name.

user1,3.05
user2,0.10
user3,1.47
user4,0.09
user5,0.25
user6,6.66
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Question About arrays VB Script
Arrays PowerShell
Overwriting Arrays PowerShell
Arrays in Powershell PowerShell
Bug with multidimensional arrays PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46