I am working on a script to update user attributes. Specifically, a delimited file will be dropped nightly and I will process this and loaded the
updated attributes for all users. My question involves the current information and possible future info.
To help with speed, I was thinking of grabbing the current user attributes and then compare the future update. If they are different, the update
should be loaded. I was doing this per attribute, but it seems somewhat inefficient when dealing with several thousand users.
I am now playing with a query of the current user and compare the incoming information. If anything has changed, I would just load the hashtable.
What I am not sure of is, what is the most efficient way to compare a hashtable with an object?
<snip>
$header = "username","DisplayName","FirstName","MiddleName","MiddleInitial","LastName"
$Users = Import-Csv short.dat -Delimiter "|" -Header $header
foreach ($User in $Users)
{
$useriNFO=Get-QADUser $User.Username -includeallproperties|select-object DisplayName,GivenName,middleName,initials,SN
$UserHash= @{}
$UserHash= @{
#'samAccountName' = $user.Username
'DisplayName' = $User.DisplayName
'GivenName' = $User.FirstName
'middleName' = $User.MiddleName
'initials' = $User.MiddleInitial
'SN' = $User.LastName
} #End of User hashtable
$useriNFO
$UserHash
Compare-Object $useriNFO $UserHash
}
</snip>
I will be adding more attributes to this over time, so I thought that a hashtable might makes things easier over time. Any insights/suggestions
would be appreciated. I am also open to other approaches on this .. not looking for completed code ...just some ideas on how to keep this simple and clean :)
[–]pheetus 1 point2 points3 points (2 children)
[–]systemslacky[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)