-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGet-WEMActionGroup.ps1
65 lines (54 loc) · 1.87 KB
/
Get-WEMActionGroup.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
<#
.Synopsis
Returns one or more Action Group objects from the WEM Database.
.Description
Returns one or more Action Group objects from the WEM Database.
.Link
https://msfreaks.wordpress.com
.Parameter IdSite
..
.Parameter IdActionGroup
..
.Parameter Name
..
.Parameter Connection
..
.Example
.Notes
Author: Arjan Mensch
#>
function Get-WEMActionGroup {
[CmdletBinding()]
param (
[Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)]
[int]$IdSite,
[Parameter(Mandatory=$False, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)]
[int]$IdActionGroup,
[Parameter(Mandatory=$False, ValueFromPipeline=$True)]
[string]$Name,
[Parameter(Mandatory=$True)]
[System.Data.SqlClient.SqlConnection]$Connection
)
process {
Write-Verbose "Working with database version $($script:databaseVersion)"
# build query
$SQLQuery = "SELECT * FROM VUEMActionGroups"
if ($IdSite -or $Name -or $IdActionGroup) {
$SQLQuery += " WHERE "
if ($IdSite) {
$SQLQuery += "IdSite = $($IdSite)"
if ($Name -or $IdActionGroup) { $SQLQuery += " AND " }
}
if ($IdActionGroup) {
$SQLQuery += "IdActionGroup = $($IdActionGroup)"
if ($Name) { $SQLQuery += " AND " }
}
if ($Name) { $SQLQuery += "Name LIKE '$($Name.Replace("*","%"))'"}
}
$result = Invoke-SQL -Connection $Connection -Query $SQLQuery
# build array of VUEMActionGroups returned by the query
$vuemObjects = @()
foreach ($row in $result.Tables.Rows) { $vuemObjects += New-VUEMActionGroupObject -DataRow $row -Connection $Connection }
return $vuemObjects
}
}