I have a - what I thought would be simple - script… but cannot figure out what I am doing wrong. It is a command line run of TeamViewer to change some account parameters…
If I run the same command in a CMD window as Administrator it works as expected.
Here is my PowerShell script:
$working_directory = "C:\Program Files (x86)\TeamViewer"
$application = "TeamViewer.exe"
$ea_string = "--grant_easy_access"
$SiteInitials = "AAA"
$teamviwer_api_token = "12345-12342-12312323"
# it appears that the order of the parameters makes a huge difference. Be careful.
#TeamViewer.exe assign --api-token aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --group AAA --alias "AAA-TEST" --grant-easy-access --reassign
Clear-Host
$command_string = "assign --api-token $teamviwer_api_token --group $SiteInitials --alias ""$ComputerName"" $ea_string --reassign"
Write-Output "Working directory is $working_directory"
Write-Output "Application name is $application"
Write-Output "Command Arguments = $command_string"
#attempt number one
Start-Process -FilePath $application -WorkingDirectory $working_directory -ArgumentList $command_string
# if I add the following to the Start-Process line above I get an error...
#-RedirectStandardOutput "E:\sout.txt"
#attempt number two
$CMD = "$working_directory\$application"
$arg1 = 'assign'
$arg2 = "--api-token $teamviwer_api_token"
$arg3 = "--group $SiteInitials"
$arg4 = "--alias ""$ComputerName"""
$arg5 = "$ea_string --reassign"
& $CMD $arg1 $arg2 $arg3 $arg4 $arg5
It does not help that there is no output from TeamViewer when you run this but it seems like it is not running.