Friday, March 23, 2018

Group Membership Report – PowerShell Script

Another “Group Membership Report” script.  You can see some of the previous versions here - http://portal.sivarajan.com/2010/08/list-group-members-in-active.html.

This script provides the group membership details based on user name.  You can include all user names in an input file (Users.csv) in the following format:















Script uses Get-ADUser cmdlet to validate the user first then get the user membership using the “memberof” properties.  Output/report will be in the GMReport_$Cdate.csv file.  Error message will be captured in Error_$Cdate.csv file.

Script:
#
#Group Membership Report – PowerShell Script
#Santhosh Sivarajan (santhosh@sivarajan.com)
#
Clear
Import-Module ActiveDirectory
$userN = ""
$GroupDetails = ""
$Group = ""
$GroupsDN = ""
$uValidation = ""
$Cdate = (Get-Date).tostring("dd-MM-yyyy-hh-mm-ss")

    $Report = New-Item -type file -force "C:\Temp\GMReport_$Cdate.csv"
    Import-CSV "C:\Temp\Users.csv" | % {
    $userN = $_.userName
    $sourceDomain = $_.Domain
    $uValidation = Get-ADUser -filter {sAMAccountName -eq $userN} -Server $sourceDomain
   
        If($uValidation -eq $Null)
             {
              Write-Host "User $userN Doesn't Exist in $sourceDomain Domain"
              $errorFile = New-Item -type file -force "C:\Temp\Error_$Cdate.csv"
              "User $userN Doesn't Exist in $sourceDomain Domain"| Out-File $errorFile -encoding ASCII -append
             }
         Else
             {
               
                $userN | Out-File $SGBeforeUpdateFile -encoding ASCII -append
                $GroupDetails = get-aduser -Server $sourceDomain -identity $userN -Properties memberof
                $GroupsDN = $GroupDetails.memberof
                $GroupsDN | Out-File $SGBeforeUpdateFile -encoding ASCII -append
            }
    }

Download:
You can also download the script from the following locations:
  1. OneDrive
  2. TechNet Gallery 

23 comments:

Quel est notre produit? - La meilleure marque de luxe au monde regarde des kopie horloges de la plus haute qualité! Si vous voulez avoir ces Kopie Horloges IWC de luxe, vous voulez porter ces montres sur votre poignet, mais arrêtez-vous en raison de leur prix élevé. Alors s'il vous plaît arrêtez vos pas, c'est votre endroit le plus correct..

You should check this site and get the fabulous college application writing guide. I assume you need this.

A very good article. Thanks to the author.I was very helped by the essay for dummies .

Thank you for this article. She is very close to my topic. College Paper Help.

Very useful information!
Check up this app, it's useful too:
https://speedypaper.app/

Thank you for this post. This is very interesting information for me. Just contact www.writingpapersucks.com if you looking for the best essay service.

Helpful article. I found interesting information for me. TopEssayServices reviews

I ordered a replica watch here. When I received the watch,Best UK Swiss watches it surprised me very much. This watch is perfect and the quality is exactly the same as the real watch. A dazzling masonry. Fake rolex Watches I introduced this website to my friends, and my friends liked it very much.

De beste luxe tijd ter wereld Goedkope luxe tijd! Wil je deze kopie horloges verkoop als je deze luxe kopie hublot dames en heren horloges wilt? Dit is gebeurd maar gestopt bij? Omdat hun dure prijs uw stappen stopt, is dit de meest correcte plaats voor u. Allereerst moeten we dit bevestigen

Many thanks for this post, this is what I need, I will definitely try. I write articles if it's interesting to visit my site https://statistics.homeworkfor.me/.


Hermes handbags Luxury Genuine Leather Bags. If you have ever drooled over the gorgeous and exquisite Handbags available in any outlet, you would love to own one. The existing counterfeit Louis Vuitton Bags available in this website include classy and sophisticated Monogram Canvas leather handbags which come in colours like white, black, brown and blue. You can also choose from Rolex Watches of Kelly bags which come with more luxurious colours and designs.

Great blog!!! Could you give me more tips about your blog? What would you say about it? You ideas are more important for me...thanks for sharing it. The solar panels are best option for saving money. https://estimate.solar

The dating.com reviews has helped a lot of singles get into a relationship. And that's just amazing.

Dietary Cafe est le meilleur site de santé et de remise en forme pour reconstruire votre poids corporel ainsi que votre condition physique.

https://www.dietarycafe.com/

https://www.dietarycafe.com/keto-body-tone-avis-fr/
http://wealthcode.over-blog.com/


Class College Education training Beauty teaching university academy lesson  teacher master student  spa manager  skin care learn eyelash extensions tattoo spray


Hi there. I need to find how to write my memo paper . Many tasks can be found ready-made. Articles or essays on a server where writers are professionals. Many tasks are easier to accomplish.

I have visited your website.Thanks for sharing this beautiful website with us.Keep blogging. Go with my site insta stalker to know more information about instagram.

TimesTech provides Latest electronics news, Semiconductor News, Technology News, Get connected to global community of tech news, Electronics Projects, Electronics Circuit here at https://timestech.in/ for more inquiery mail us at info@timestech.in ,91-122-3550122

Looking for Academic Assignment service? Get Quality Assignment Help Online by Best Assignment Writing Experts at an affordable price. My Assignment Helpis the best assignment service provider offered online by a team of experts tutors of Australia , UK and USA. Our support team is available round the clock to help you.

Get the best Accounting Homework Help from our accounting experts. Our professionals aim to provide best possible Online Homework Help for school level, College level and university level students. Urgenthomework is one of the best online assignment service portal that provides quality Accounting Homework Help and Accounting Assignment Help. Also, do check our marketing homework help. you're at the right place if you need Marketing Homework Help, Marketing Assignment Help and this is where you will find the answers to all your queries related to marketing.

Online information technology assignments help companies are very keen when it comes to Information Technology Writing Services for IT students in order for them to score straight A’s in their information technology research papers.

Online political science essay writing help services are very common nowadays since there are very many students seeking Political Science Writing Services and political science research paper writing services.

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More