cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Anyone Managing their Windchill Installation with Powershell?

bcedar
14-Alexandrite

Anyone Managing their Windchill Installation with Powershell?

We have our Windchill servers deployed in Windows environments and have been stuck using command prompt and batch files to manage our servers...  Not too long ago, we started on a journey of pipeline based configuration using Azure Devops.

 

Officially PTC says they don't support Powershell.
https://www.ptc.com/en/support/article/CS323668?&language=en&posno=3&q=powershell&source=search

But I think I figured out how to at least get the environment variables from that handy windchill2.bat script.

 

foreach ($line in $(cmd.exe /c "E:\ptc\Windchill\bin\windchill2.bat setenv && set")) {
    [System.Environment]::SetEnvironmentVariable($line.split("=")[0], $line.split("=")[1], [System.EnvironmentVariableTarget]::Process)
}

 

Comment below on how you're managing your deployments?  What language(s) are you using?

1 REPLY 1
bcedar
14-Alexandrite
(To:bcedar)

I have expanded this powershell script to be wrapped into an if statement incase it gets called over and over.  You don't want to just keep expanding on your path.

This is a snippet from my Enter-WindchillShell.ps1 script.

if (
    -not (
        (Get-Command 'ant' -ErrorAction SilentlyContinue) -and 
        (Get-Command 'windchill' -ErrorAction SilentlyContinue) -and 
        (Get-Command 'xconfmanager' -ErrorAction SilentlyContinue) -and 
        (Get-Command 'windchill2.bat' -ErrorAction SilentlyContinue) -and 
        $ENV:WT_HOME
    )
) {
    $WT_HOME = Get-Item -Path E:\ptc\Windchill
    foreach ($line in $(cmd.exe /c "$WT_HOME\bin\windchill2.bat setenv && set")) {
        [System.Environment]::SetEnvironmentVariable($line.split("=")[0], $line.split("=")[1], [System.EnvironmentVariableTarget]::Process)
    }
}

 

Announcements