## p4get-group ## aaron bockelie <# .SYNOPSIS Returns group objects for all or specific groups in the depot. .DESCRIPTION Run this command without any parameters to return an object with all groups enumerated by group. .EXAMPLE This example returns all groups in the depot. [PS] p4get-group Count Name Group ----- ---- ----- 19 p4infosys {@{isOwner=0; isUser=1; group=p4infosys; user=SpenAdmin; isSubGroup=0; maxResults=0;... 5 p4infosys-super {@{isOwner=0; isUser=1; group=p4infosys-super; user=spen; isSubGroup=0; maxResults=-... 7 p4infosys-users {@{isOwner=0; isUser=1; group=p4infosys-users; user=amanda.dunkle; isSubGroup=0; m... 1 p4infosys.infiniticket {@{isOwner=0; isUser=1; group=p4infosys.infiniticket; user=aaron.bockelie; isSubGrou... 1 p4infosys.peach {@{isOwner=0; isUser=1; group=p4infosys.peach; user=aaron.bockelie; isSubGroup=0; ma... .EXAMPLE This example returns a single group from the depot [PS] p4get-group p4infosys Count Name Group ----- ---- ----- 19 p4infosys {@{isOwner=0; isUser=1; group=p4infosys; user=SpenAdmin; isSubGroup=0; maxResults=0;... .PARAMETER group Optional parameter to request a single group returned from the depot. .FUNCTIONALITY Use this function to return an object (or objects) with all group membership information from the depot. #> Function p4get-group {param($group) $servercheck = p4get-server if ($servercheck.pingsuccess.equals($true)) { if ($group -eq $null) { $grouplist = p4 groups foreach ($request in $grouplist) { p4get-group $request } } if ($group -ne $null) { $cmd = "p4get `"group -o " + $group + "`"" $propertyitems = @("MaxResults","Group","Timeout","MaxLockTime","MaxScanRows","PasswordTimeout") $metagroup = @() $usersvalues = @() $ownersvalues = @() $subgroupsvalues = @() $groupdata = iex $cmd #p4get returns properties from a single client as two chunks, due to the way perforce likes to stick random carraige return/linefeeds in the comments section. Thanks perforce! foreach ($property in $groupdata.psobject.properties){$metagroup += $property} #insert each property into an intermediate table. $groupobject = new-object pscustomobject #instantiate a new $client object for return from the base function. foreach ($propertytag in $metagroup) #pull out the properties we care about and insert them with add-member into the new object. { foreach ($property in $propertyitems) { if ($propertytag.name -eq $property) { add-member -inputobject $groupobject -membertype $propertytag.membertype -name $propertytag.name -value $propertytag.value } } if ($propertytag.name -match "users") #now handle the line if it is a view. do not add as a member yet, we need to perform additional sorting to it. { $usersvalues += $propertytag.value } if ($propertytag.name -match "owners") #now handle the line if it is a view. do not add as a member yet, we need to perform additional sorting to it. { $ownersvalues += $propertytag.value } if ($propertytag.name -match "subgroups") #now handle the line if it is a view. do not add as a member yet, we need to perform additional sorting to it. { $subgroupsvalues += $propertytag.value } } $groupobject.group = $group add-member -inputobject $groupobject -membertype NoteProperty -name Owners -value $ownersvalues add-member -inputobject $groupobject -membertype NoteProperty -name SubGroups -value $subgroupsvalues add-member -inputobject $groupobject -membertype NoteProperty -name Users -value $usersvalues } return $groupobject } } #end p4get-group