<# .SYNOPSIS Returns a differential list object of all users for a perforce server compared active directory with multiple auth groups. Use this script to create user objects. #> Function p4diff-allusers {param([switch]$verbosediff) $servercheck = p4get-server if ($servercheck.pingsuccess.equals($true)) { $authgroup = "p4" + $servercheck.server $aduserobjects = $null $p4userobjects = $null try { $p4userobjects = p4get users $aduserobjects = get-qadgroupmember $authgroup -indirect | ?{$_.type -eq "user"} } catch { #if an error with getting group, throw error. throw "Something went horribly wrong when attempting to return Active Directory users or Perforce users" } $ADusers = $aduserobjects | %{$_.samaccountname}#return a simple list of user names from ad $P4users = $p4userobjects | %{$_.user} #return a simple list of user names from perforce #sort users equally. if ($ADUsers){$ADusers = $ADusers | sort-object} else {$ADusers = @()} #if the object is null, create an empty object, otherwise sort the object. if ($P4users){$P4users = $P4users | sort-object} else {$P4users = @()} #if the object is null, create an empty object, otherwise sort the object. #reconcile groups try { $RecUsers = compare-object -includeequal -syncwindow 1000 $P4users $ADusers #Reconcile the list from AD with the list from Perforce. Syncwindow is for sorting the users correctly. } catch { write-error "One or more user lists are null." -category InvalidOperation } if ($verbosediff.ispresent -eq "True") { foreach ($diff in $RecUsers) { if ($diff.sideindicator -eq "=>") { $verboseoutput += $diff.inputobject + ", user in Active Directory only.`r`n" } if ($diff.sideindicator -eq "<=") { $verboseoutput += $diff.inputobject + ", user in Perforce only.`r`n" } if ($diff.sideindicator -eq "==") { $verboseoutput += $diff.inputobject + ", user in Perforce and Active Directory group.`r`n" } } return $verboseoutput } else { $RecUsers #return compared object. } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 8410 | Aaron Bockelie |
Root checkin, Perforce Powershell wrapper. Still lots of work to be done, namely documentation and deployment tools, for instance, get-help needs work on the majority of these tools. Additionally, the /lib structure needs a little bit of condensation, probably into major groups (depot, userspec, clientspec, group management, and so on) that way function family can exist under each resource. |