
<p>Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014</p><p>Get Local Groups and Members PowerShell Tool</p><p>The help information provided below can also be viewed by using the following syntax:</p><p>Get-Help Get-LocalGroupsandMembers –Full</p><p>Help Info</p><p>NAME</p><p>Get-LocalGroupsandMembers</p><p>SYNOPSIS</p><p>Retrieves a list of groups as well as a specified group's members from </p><p> local and remote computers</p><p>SYNTAX</p><p>Get-LocalGroupsandMembers [[-ComputerName] <Object>] [[-GroupName] </p><p><Object>] [-GroupList] <String[]> [<CommonParameters>]</p><p>DESCRIPTION</p><p>The "Get Local Groups and Members PowerShell Tool" is able to display a list of groups on either the local or remote computer along with a specified group's members. This tool requires PowerShell version </p><p>3.0. This tool has only one mandatory parameter which is the $GroupList parameter. If you just want to find the members of the "Administrators" group on the local computer, then you do not have to make Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014 any specification for the -ComputerName or the -GroupName parameters since the local computer and the "Administrators" group has been set as the default values. If you want to get a list of members of the "Administrators" group from a remote computer, then you specify the remote computer name using the -ComputerName parameter, but again, you do not have to specify the "Administrators" group using the -GroupName parameter since that is the default value. This script will also attempt to detect if the </p><p>Administrators group has been renamed, and if so, it will target that group instead. This tool uses the </p><p>"System.DirectoryServices.AccountManagement" .Net namespace that was released with .Net </p><p>Framework 3.5. Since Windows PowerShell 3.0 requires the full installation of Microsoft .NET </p><p>Framework 4, this will not be a problem, just ensure that the "#Requires -Version 3.0" statement remains at the top of the script to be used as the primary detection method, assuming that the full .Net </p><p>Framework 4 version is installed. </p><p>PARAMETERS</p><p>-ComputerName <Object></p><p>Used to query a single computer or multiple computers.</p><p>Required? false</p><p>Position? 1</p><p>Default value $env:COMPUTERNAME</p><p>Accept pipeline input? true (ByValue, ByPropertyName)</p><p>Accept wildcard characters? false</p><p>-GroupName <Object></p><p>Used to specify the name of a group if the default Administrators Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014 group is not desired.</p><p>Required? false</p><p>Position? 2</p><p>Default value Administrators</p><p>Accept pipeline input? true (ByValue, ByPropertyName)</p><p>Accept wildcard characters? false</p><p>-GroupList <String[]></p><p>A mandatory parameter used to display a list of all the local groups </p><p> on a local or remote computer. This parameter requires only a Yes or </p><p>No value.</p><p>Required? true</p><p>Position? 3</p><p>Default value </p><p>Accept pipeline input? false</p><p>Accept wildcard characters? false</p><p><CommonParameters></p><p>This cmdlet supports the common parameters: Verbose, Debug,</p><p>ErrorAction, ErrorVariable, WarningAction, WarningVariable,</p><p>OutBuffer and OutVariable. For more information, see </p><p> about_CommonParameters </p><p>(http://go.microsoft.com/fwlink/?LinkID=113216). </p><p>Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014 INPUTS</p><p>OUTPUTS</p><p>------EXAMPLE 1 ------</p><p>C:\PS>To get a list of the local groups and the members of the </p><p>Administrators group on the local computer:</p><p>Get-LocalGroupsandMembers -GroupList "Yes"</p><p>------EXAMPLE 2 ------</p><p>C:\PS>To NOT get a list of the local groups, but to get the members of the </p><p>Administrators group on the local computer:</p><p>Get-LocalGroupsandMembers -GroupList "No"</p><p>Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014</p><p>------EXAMPLE 3 ------</p><p>C:\PS>To get a list of the local groups and get the members of another </p><p> group besides the default Administrators group on the local computer:</p><p>Get-LocalGroupsandMembers -GroupList "Yes" -GroupName "Group1"</p><p>------EXAMPLE 4 ------</p><p>C:\PS>To NOT get a list of the local groups, but to get the members of </p><p> another group besides the default Administrators group on the local </p><p> computer:</p><p>Get-LocalGroupsandMembers -GroupList "No" -GroupName "Group1"</p><p>Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014</p><p>------EXAMPLE 5 ------</p><p>C:\PS>To get a list of the local groups and the members of the </p><p>Administrators group on a remote computer:</p><p>Get-LocalGroupsandMembers -ComputerName "Computer1" -GroupList "Yes"</p><p>------EXAMPLE 6 ------</p><p>C:\PS>To NOT get a list of the local groups, but to get the members of the </p><p>Administrators group on the remote computer:</p><p>Get-LocalGroupsandMembers -ComputerName "Computer1" -GroupList "No"</p><p>------EXAMPLE 7 ------Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014</p><p>C:\PS>To get a list of the local groups and get the members of another </p><p> group besides the default Administrators group on a remote computer:</p><p>Get-LocalGroupsandMembers -ComputerName "Computer1" -GroupList "Yes" </p><p>-GroupName "Group1"</p><p>------EXAMPLE 8 ------</p><p>C:\PS>To NOT get a list of the local groups, but to get the members of </p><p> another group besides the default Administrators group on a remote </p><p> computer:</p><p>Get-LocalGroupsandMembers -ComputerName "Computer1" -GroupList "No" </p><p>-GroupName "Group1"</p><p>Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014 ------EXAMPLE 9 ------</p><p>C:\PS>To get a list of the local groups and get the members of the </p><p>Administrators group on multiple computers:</p><p>Get-LocalGroupsandMembers -ComputerName @("Compute1", "Computer2", </p><p>"Computer3") -GroupList "Yes"</p><p>------EXAMPLE 10 ------</p><p>C:\PS>To get a list of the local groups and get the members of another </p><p> group besides the default Administrators group on multiple computers:</p><p>Get-LocalGroupsandMembers -ComputerName @("Compute1", "Computer2", </p><p>"Computer3") -GroupList "Yes" -GroupName "Group1"</p><p> or </p><p>Get-LocalGroupsandMembers -ComputerName (Get-Content -Path </p><p>"$env:TEMP\ComputerList.txt") -GroupList "Yes" -GroupName "Group1" Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014</p><p>------EXAMPLE 11 ------</p><p>C:\PS>To get a list of the local groups and get the members of multiple </p><p> groups on the local computer:</p><p>Get-LocalGroupsandMembers -GroupList "Yes" -GroupName @("Group1", </p><p>"Group2", "Group3")</p><p> or</p><p>Get-LocalGroupsandMembers -GroupList "Yes" -GroupName (Get-Content -Path </p><p>"$env:TEMP\GroupList.txt")</p><p>------EXAMPLE 12 ------</p><p>C:\PS>To get a list of the local groups and get the members of multiple Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014 groups on multiple computers:</p><p>Get-LocalGroupsandMembers -ComputerName @("Compute1", "Computer2", </p><p>"Computer3") -GroupList "Yes" -GroupName @("Group1", "Group2", "Group3")</p><p> or</p><p>Get-LocalGroupsandMembers -ComputerName (Get-Content -Path </p><p>"$env:TEMP\ComputerList.txt") -GroupList "Yes" -GroupName (Get-Content </p><p>-Path "$env:TEMP\GroupList.txt")</p><p>------EXAMPLE 13 ------</p><p>C:\PS>To get a list of the local groups and get the members of multiple </p><p> groups on multiple computers and output the info to a .log (or .txt file) </p><p> while displaying the results on screen:</p><p>Get-LocalGroupsandMembers -ComputerName @("Compute1", "Computer2", </p><p>"Computer3") -GroupList "Yes" -GroupName @("Group1", "Group2", "Group3") | </p><p>Tee-Object -Filepath "$env:TEMP\ListofGroupsandMembers.log" Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014</p><p> or</p><p>Get-LocalGroupsandMembers -ComputerName (Get-Content -Path </p><p>"$env:TEMP\ComputerList.txt") -GroupList "Yes" -GroupName (Get-Content </p><p>-Path "$env:TEMP\GroupList.txt") | Tee-Object -Filepath </p><p>"$env:TEMP\ListofGroupsandMembers.txt"</p><p>------EXAMPLE 14 ------</p><p>C:\PS>To get a list of the local groups and get the members of multiple </p><p> groups on multiple computers and output the info to a .log (or .txt file) </p><p> while NOT displaying the results on screen:</p><p>Get-LocalGroupsandMembers -ComputerName @("Compute1", "Computer2", </p><p>"Computer3") -GroupList "Yes" -GroupName @("Group1", "Group2", "Group3") | </p><p>Out-File -FilePath "$env:TEMP\ListofGroupsandMembers.log"</p><p> or</p><p>Get-LocalGroupsandMembers -ComputerName (Get-Content -Path Author: Ron Ratzlaff (aka “The_Ratzenator”) Date: 8\26\2014 "$env:TEMP\ComputerList.txt") -GroupList "Yes" -GroupName (Get-Content </p><p>-Path "$env:TEMP\GroupList.txt") | Out-File -FilePath </p><p>"$env:TEMP\ListofGroupsandMembers.txt"</p><p>RELATED LINKS</p>
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages12 Page
-
File Size-