Skip to content
Snippets Groups Projects
Commit 8e52c16c authored by Simon Janos's avatar Simon Janos
Browse files

Merge branch 'master' of https://git.sch.bme.hu/jano/irf-hazi

parents ae61b807 b2e26efa
Branches
Tags
No related merge requests found
<#
.SYNOPSIS
test
.DESCRIPTION
test
.PARAMETER hostname
hostname
.NOTES
Author: Simon Janos
#>
Param(
[Parameter(Mandatory=$true,Position=0)][String] $Group,
[switch] $Inactive
)
Import-Module ActiveDirectory
$ou = Get-ADOrganizationalUnit -Filter 'name -eq $Group'
$allUsers = Get-ADUser -SearchBase $ou.DistinguishedName -filter * -Properties MemberOf,mail
$htUsers = @{}
Write-Output $allUsers | ForEach-Object { $htUsers.Add($_.mail, $_.MemberOf.Count) }
$htUsers = ($htUsers.GetEnumerator() | Sort-Object { $_.Value })
#Write-Output $htUsers
if ($Inactive) {
$etalon = ($htUsers.GetEnumerator() | Select-Object -First 1)
}else {
$etalon = ($htUsers.GetEnumerator() | Select-Object -Last 1)
}
Write-Output $etalon.Value
Write-Output ($htUsers.GetEnumerator() | Where-Object { $_.Value -eq $etalon.Value })
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment