Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Lost in $result

$
0
0

hello,

Whenever  I think, "yeaaah I get it"I am no longer een Noob..:)
A new issue pops up that cracks my brains...
It makes me learn more and that is good, only now I am confused, and start to think in circles ...

I use import-csv with 13 samacountnames, and a header called 'samccountname"

When I try $var =get-aduser ....
or Get-aduser ...|export-csv , the output is just 1 user

When I run it with just get-ADuser .... it returns all 13 users with their groups.

$users = import-csv "D:\Users\Documents\PS-script\Output\Inactief.csv"

$Export   = "D:\Users\Documents\PS-script\output\Adgroup_inactief.csv"

$Result = @()

foreach ($user in $userlist.samaccountname)  {
               
         $result= Get-ADUser -Identity $user -Properties 

Memberof |select-object name, memberOf 
            } 

$result | | export-csv $Export

I tried to do :

Get-ADUser -Identity $user -Properties Memberof |select-object name, memberOf | export-csv $Export
Only this returns just the last user.

Also this returns the last user:
 $result= Get-ADUser -Identity $user -Properties Memberof |select-object name, memberOf
Thanks for telling me, where I go the wrong path..:)


pba1211


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>