# if ($env:depotsxml) { if ((test-path $env:depotsxml) -eq $true) { $scriptPath = (gci $env:depotsxml).DirectoryName $libScriptPath = (gci $env:depotsxml).DirectoryName + "\lib\" $libScripts = gci $libScriptPath $userscriptpath = $null if ($libScripts) { "Valid depots.xml environment path found" ("Loading libraries from " + $libScripts.directoryname[0]) foreach ($script in $libScripts) { . $script.fullname } } } else { throw ("Cannot locate " + $env:depotsxml) } } else { try { $scriptPath = (gci depots.xml) } catch { throw $error[0] } if ($scriptPath) { $answer = read-host -Prompt ("depots.xml file found in current directory.`r`nSet depotsxml system environment variable to `'" + $scriptPath + "`'?`r`n(y/n)") if ($answer.tolower() -match "y") { try { [Environment]::SetEnvironmentVariable("depotsxml", $scriptPath, "Machine") $env:depotsxml = $scriptPath } catch { write-error ("Could not set environment variable" + $error[0]) break } } else { write-host "Please specify system environment variable `'depotsxml`' so it points to a valid depots.xml file and try again." break } } else { $userscriptpath = read-host -Prompt "Autolocate of depots.xml failed. Please manually specify location of depots.xml`r`nPress enter without any input to abort.`r`n" if (!$userscriptpath) { write-host "Configuration of system environment variable `'depotsxml`' canceled." break } else { try { $scriptPath = (gci $userscriptpath).fullname } catch { write-error ("depots.xml file not found." + $error[0]) } [Environment]::SetEnvironmentVariable("depotsxml", $scriptPath, "Machine") $env:depotsxml = $scriptPath } } write-warning "Please dot load p4ps1.ps1 again to use function collection" }