-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConvertTo-SoftwareIdentity.ps1
More file actions
40 lines (37 loc) · 1014 Bytes
/
Copy pathConvertTo-SoftwareIdentity.ps1
File metadata and controls
40 lines (37 loc) · 1014 Bytes
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
# Convert the objects returned from Microsoft.WinGet.Client into Software Identities (SWIDs).
function ConvertTo-SoftwareIdentity {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline)]
[object[]]
$InputObject,
[Parameter()]
[string]
$Source
)
process {
Write-Debug ($LocalizedData.ProviderDebugMessage -f ('ConvertTo-SoftwareIdentity'))
foreach ($package in $InputObject) {
# Return a new SWID based on the output from Microsoft.WinGet.Client
$packageSource = $(
if ($package.source) {
$package.source
} elseif ($Source) {
$Source
}
)
if ($packageSource) {
Write-Debug "Package identified: $($package.ID), $($package.version), $($packageSource)"
$swid = @{
FastPackageReference = $package.ID+"#"+ $package.version+"#"+$packageSource
Name = $package.ID
Version = $package.version
versionScheme = "MultiPartNumeric"
FromTrustedSource = $true
Source = $packageSource
}
New-SoftwareIdentity @swid
}
}
}
}