-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-GooglePlayAppUpdateDate.ps1
62 lines (45 loc) · 2.08 KB
/
Get-GooglePlayAppUpdateDate.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
<#
.SYNOPSIS
Script is checking is new version of google play application is available.
.DESCRIPTION
Script is checking is new version of google play application is available.
.EXAMPLE
Get-AppUpdateDate "https://play.google.com/store/apps/details?id=com.whatsapp"
.NOTES
autor: hajdus 2018
#>
Function Get-AppUpdateDate {
Param(
[Parameter(Mandatory = $true)] [String]$url
)
$Response = Invoke-WebRequest $url
#Get app name from google play store
$AppName = $Response.AllElements | Where id -eq "main-title" | Select -First 1 -ExpandProperty innerText
$AppName = $AppName.Split()
$AppName = $AppName[0]
#Get app update date form google play store
$UpdateDate = $Response.AllElements | Where Class -eq "htlgb" | Select -First 1 -ExpandProperty innerText
#Copy previous new data to old.txt file
Copy-Item -Path "$AppName new.txt" -Destination "$AppName old.txt"
#Save present data to new.txt file
$UpdateDate | Out-File -FilePath "$AppName new.txt"
#Compare old and new data from txt files
If ( Compare-Object -ReferenceObject $(Get-Content "$AppName old.txt") -DifferenceObject $(Get-Content "$AppName new.txt"))
{
#Find app update and sand email
$MyEmail = "[email protected]"
$Password = 'PASSWORD'
$SMTP = "smtp.gmail.com"
$To = "[email protected]"
$Subject = "$AppName new update"
$Body = "$AppName has been updated! Last version is from $UpdateDate. Available at the $url"
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Creds = New-Object "System.Management.Automation.PSCredential" -ArgumentList $MyEmail, $SecurePassword
Send-MailMessage -To $To -From $MyEmail -Subject $Subject -Body $Body -SmtpServer $SMTP -Credential $Creds -UseSsl -Port 587 -DeliveryNotificationOption never
}
#No app update
Else {}
}
#Calling function
Get-AppUpdateDate "https://play.google.com/store/apps/details?id=com.whatsapp"
Get-AppUpdateDate "https://play.google.com/store/apps/details?id=com.yammer.v1&hl=pl"