Posts

Showing posts from June, 2021

Set Powershell to TLS 1.2

Image
Set Powershell to TLS 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

USER - List of users present in list of AD groups

List of users present in list of AD groups $users = Get-content "$env:USERPROFILE\Desktop\users.txt" $groups = Get-Content "$env:USERPROFILE\Desktop\Groups.txt" $result = foreach($user in $users){  foreach($group in $groups){ try{ $groupmembers = Get-ADGroupMember $group -ErrorAction Stop }   catch{ $groupmembers = $null } if($groupmembers.samaccountname -match $user){   [PSCustomObject]@{ Name = $user Group = $group Member = 'True' } }   else{ [PSCustomObject]@{   Name = $user Group = $group Member = 'False' } } } } $result | export-csv  "$env:USERPROFILE\Desktop\result.csv" -NoTypeInformation