-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv1_volume_mute.ps1
62 lines (49 loc) · 1.28 KB
/
tv1_volume_mute.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<#
SonyTVRemote
Version 0.2
Description: Remote Control Sony TV with the powershell scripts.
Pavel Satin (c) 2016
#>
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2
$returnStateUnknown = 3
if ( Test-Path "tvip.cfg" ) {
$tv_ip = Get-Content "tvip.cfg"
} else {
$returnState = $returnStateCritical
# [System.Environment]::Exit($returnState)
Write-Host $returnState
Break
}
if ( Test-Path "auth_cookie" ) {
} else {
$returnState = $returnStateWarning
Write-Host "Файл с куками не найден! Работа скрипта завершена."
# [System.Environment]::Exit($returnState)
Write-Host $returnState
Break
}
$url = "http://${tv_ip}/sony/audio"
#$status = "true"
$status = $args[0]
$cookie_auth = Get-Content "auth_cookie"
$data = @"
{
"id" : 10,
"version" : "1.0",
"method" : "setAudioMute",
"params" : [{
"status" : ${status}
}]
}
"@
#Готовим куки
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$cookie = New-Object System.Net.Cookie
$cookie.Name = "auth"
$cookie.Value = $cookie_auth.Split("=")[1]
$cookie.Domain = $tv_ip
$session.Cookies.Add($cookie);
$Request = Invoke-WebRequest -Method Post -Uri $url -Body $data -WebSession $session