Function p4sync-allusers { $servercheck = p4get-server if ($servercheck.pingsuccess.equals($true)) { write-progress -id 10 -activity "Performing differential comparison on all users." -status "Please be patient." $userdiff = p4diff-allusers $removed = @() $nochange = @() $added = @() $i = 0 write-progress -id 10 -completed -activity "Complete." -status "Complete." foreach ($user in $userdiff) { write-progress -id 10 -activity ("Performing user add and removal actions for server " + $servercheck.server) -status ("Working on user " + $i + " of " + $userdiff.count) -percentcomplete (($i/$userdiff.count)*100) if ($user.sideindicator -eq "=>") #if the user is in active directory only { write-progress -id 10 -activity ("Adding user `'" + $user.inputobject + "`' to this server.") -status "Please be patient." write-warning ("Adding user " + $user.inputobject) p4add-newuser -userobject $user.inputobject $added += $user.inputobject } if ($user.sideindicator -eq "<=") #if the user is in perforce only { write-progress -id 10 -activity ("Removing user `'" + $user + "`' from this server.") -status "Please be patient." write-warning ("Removing user " + $user.inputobject) p4remove-user -users $user.inputobject -tryrevert #optimize this in the future with an array of users. probably will go a lot faster. $removed += $user.inputobject } if ($user.sideindicator -eq "==") #if the user is in both lists { $nochange += $user.inputobject } $i++ } $result = new-object psobject -property @{"removed" = $removed;"nochange" = $nochange;"added" = $added} } else { write-error "Couldn't verify server connection" } write-progress -id 10 -completed -activity "Complete." -status "Complete." return $result }
# | 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. |