Skip to content

MtoA deployment script

ps1
$NetworkPath = "\\<NAS>"
$login = ""
$pass = ""

New-SMBMapping -LocalPath "A:" -RemotePath $NetworkPath -UserName $login -Password $pass

# Clean
$vfhpaths = @(
    "C:/MTOA/maya2022";
)

foreach ($vfhpath in $vfhpaths)
{
    if ((Get-Item $vfhpath) -is [System.IO.DirectoryInfo]) {
        rm -r -fo $vfhpath
    }
    else {
        remove-item /f $vfhpath
    }
}

# Recreate folder
$rootMTOA = "C:\MTOA"
If (!(test-path $rootMTOA))
{
    md $rootMTOA
}

md "C:\MTOA\maya2022"

# Copy zip
Copy-Item A:\Autodesk\arnold\mtoa\maya2022\maya2022.zip -destination C:\MTOA\maya2022 -Recurse -Force

# Extract
Expand-Archive C:\MTOA\maya2022\maya2022.zip -DestinationPath C:\MTOA\maya2022

# Add on top of env variables, if not exist
$PathContent = [Environment]::GetEnvironmentVariable('MAYA_PLUG_IN_PATH', 'Machine')
if ($PathContent -split ';' -NotContains  "C:\MTOA\maya2022\plug-ins") {
    [Environment]::SetEnvironmentVariable("MAYA_PLUG_IN_PATH", 'C:\MTOA\maya2022\plug-ins;'+[Environment]::GetEnvironmentVariable('MAYA_PLUG_IN_PATH', 'Machine'), [System.EnvironmentVariableTarget]::Machine)
}

# set env for job render
[System.Environment]::SetEnvironmentVariable("MAYA_RENDER_DESC_PATH","C:\MTOA\maya2022\", [System.EnvironmentVariableTarget]::Machine)

Remove-SmbMapping -LocalPath "A:" -Force