forked from farag2/Utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearch_UWP_Package_in_Store.ps1
115 lines (97 loc) · 2.63 KB
/
Search_UWP_Package_in_Store.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#Requires -Version 7.1
<#
.SYNOPSIS
Search Microsoft Store from PowerShell
.PARAMETER Query
.EXAMPLE
Search-MSStore -Query "terminal"
.NOTES
Originally coded by antidisestablishmentarianism
https://dev.to/antidisestablishmentarianism/search-microsoft-store-from-powershell-2bjj
#>
function Search-MSStore
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]
$Query
)
$Base = "https://storeedgefd.dsx.mp.microsoft.com/v8.0/search?"
$Parameters = [PSCustomObject]@{
market = (Get-UICulture).Parent.Name
locale = $PSCulture
catalogLocales = $PSCulture
query = $Query
mediaType = "apps"
category = "all"
moId = "Public"
oemId = "LENOVO"
scmId = "Lenovo3_Idea"
deviceFamily = "windows.desktop"
appVersion = "12006.1001.0.0"
availableOn = "windows.desktop"
maturityRating = "all"
cardsEnabled = "true"
pzn = "0"
pageSize = "25"
skipItems = "0"
}
[string]$Parameters = (-join ($Parameters.psobject.Properties.Name | ForEach-Object -Process {$_ + "=" + $Parameters.$_ + "&"})).TrimEnd("&")
$URL = @{
Name = "URL"
Expression = {"https://www.microsoft.com/store/productId/" + $_.ProductId}
}
((Invoke-WebRequest -UseBasicParsing -Uri ($Base + $Parameters)).Content | ConvertFrom-Json).Payload.Cards | Select-Object -Property Title, Price, ProductId, $URL
}
###
# Another version without [PSCustomObject]
###
#Requires -Version 7.1
<#
.SYNOPSIS
Search Microsoft Store from PowerShell
.PARAMETER Query
.EXAMPLE
Search-MSStore -Query "terminal"
.NOTES
Originally coded by antidisestablishmentarianism
https://dev.to/antidisestablishmentarianism/search-microsoft-store-from-powershell-2bjj
#>
function Search-MSStore
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[string]
$Query
)
$Base = "https://storeedgefd.dsx.mp.microsoft.com/v8.0/search?"
$Parameters = @{
market = (Get-UICulture).Parent.Name
locale = $PSCulture
catalogLocales = $PSCulture
query = $Query
mediaType = "apps"
category = "all"
moId = "Public"
oemId = "LENOVO"
scmId = "Lenovo3_Idea"
deviceFamily = "windows.desktop"
appVersion = "12006.1001.0.0"
availableOn = "windows.desktop"
maturityRating = "all"
cardsEnabled = "true"
pzn = "0"
pageSize = "25"
skipItems = "0"
}
[string]$Parameters = (-join ($Parameters.Keys | ForEach-Object -Process {$_ + "=" + $Parameters.$_ + "&"})).TrimEnd("&")
$URL = @{
Name = "URL"
Expression = {"https://www.microsoft.com/store/productId/" + $_.ProductId}
}
((Invoke-WebRequest -UseBasicParsing -Uri ($Base + $Parameters)).Content | ConvertFrom-Json -AsHashtable).Payload.Cards | Select-Object -Property Title, Price, ProductId, $URL
}