Skip to content

#################### FUNCTIONS #################### function GetEnvs { return [Environment]::GetEnvironmentVariables([System.EnvironmentVariableTarget]::User) }

function GetEnv { Param( [Parameter(Mandatory=$true, Position=0)] [string]$Name ) return [Environment]::GetEnvironmentVariable($Name, [System.EnvironmentVariableTarget]::User) }

function SetEnv { Param( [Parameter(Mandatory=$true, Position=0)] [string]$Name, [Parameter(Mandatory=$False, Position=1)] [string]$Value ) [Environment]::SetEnvironmentVariable($Name, $Value, [System.EnvironmentVariableTarget]::User) }

function RemoveEnv { Param( [Parameter(Mandatory=$true, Position=0)] [string]$Name ) SetEnv -Name $Name -Value "" }

#################### CONSTANT ####################

Environment Allowed List

$ALLOWED_USER_ENVS= "TMP", "TEMP", "OneDrive"

Rez env values

$REZ_CONFIG_PATH="\squeeze\software\prod\rez\rezconfig_windows_mtl.py"

New rez env values

$NEW_REZ_USERS= "oargentieri", "jdoe" $NEW_REZ_CONFIG_PATH="<SERVER_ROOT>...\rezconfig.py"

Bin values

$GIT_BIN_PATH="C:\PROGRA~1\Git" $NEW_REZ_BIN_PATH="<SERVER_ROOT>...\Scripts\rez" $REZ_BIN_PATH="C:\PROGRA~1\rez\Scripts\rez"

Fallback to new rez if current user is allowed to use it

if ($NEW_REZ_USERS.Contains($env:USERNAME)) { $REZ_BIN_PATH=$NEW_REZ_BIN_PATH $REZ_CONFIG_PATH=$NEW_REZ_CONFIG_PATH }

Environment variables

$OTHER_ENVS = @{ SHOTGRID_KEYS="<SERVER_ROOT>...\keys.ini"; OCIO="<SERVER_ROOT>...\config.ocio"; REZ_CONFIG_FILE=$REZ_CONFIG_PATH; FLEXLM_DIAGNOSTIC=0; PATH="$($REZ_BIN_PATH);$($GIT_BIN_PATH)"; }

#################### MAIN ####################

Clean environment

foreach ($key in (GetEnvs).keys) { if ($ALLOWED_USER_ENVS.contains($key)){ continue } RemoveEnv -Name $key }

Set other env

foreach ($obj in $OTHER_ENVS.GetEnumerator()) { SetEnv -Name $obj.key -Value $obj.value }