How to launch teams.exe with powershell

Viewed 1458

I've been trying to launch teams using powershell, i've succeeded launching teams using the destination path under the shortcut property, and then running it in powershell.

C:\Users\user1\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe"

But this only works for the local user, if i run the script with another user teams won't launch. i've storing the user in a variable.

$user = $env:UserName 

C:\Users\$user\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe"

This doesn't work. So my question how can I launch teams.exe (make it visible)? I want to make it like how you can launch word with start winword.exe

2 Answers

You should get the variable for the App Data folder, not just the username. Otherwise, it won't work in situations where the user's profile folder is in a different location:

$user = "$($env:LOCALAPPDATA)\Microsoft\Teams\Update.exe --processStart `"Teams.exe`""

This can be fixed by using the following format instead:

$user = $env:UserName
'C:\Users\'+$user+'\AppData\Local\Microsoft\Teams\Update.exe --processStart "Teams.exe"'
Related