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

Looping not working when exporting the result to csv

$
0
0

Hi Buddies,

I am working on a basic script that imports group list from a text file and then check if the group having no members.

import-csv .\groups.txt | foreach-object {
Get-ADGroup -identity $_.samaccountname -Properties Members | where {-not $_.members} | select Name, members | Export-Csv .\emptygroups.csv –NoTypeInformation
}

When I am exporting it to csv, I am getting only the last group in the output. Can you please let me know what is wrong in this code?

Thanks!!

Himanshu


MCTS|MCSE|MCSA:Messaging|CCNA




Viewing all articles
Browse latest Browse all 15028

Trending Articles



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