-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathGet-PPApp.ps1
106 lines (75 loc) · 2.6 KB
/
Get-PPApp.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
<#
$Metadata = @{
Title = "Get PowerShell PowerUp App"
Filename = "Get-PPApp.ps1"
Description = ""
Tags = "powershell, profile, get, apps"
Project = ""
Author = "Janik von Rotz"
AuthorContact = "http://janikvonrotz.ch"
CreateDate = "2013-10-25"
LastEditDate = "20114-04-07"
Url = ""
Version = "1.1.0"
License = @'
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Switzerland License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ch/ or
send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
'@
}
#>
function Get-PPApp{
<#
.SYNOPSIS
Get available PowerShell PowerUp apps.
.DESCRIPTION
Get available PowerShell PowerUp apps.
.PARAMETER Name
Name of an app.
.PARAMETER Installed
Only show globally installed apps.
.PARAMETER CurrentInstalled
Only show apps that are installed in the current path.
.EXAMPLE
PS C:\> Get-PPApp
#>
param(
[Parameter(Mandatory=$false)]
[String]
$Name,
[switch]
$Installed,
[switch]
$CurrentInstalled
)
# set default variables
$CurrentLocation = (Get-Location).Path
# get package manager configuations
# config for current folder
$CurrentAppDataFile = Join-Path $CurrentLocation $PSconfigs.App.DataFile
# global config
$GlobalAppDataFile = (Get-ChildItem -Path $PSconfigs.Path -Filter $PSconfigs.App.DataFile -Recurse).Fullname
# get global configurations
$InstalledApps = Get-PPConfiguration -Path $GlobalAppDataFile | %{$_.Content.App}
# get apps installed in current folder
if(Test-Path $CurrentAppDataFile){
$CurrentInstalledApps = Get-PPConfiguration -Path $CurrentAppDataFile | ForEach-Object{$_.Content.App}
}
$(if($Name){
Get-PPConfiguration -Filter $PSconfigs.App.Filter -Path $PSlib.Path | %{$_.Content.App | where{$_.Name -match $Name}}
}else{
Get-PPConfiguration $PSconfigs.App.Filter -Path $PSlib.Path | %{$_.Content.App}
}) | %{
if($Installed){
$Name = $_.Name
$Version = $_.Version
$InstalledApps | where{($_.Name -eq $Name) -and ($_.Version -eq $Version)}
}elseif($CurrentInstalled){
$Name = $_.Name
$Version = $_.Version
$CurrentInstalledApps | where{($_.Name -eq $Name) -and ($_.Version -eq $Version)}
}else{
$_
}
}
}