Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Why not pull a list of DL's from Exchange and then push that through an Get-ADGroupMember cmdlet using the ().count and assigning to variable. Then pushing that out to an out-gridview of those that are empty. So something like
$emptDLs = @()
$DLs = Get-DistributionGroup
$DLs | Foreach {
$count = (Get-ADGroupMember -identity $_.Name).Count
If ($count -gt "0") {
Write-Host "DL $_.DisplayName is empty. Adding to list"
$emptyDLs = $emtpDLs + $_ (Or something like that. I always mix up the operators and have to look them up.)
}
$emptyDLs | Out-Gridview or Out-File with an append
jvierra wrote: ↑Wed Aug 22, 2018 4:42 pm
"Count" is an integer and not a string. Always remember that string numbers cannot normally be compare correctly.
Hm.. no wonder it doesn't work.
however, I've tried to modify the script to be like the following:
This topic is 5 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.