I have a script that works on other PCs. It only on one PC I have following error message.
Error: Fehler beim Aufrufen der Methode, da [System.Object[]] keine Methode mit dem Namen "op_Addition" enthält. 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
Thats the script:
#$ErrorActionPreference = 'SilentlyContinue'
$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"
}
Does somebody has any idea? Thanks so much :-)
I thought it was due to the permission to run scripts in Powershell. But I allowed the execution of scripts (Unrestricted)