# encoding: ascii
# api: powershell
# title: Get-LocalGroupMembers
# description: RU_DAX_ERP_Read
# version: 0.1
# type: function
# author: Carter Shanklin
# license: CC0
# function: Get-LocalGroupMembers
# x-poshcode-id: 6581
# x-archived: 2016-12-22T03:01:25
# x-published: 2016-10-17T14:33:00
#
#
function Get-LocalGroupMembers {
	param($groupname)

	$pattern = "*Name=`"$groupname`""
	$groupusers = gwmi Win32_GroupUser | Where { $_.GroupComponent -like $pattern }

	# Now extract the usernames.
	foreach ($user in $groupusers) {
		if ($user.PartComponent -match 'Name="([^"]+)') {
			Write-Output $matches[1]
		}
	}
}

# Use it like this.
# Get-GroupMembers Administrators
