Error in upload monitoring script

dreamer84

New Member
I need help with a script that monitors the upload.
The script is intended to prevent crashes of OBS, where OBS simply stops sending data. I have already run this script on several streaming PCs - without problems. But on a new streaming PC it just won't run.

Here is the script for now:
Code:
$threshold = 6000
$timer = new-timespan -Seconds 10
$wmi = 0
$count = 0
$clock = [diagnostics.stopwatch]::StartNew()
while ($clock.elapsed -lt $timer){
    $wmi += (Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_NetworkInterface | Select-Object BytesSentPerSec).BytesSentPerSec
    $count++
}

$kbytes = ($wmi/$count)  / 1kb * 8 #to kbit/s


if($kbytes -le $threshold)
{
    Write-Output $kbytes
    Write-Host "Neustart"
    taskkill /f /im obs64.exe
    timeout /t 5
    Start-Process -FilePath "obs64.exe" -WorkingDirectory "C:\Program Files\obs-studio\bin\64bit\" --startstreaming --minimize-to-tray
}
else  
{
    Write-Output $kbytes
    Write-Host "Alles OK"
}

As an error I get this:

Code:
Error when calling the method. [System.Object[]] no method with the name "op_Addition".
In C:\Users\stream1\Desktop\watchdog.ps1:8 Zeichen:5
+     $wmi += (Get-WMIObject -Class Win32_PerfFormattedData_Tcpip_Netwo ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

I hope someone can help me.
Thanks a lot

Greeting
Thomas
 

sandrix

Member
You definitely need to post this in another section.

You can also ask for help in the Discord OBS. Usually it is almost impossible to get an answer to such topics here.
 

dreamer84

New Member
You definitely need to post this in another section.

You can also ask for help in the Discord OBS. Usually it is almost impossible to get an answer to such topics here.
Thank you for your reply. Unfortunately I can't make a post in "Scripts". I do not know why.
And on Discord, unfortunately, there is no area for scripts.
 

sandrix

Member
Thank you for your reply. Unfortunately I can't make a post in "Scripts". I do not know why.
And on Discord, unfortunately, there is no area for scripts.
 
Top