Skip to content

Commit 00306a2

Browse files
authored
Merge branch 'master' into bugfix-requestItemName
2 parents b530d16 + 25c3daa commit 00306a2

13 files changed

+237
-64
lines changed

Build/build.ps1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ Warren F. (RamblingCookieMonster)
66
#>
77

88
[cmdletbinding()]
9-
param ($Task = 'Default')
9+
param (
10+
$Task = 'Default',
11+
12+
[ValidateSet('Build','Minor','Major')]
13+
$StepVersionBy = 'Build'
14+
)
1015

1116
# Grab nuget bits, install modules, set build variables, start build.
1217
Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
@@ -26,5 +31,12 @@ ForEach ($Module in $Modules) {
2631
$Path = (Resolve-Path $PSScriptRoot\..).Path
2732
Set-BuildEnvironment -Path $Path
2833

29-
Invoke-psake -buildFile $PSScriptRoot\psake.ps1 -taskList $Task -nologo
30-
exit ([int](-not $psake.build_success))
34+
$invokepsakeSplat = @{
35+
buildFile = "$PSScriptRoot\psake.ps1"
36+
taskList = $Task
37+
properties = @{'StepVersionBy' = $StepVersionBy}
38+
nologo = $true
39+
}
40+
Invoke-psake @invokepsakeSplat
41+
42+
exit ([int](-not $psake.build_success))

Build/psake.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# PSake makes variables declared here available in other scriptblocks
22
Properties {
33
# Find the build folder based on build system
4-
$ProjectRoot = Resolve-Path $ENV:BHProjectPath
5-
if(-not $ProjectRoot)
6-
{
7-
$ProjectRoot = Resolve-Path "$PSScriptRoot\.."
8-
}
4+
$ProjectRoot = Resolve-Path $ENV:BHProjectPath
5+
if(-not $ProjectRoot)
6+
{
7+
$ProjectRoot = Resolve-Path "$PSScriptRoot\.."
8+
}
9+
10+
#
11+
$StepVersionBy = 'Build'
912

1013
$Timestamp = Get-date -uformat "%Y%m%d-%H%M%S"
1114
$PSVersion = $PSVersionTable.PSVersion.Major
@@ -91,7 +94,7 @@ Task Build -Depends Test {
9194
Set-ModuleFunctions -Name $env:BHPSModuleManifest -FunctionsToExport $functions
9295

9396
# Bump the module version
94-
$version = [version] (Step-Version (Get-Metadata -Path $env:BHPSModuleManifest))
97+
$version = [version] (Step-Version -Version (Get-Metadata -Path $env:BHPSModuleManifest) -By $StepVersionBy)
9598
$galleryVersion = Get-NextPSGalleryVersion -Name $env:BHProjectName
9699
if($version -lt $galleryVersion)
97100
{

ServiceNow/Public/Get-ServiceNowChangeRequest.ps1

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function Get-ServiceNowChangeRequest {
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[Parameter(Mandatory = $false)]
20+
[Alias('Fields')]
21+
[string[]]$Properties,
22+
1823
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1924
[Parameter(Mandatory = $false)]
2025
[hashtable]$MatchExact = @{},
@@ -54,25 +59,26 @@ function Get-ServiceNowChangeRequest {
5459

5560
# Table Splat
5661
$getServiceNowTableSplat = @{
57-
Table = 'change_request'
58-
Query = $Query
59-
Limit = $Limit
60-
DisplayValues = $DisplayValues
62+
Table = 'change_request'
63+
Query = $Query
64+
Limit = $Limit
65+
Fields = $Properties
66+
DisplayValues = $DisplayValues
6167
}
6268

6369
# Update the Table Splat if the parameters have values
64-
if ($null -ne $PSBoundParameters.Connection)
65-
{
70+
if ($null -ne $PSBoundParameters.Connection) {
6671
$getServiceNowTableSplat.Add('Connection',$Connection)
6772
}
68-
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL)
69-
{
73+
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
7074
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
7175
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
7276
}
7377

7478
# Perform query and return each object in the format.ps1xml format
7579
$Result = Get-ServiceNowTable @getServiceNowTableSplat
76-
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.ChangeRequest")}
80+
If (-not $Properties) {
81+
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.ChangeRequest")}
82+
}
7783
$Result
7884
}

ServiceNow/Public/Get-ServiceNowConfigurationItem.ps1

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function Get-ServiceNowConfigurationItem {
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[Parameter(Mandatory = $false)]
20+
[Alias('Fields')]
21+
[string[]]$Properties,
22+
1823
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1924
[Parameter(Mandatory = $false)]
2025
[hashtable]$MatchExact = @{},
@@ -54,25 +59,26 @@ function Get-ServiceNowConfigurationItem {
5459

5560
# Table Splat
5661
$getServiceNowTableSplat = @{
57-
Table = 'cmdb_ci'
58-
Query = $Query
59-
Limit = $Limit
60-
DisplayValues = $DisplayValues
62+
Table = 'cmdb_ci'
63+
Query = $Query
64+
Limit = $Limit
65+
Fields = $Properties
66+
DisplayValues = $DisplayValues
6167
}
6268

6369
# Update the Table Splat if the parameters have values
64-
if ($null -ne $PSBoundParameters.Connection)
65-
{
70+
if ($null -ne $PSBoundParameters.Connection) {
6671
$getServiceNowTableSplat.Add('Connection',$Connection)
6772
}
68-
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL)
69-
{
73+
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
7074
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
7175
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
7276
}
7377

7478
# Perform query and return each object in the format.ps1xml format
7579
$Result = Get-ServiceNowTable @getServiceNowTableSplat
76-
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.ConfigurationItem")}
80+
If (-not $Properties) {
81+
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.ConfigurationItem")}
82+
}
7783
$Result
7884
}

ServiceNow/Public/Get-ServiceNowIncident.ps1

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function Get-ServiceNowIncident{
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[Parameter(Mandatory = $false)]
20+
[Alias('Fields')]
21+
[string[]]$Properties,
22+
1823
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1924
[Parameter(Mandatory = $false)]
2025
[hashtable]$MatchExact = @{},
@@ -54,25 +59,26 @@ function Get-ServiceNowIncident{
5459

5560
# Table Splat
5661
$getServiceNowTableSplat = @{
57-
Table = 'incident'
58-
Query = $Query
59-
Limit = $Limit
62+
Table = 'incident'
63+
Query = $Query
64+
Limit = $Limit
65+
Fields = $Properties
6066
DisplayValues = $DisplayValues
6167
}
6268

6369
# Update the splat if the parameters have values
64-
if ($null -ne $PSBoundParameters.Connection)
65-
{
70+
if ($null -ne $PSBoundParameters.Connection) {
6671
$getServiceNowTableSplat.Add('Connection',$Connection)
6772
}
68-
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL)
69-
{
73+
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
7074
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
7175
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
7276
}
7377

7478
# Perform query and return each object in the format.ps1xml format
7579
$Result = Get-ServiceNowTable @getServiceNowTableSplat
76-
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.Incident")}
80+
If (-not $Properties) {
81+
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.Incident")}
82+
}
7783
$Result
7884
}

ServiceNow/Public/Get-ServiceNowRequest.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function Get-ServiceNowRequest {
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[Parameter(Mandatory = $false)]
20+
[Alias('Fields')]
21+
[string[]]$Properties,
22+
1823
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1924
[Parameter(Mandatory = $false)]
2025
[hashtable]$MatchExact = @{},
@@ -57,6 +62,7 @@ function Get-ServiceNowRequest {
5762
Table = 'sc_request'
5863
Query = $Query
5964
Limit = $Limit
65+
Fields = $Properties
6066
DisplayValues = $DisplayValues
6167
}
6268

@@ -71,6 +77,8 @@ function Get-ServiceNowRequest {
7177

7278
# Perform query and return each object in the format.ps1xml format
7379
$Result = Get-ServiceNowTable @getServiceNowTableSplat
74-
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0, "ServiceNow.Request")}
80+
If (-not $Properties) {
81+
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0, "ServiceNow.Request")}
82+
}
7583
$Result
7684
}

ServiceNow/Public/Get-ServiceNowRequestItem.ps1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ function Get-ServiceNowRequestItem {
3131
[parameter(Mandatory = $false)]
3232
[int]$Limit = 10,
3333

34+
# Fields to return
35+
[Parameter(Mandatory = $false)]
36+
[Alias('Fields')]
37+
[string[]]$Properties,
38+
3439
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
3540
[parameter(Mandatory = $false)]
3641
[hashtable]$MatchExact = @{},
@@ -72,6 +77,7 @@ function Get-ServiceNowRequestItem {
7277
Table = 'sc_req_item'
7378
Query = $Query
7479
Limit = $Limit
80+
Fields = $Properties
7581
DisplayValues = $DisplayValues
7682
}
7783

@@ -86,6 +92,8 @@ function Get-ServiceNowRequestItem {
8692

8793
# Perform query and return each object in the format.ps1xml format
8894
$Result = Get-ServiceNowTable @getServiceNowTableSplat
89-
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0,'ServiceNow.RequestItem')}
95+
If (-not $Properties) {
96+
$Result | ForEach-Object {$_.PSObject.TypeNames.Insert(0,'ServiceNow.RequestItem')}
97+
}
9098
$Result
9199
}

ServiceNow/Public/Get-ServiceNowTable.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function Get-ServiceNowTable {
2929
[Parameter(Mandatory = $false)]
3030
[int]$Limit = 10,
3131

32+
# Fields to return
33+
[Parameter(Mandatory = $false)]
34+
[Alias('Fields')]
35+
[string[]]$Properties,
36+
3237
# Whether or not to show human readable display values instead of machine values
3338
[Parameter(Mandatory = $false)]
3439
[ValidateSet('true', 'false', 'all')]
@@ -73,6 +78,10 @@ function Get-ServiceNowTable {
7378
$Body.sysparm_query = $Query
7479
}
7580

81+
if ($Properties) {
82+
$Body.sysparm_fields = ($Properties -join ',').ToLower()
83+
}
84+
7685
# Perform table query and capture results
7786
$Uri = $ServiceNowURL + "/table/$Table"
7887
$Result = (Invoke-RestMethod -Uri $Uri -Credential $ServiceNowCredential -Body $Body -ContentType "application/json").Result

ServiceNow/Public/Get-ServiceNowTableEntry.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ function Get-ServiceNowTableEntry {
3838
[parameter(Mandatory = $false)]
3939
[int]$Limit = 10,
4040

41+
# Fields to return
42+
[Parameter(Mandatory = $false)]
43+
[Alias('Fields')]
44+
[string[]]$Properties,
45+
4146
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
4247
[parameter(Mandatory = $false)]
4348
[hashtable]$MatchExact = @{},
@@ -82,6 +87,7 @@ function Get-ServiceNowTableEntry {
8287
Table = $Table
8388
Query = $Query
8489
Limit = $Limit
90+
Fields = $Properties
8591
DisplayValues = $DisplayValues
8692
ErrorAction = 'Stop'
8793
}

ServiceNow/Public/Get-ServiceNowUser.ps1

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function Get-ServiceNowUser{
1515
[Parameter(Mandatory = $false)]
1616
[int]$Limit = 10,
1717

18+
# Fields to return
19+
[Parameter(Mandatory = $false)]
20+
[Alias('Fields')]
21+
[string[]]$Properties,
22+
1823
# Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
1924
[Parameter(Mandatory = $false)]
2025
[hashtable]$MatchExact = @{},
@@ -45,34 +50,35 @@ function Get-ServiceNowUser{
4550

4651
# Query Splat
4752
$newServiceNowQuerySplat = @{
48-
OrderBy = $OrderBy
53+
OrderBy = $OrderBy
4954
OrderDirection = $OrderDirection
50-
MatchExact = $MatchExact
51-
MatchContains = $MatchContains
55+
MatchExact = $MatchExact
56+
MatchContains = $MatchContains
5257
}
5358
$Query = New-ServiceNowQuery @newServiceNowQuerySplat
5459

5560
# Table Splat
5661
$getServiceNowTableSplat = @{
57-
Table = 'sys_user'
58-
Query = $Query
59-
Limit = $Limit
62+
Table = 'sys_user'
63+
Query = $Query
64+
Limit = $Limit
65+
Fields = $Properties
6066
DisplayValues = $DisplayValues
6167
}
6268

6369
# Update the splat if the parameters have values
64-
if ($null -ne $PSBoundParameters.Connection)
65-
{
70+
if ($null -ne $PSBoundParameters.Connection) {
6671
$getServiceNowTableSplat.Add('Connection',$Connection)
6772
}
68-
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL)
69-
{
70-
$getServiceNowTableSplat.Add('ServiceNowCredential',$ServiceNowCredential)
71-
$getServiceNowTableSplat.Add('ServiceNowURL',$ServiceNowURL)
73+
elseif ($null -ne $PSBoundParameters.ServiceNowCredential -and $null -ne $PSBoundParameters.ServiceNowURL) {
74+
$getServiceNowTableSplat.Add('ServiceNowCredential', $ServiceNowCredential)
75+
$getServiceNowTableSplat.Add('ServiceNowURL', $ServiceNowURL)
7276
}
7377

7478
# Perform query and return each object in the format.ps1xml format
7579
$Result = Get-ServiceNowTable @getServiceNowTableSplat
76-
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.UserAndUserGroup")}
80+
If (-not $Properties) {
81+
$Result | ForEach-Object{$_.PSObject.TypeNames.Insert(0,"ServiceNow.UserAndUserGroup")}
82+
}
7783
$Result
7884
}

0 commit comments

Comments
 (0)