## p4revert-user ## aaron bockelie <# .SYNOPSIS Unlocks and reverts all files for a given user. .DESCRIPTION Reverting all files for a given user can be tedious. This function assists the task by automating the unlock and revert task. After the task is complete, a record of the reverted files is returned in a record object for each client. You must have Perforce super permissions in order for this function to operate correctly. .EXAMPLE This example reverts all files for the user 'p4infosysadmin' [PS] p4revert-user p4infosysadmin WARNING: This will revert ALL files on ALL clients belonging to p4infosysadmin Confirm Continue with this operation? [Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): Y revertcomplete client notreverted reverted -------------- ------ ----------- -------- True voltron2 {@{depotFile=//depot/servi... True voltron3 {@{depotFile=//depot/servi... The returned object contains the following objects: revertcomplete: a boolean value returning the status of the command. This is false if there are any files not reverted. client: the name of the client operated against. notreverted: an array of depot files that could not be reverted. reverted: an array of depot files that were successfully reverted. .PARAMETER clientname The client you wish to revert and unlock all files on. .FUNCTIONALITY This function simplifies the administrative overhead of reverting any and all files for a given user with multiple clients. #> Function p4revert-user {param([Parameter(Mandatory = $true)]$username,[switch]$force) $servercheck = p4get-server if ($servercheck.pingsuccess.equals($true)) { $result = @() $clientlist = p4get-userclient $username if ($clientlist -eq $null) { write-error "No clients to revert!" -category ObjectNotFound } else { if ($force.ispresent -eq $true) #if requested to try reverting, try the revert. { $message = "Forcibly reverting ALL files on ALL clients belonging to " + $username write-warning $message } else { $message = "This will revert ALL files on ALL clients belonging to " + $username #warn user write-warning $message -warningaction Inquire } foreach ($clientobject in $clientlist) { try { $result += p4revert-client $clientobject.client } catch { resolve-error $message = "An error occured reverting files on client `'" + $clientobject.client + "`'" write-error $message } } } } return $result }#end function p4revert-user