dynamik wrote: » HP, where's your powershell script?
HeroPsycho wrote: » Me thinks dynamik was referring to yours truly. Go get the quest AD cmdlets and powershell:www.microsoft.com/powershellhttp://www.quest.com/activeroles-server/arms.aspx Ensure you launch the Quest Powershell tool, not a normal Powershell session (under start - programs - Quest). You're wanting to enumerate every group?! $groups = get-qadgroup * -sizelimit 0 $groups | foreach-object {get-qadgroupmember} Try that, but we're gonna have to play around with it to get it in the format you want. Post back with a sample and description of the output you receive. Surely he's not looking to see every freaking group membership. Are there certain groups he wants to see perhaps?
dsquery group -name Administrators | dsget group -members >c:\administrators.txt
FadeToBright wrote: » Or how can I output a list per group. Say, administrators and I want to find out who's in it and have it output to a txt file.
royal wrote: » Fade, do you still need something? I can script you out something if you need in PowerShell that'll go out and parse all groups and **** their users into a CSV for each group and without needing the Quest Snapin. Let me know and I'll write it up quick for you.
FadeToBright wrote: » That would be terrific, honestly.
$erroractionpreference = "SilentlyContinue" function Get-GroupMembers { $filter = "(objectCategory=Group)" $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.Filter = $filter $colResults = $objSearcher.FindAll() $ldapGroup = @() $group = @() foreach ($group in $colResults) { $group = $group.properties $ldapGroup += $group.adspath } foreach ($aGroup in $ldapGroup) { $a = $aGroup $b = [ADSI]"$aGroup" foreach ($member in $b.member) { $member } } } get-GroupMembers
royal wrote: » Well, here's what's done so far if you want to check it out. All it'll do is **** the data to the Powershell window in a very unorganized member but the below will get every group in AD and **** the membership out. Still need to finish the outputting. Do you want it in an excel? It'd be much easier for me to create a new folder on C:\, create a new Excel for every group, and **** the membership in there. Let me know. I love taking requests for scripts as it actually motivates me to script and learn.
HeroPsycho wrote: » FadeToBright, You can make with PowerShell webpage reports with custom formatting using ConvertTo-HTML, CSV files you can open and manipulate with Excel if you have Excel skills using export-csv, and you can also create Excel spreadsheets via COM object capability from PowerShell that Royal has done in his script. To use my one liner or Royal's script, you do NOT have to run it from the domain controller. Use either from your workstation with PowerShell, and if using my one liner, have the Quest AD CMDlets installed as well. Of course, you could use my one liner on the server to generate the CSV file report without Excel, too. Then copy it from there to a workstation with Excel, and pretty it up there. It's all about what you want to do, what skills you're comfortable with, etc.
Pash wrote: » This is really useful for me too! Are you guys just using the MSDN .net class library to search for proper uses? I found royals class here:-DirectorySearcher Class (System.DirectoryServices) Note: They don't have powershell syntax examples yet, I hope they will soon. I still don't understand the construction of the variable $group in the foreach loop though. $group.properties for example. How did we get there? Maybe I need to read on and stop jumping the gun, but that's just me
royal wrote: » Pash, when you get a list of the groups, it's essentially an object. You can store something in a variable and do a $variable.GetType() and see all the properties. I typically do $variable.GetType().FullName. When you run a variable, you'll even see the type before it runs. You can go to MSDN and search for that Type and it'll show you Members, Properties, Etc... A quick way to find that though in PowerShell, is by taking the Object and piping it to Get-Member. That'll show you variables, properties, etc... So $a | Get-Member. You can also do $a | Get-Member -static. For example, one TYPE Shortcut out there is [math]. Do [Math] | GM -static. You'll see Round. So to call a static method you'd do: [math]::round($variable,2). If $variable was 2.6342244 it'll round it to 2.63. I suggest you get the Powershell for the absolute beginner if you want to get started.