powershell external script
powershell external script
Hi Guys,
I need some help, I'm running an external powershell script to run a command -
in osa i have this -
Write-Output "IN SWITCH OUTSIDE SOEAKERS"
cd c:\Users\Andy\Documents
Set-ExecutionPolicy Unrestricted
.\outsidespeakers.ps1
and in outside speakers.ps1
i have this -
Write-Output "IN SWITCH OUTSIDE SOEAKERS"
cd c:\Users\Amit\Documents\SoundSwitch\bin
Write-Output "TEST1"
$program = ".\SetDefaultAudioEndpoint.exe"
Write-Output "TEST2"
$test = Invoke-Command -ScriptBlock { & $program -pOutsideSpeakers }
Write-Output "TEST3"
Write-Output "TESTING $test"
The variable $test would provide some output i.e. switched audio to OutsideSpeakers but the $test variable is empty...
Running each line on the console works correctly, what am i missing.
I need some help, I'm running an external powershell script to run a command -
in osa i have this -
Write-Output "IN SWITCH OUTSIDE SOEAKERS"
cd c:\Users\Andy\Documents
Set-ExecutionPolicy Unrestricted
.\outsidespeakers.ps1
and in outside speakers.ps1
i have this -
Write-Output "IN SWITCH OUTSIDE SOEAKERS"
cd c:\Users\Amit\Documents\SoundSwitch\bin
Write-Output "TEST1"
$program = ".\SetDefaultAudioEndpoint.exe"
Write-Output "TEST2"
$test = Invoke-Command -ScriptBlock { & $program -pOutsideSpeakers }
Write-Output "TEST3"
Write-Output "TESTING $test"
The variable $test would provide some output i.e. switched audio to OutsideSpeakers but the $test variable is empty...
Running each line on the console works correctly, what am i missing.
Re: powershell external script
I've managed to get it to execute ...using od "Execute Command"
however the command switches the audio from one to another, and this takes about a second or two... how can i delay the script from outputting voice command before actuallyign setting the correct sound output.
however the command switches the audio from one to another, and this takes about a second or two... how can i delay the script from outputting voice command before actuallyign setting the correct sound output.
Re: powershell external script
hi,
Start-Sleep -Second 10 used this but it seems to pause the whole script.
i cant get to delay between external call and speech output.
any ideas.
Start-Sleep -Second 10 used this but it seems to pause the whole script.
i cant get to delay between external call and speech output.
any ideas.
Re: powershell external script
Can you post the script you tried?
Re: powershell external script
show-osa -name "SpeakingOutside"
invoke-osascript -name "SwitchSoundSpeakers" -nested "true"
invoke-osascript -name "uppervolume"
Start-Sleep -Second 10
$speak_var = get-osa -name "SpeakingOutside"
$speakValue = $speak_var.properties["SayText"].value
invoke-osa -name "Speech" -Method "Say" -parameter1 $speakValue
invoke-osascript -name "SwitchSoundSpeakers" -nested "true"
invoke-osascript -name "uppervolume"
Start-Sleep -Second 10
$speak_var = get-osa -name "SpeakingOutside"
$speakValue = $speak_var.properties["SayText"].value
invoke-osa -name "Speech" -Method "Say" -parameter1 $speakValue
Re: powershell external script
switchsoundspeaker script below
Write-Output "IN SWITCH OUTSIDE SOEAKER"
invoke-osa -name "SERVICE-Amit-PC" -Method "Execute Command" -parameter1 "c:\Users\Amit\Documents\SoundSwitch\bin\SetDefaultAudioEndpoint.exe" -parameter2 "-pOutsideSpeakers"
Write-Output "IN SWITCH OUTSIDE SOEAKER"
invoke-osa -name "SERVICE-Amit-PC" -Method "Execute Command" -parameter1 "c:\Users\Amit\Documents\SoundSwitch\bin\SetDefaultAudioEndpoint.exe" -parameter2 "-pOutsideSpeakers"
Re: powershell external script
"Speaker" is misspelled, just incase it is that easy =) Otherwise, I haven't used PS, so I can't help much.
Vaughn
Vaughn
Re: powershell external script
Nah that's jus output to log text. For some reason it's doing the external execution at the same time as running the rest of the script. Think it might be a bug in osa.
As way around this I got php to call one switch speaker script first and then the second script After 2 seconds. It's a bit hacky as sometimes it could take more than 2 secs.
As way around this I got php to call one switch speaker script first and then the second script After 2 seconds. It's a bit hacky as sometimes it could take more than 2 secs.