## p4login ## aaron bockelie <# .SYNOPSIS Logs user into depot, setting special flags that other functions can use to determine perforce server state .DESCRIPTION Logs user into a given Perforce depot after supplying required credential information. This script also sets a number of session environment variables, and returns an array object of the login results. .EXAMPLE This will interactively prompt you for every required parameter: [PS] p4loginhash Supply values for the following parameters: server: infosys port: 1673 username: aaron.bockelie Enter Password: .EXAMPLE p4login -server servername -port port -username user.name -password Pa$$word This will immediately log you into the depot with out any prompting. .PARAMETER server Perforce server dns name .PARAMETER port Port that the Perforce server is listening on .PARAMETER username Valid username for depot logon. This user should have super rights in the depot. .PARAMETER password Password for depot authentication. If this parameter is not supplied, it will be requested interactively. .FUNCTIONALITY This function should be used at the start of any session that will use ANY of the other p4 cmdlets. The following environment variables are also set: p4logincall perforceport p4server You may call these variables from the current session with the $env: function. For example: $env:p4server Returns the server that the function logged into. #> Function p4login #logs user into perforce depot. Needs $server, $port, $username and password, which is piped to the function. {param([Parameter(Mandatory=$true)]$server,[Parameter(Mandatory=$true)]$port,[Parameter(Mandatory=$true)]$username,$password) $serverport = $server + ":" + $port #combine server and port into a p4set option that perforce can understand. $env:p4port=$serverport #set the server $env:p4user=$username #set the user $env:p4logincall = $true $env:perforceport = $port $env:p4server = $server $env:p4passwd = $null if (!$password) { $password = Read-HostMasked } $command = $password| p4 login #pipe the password into if ($command -match "logged in.") { $loginstatus = @{"loginsucceed" = $true;"server" = $server;"port" = $port;"user" = $username} } else { $loginstatus = @{"loginsucceed" = $false;"server" = $server;"port" = $port;"user" = $username} #p4logout write-error "Perforce login failed." -category OperationTimeout } return new-object psobject -property $loginstatus }# end p4login
# | 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. |