Doesn't find pyrevit CLI when running deployment script

Hey all
New to pyrevit but has made few tools and have been trying to deploy it to my colleagues that are not tech savy and need it served if there should be a chance of them installing the tools.

So made a powershell script based on the info here: pyRevit For Teams (notion.site)

But when running the script at first i get that warning pyrevit is not a recognized cmdlet, like the CLI has not been added to the env path variable. But when I check the path C:\Program Files\pyRevit CLI\bin is in system variables.

When i run the script again everything works fine and the tools are available in Revit.

Anybody tryed this and have a solution? Seems like restarting Powershell does the trick but how does one do that mid executing and is that the right way to go.

Appreciate any help
Best regards Casper

Still haven’t solved this so if any has the slides idea…

You may want to run two different script, one to install cli, one for everything else, and these needs to run one instance of ps after the other.

You could also run it in one go knowing where the cli is being installed with something like

python PathToUrCli then the command

I haven’t tried it

I have tried to run in one go and the installation are running and with a restart of powershell the CLI is working. It’s just not working in one go.

This is the script before all the pyrevit cmdlet’s:

# install CLI dependencies
Write-Output "Installing .Net (4.8)..."
Start-Process -FilePath "Path\to\.net\\ndp48-web.exe" `
              -ArgumentList "/VERYSILENT /norestart" `
              -Wait `
              -Verb RunAs > $null


# install/update pyRevit CLI
Write-Output "Installing pyRevit CLI..."
Start-Process -FilePath "path\to\CLI\\pyRevit_CLI_4.8.13.23182_admin_signed.exe" `
              -Wait `
              -ArgumentList "/SILENT"> $null 

$env:Path += "C:\Program Files\pyRevit CLI"

So if run this ones I get a error, if i do nothing but run it again everything works.

Don’t want to muddy this discussion but I too have found sometimes that adding something to path in windows does not guarantee its availability.

Now with that being said, since the CLI is often installed under program files, you could technically call pyrevit cli using a direct path in your ps script no?

Have you found a solution to guarantee its availability?

You think instead of using “pyrevit clone” etc. you could use “C:\Program Files\pyRevit CLI\bin\pyrevit.exe clone” or do I misunderstand?

I’ve also run into this problem recently. We were previously deploying with the CLI version 4.8.8, which was working fine with everything in one ps1 script, but once we updated to a newer version of the executable it appears to silently fail on certain machines. Running two separate scripts seems like the best solution for now, but would be curious to know if anyone was able to get it working in one shot.

Interesting. Do you call the 2nd script from the end of the first or just run it seperatly?

I was running them separately, but even this isn’t working consistently across machines. If I arrive at a better solution I’ll let you know. When running pyrevit commands directly in Powershell it works fine, but not when running the ps1 files via a BAT file. (CLI version 4.8.8 still works fine)