Last active
April 28, 2021 17:32
-
-
Save TylerJWhit/39924f1692b51c0c4c92d057a6ec2164 to your computer and use it in GitHub Desktop.
Get-RemoteLocalGroupMembers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Version: 0.5 | |
# Date: 2021-04-28 | |
# File Name: Get-RemoteLocalGroupMembers | |
# Author: TylerJWhit | |
# Notes: | |
# The following commands may be of help: | |
# | |
# Run against every computer in domain. | |
# Get-ADComputer -Filter * | Select-Object -ExpandProperty Name | Get-RemoteLocalGroupMembers | |
# | |
# Run against CSV (replace path with location of file and ensure A1 says 'computername': | |
# Get-RemoteLocalGroupMembers -computers (Import-Csv -Path C:\Computers.csv | Select-Object -ExpandProperty computername) | |
# | |
# Run against computers listed in command: | |
# Get-RemoteLocalGroupMembers -computers HOSTNAMEA,HOSTNAMEB | |
function Get-RemoteLocalGroupMembers{ | |
[CmdletBinding()] | |
[Parameter(ValueFromPipeline=$true)] | |
[Alias('name')] # Helps with 'Select-Object -ExpandProperty Name' | |
[string[]]$computers = $env:COMPUTERNAME | |
foreach ($computer in $computers){ | |
Invoke-Command -ComputerName $computer -ScriptBlock{foreach ($group in (get-localgroup)){get-localgroupmember -Group $group}} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment