Skip to content

Commit 7bc58ae

Browse files
authored
Merge pull request #3 from snazy2000/develop
Merge develop to main
2 parents 51a49cb + 57512d5 commit 7bc58ae

21 files changed

+716
-33
lines changed

.gitlab-ci.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
1-
variables:
2-
GIT_SSL_NO_VERIFY: "true"
3-
4-
before_script:
5-
- Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
6-
- Install-Module InvokeBuild, BuildHelpers, PSScriptAnalyzer -force -Scope CurrentUser
7-
- Install-Module Pester -Force -SkipPublisherCheck -Scope CurrentUser
8-
- Import-Module PSScriptAnalyzer -Scope CurrentUser
9-
101
stages:
112
- test
12-
# - release
13-
14-
ps_scriptanalyzer:
3+
- release
4+
variables:
5+
GIT_SSL_NO_VERIFY: "true"
6+
ErrorActionPreference: STOP
7+
Test:
158
stage: test
16-
script:
17-
- $res = (Invoke-ScriptAnalyzer -Path . -Severity Error).count
18-
- if ($res -gt 0) { throw "$($res) Analytics failed."}
19-
tags:
20-
- powershell
21-
22-
# except:
23-
# - master
24-
#Release:
25-
# stage: release
26-
# script:
27-
# - .\build.ps1 -Tasks 'analyze','test','release'
28-
# only:
29-
# - master
9+
script:
10+
- .\build.ps1 -Tasks 'test'
11+
except:
12+
- master
13+
Release:
14+
stage: release
15+
script:
16+
- .\build.ps1 -Tasks 'test','release'
17+
only:
18+
- master

SnipeItPS.build.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ task InstallPandoc -If (-not (Test-Path Tools\pandoc.exe)) {
5656

5757
# Get latest bits
5858
$latestRelease = "https://github.com/jgm/pandoc/releases/download/1.19.2.1/pandoc-1.19.2.1-windows.msi"
59+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
5960
Invoke-WebRequest -Uri $latestRelease -OutFile "$($env:temp)\pandoc.msi"
6061

6162
# Extract bits

SnipeitPS/Private/Invoke-SnipeitMethod.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
$result
107107
}
108108
}
109+
elseif ($webResponse.StatusCode -eq "Unauthorized") {
110+
Write-Error "[$($MyInvocation.MyCommand.Name)] You are not Authorized to access the resource, check your token is correct"
111+
}
109112
else {
110113
# No content, although statusCode < 400
111114
# This could be wanted behavior of the API

SnipeitPS/Public/Get-Asset.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ function Get-Asset()
2929
$Parameters = @{
3030
Uri = "$url/api/v1/hardware"
3131
Method = 'Get'
32+
GetParameters = @{
33+
limit = 9999
34+
}
3235
Token = $apiKey
3336
}
3437

SnipeitPS/Public/Get-Company.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<#
2+
.SYNOPSIS
3+
# Gets a list of Snipe-it Companies
4+
5+
.PARAMETER url
6+
URL of Snipeit system, can be set using Set-Info command
7+
8+
.PARAMETER apiKey
9+
Users API Key for Snipeit, can be set using Set-Info command
10+
11+
.EXAMPLE
12+
Get-Company -url "https://assets.example.com" -token "token..."
13+
14+
.EXAMPLE
15+
Get-Company -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Company1" }
16+
17+
#>
18+
19+
function Get-Company()
20+
{
21+
Param(
22+
[parameter(mandatory=$true)]
23+
[string]$url,
24+
25+
[parameter(mandatory=$true)]
26+
[string]$apiKey
27+
)
28+
29+
$Parameters = @{
30+
Uri = "$url/api/v1/companies"
31+
Method = 'Get'
32+
Token = $apiKey
33+
}
34+
35+
$result = Invoke-SnipeitMethod @Parameters
36+
37+
$result
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<#
2+
.SYNOPSIS
3+
# Gets a list of Snipe-it Departments
4+
5+
.PARAMETER url
6+
URL of Snipeit system, can be set using Set-Info command
7+
8+
.PARAMETER apiKey
9+
Users API Key for Snipeit, can be set using Set-Info command
10+
11+
.EXAMPLE
12+
Get-Department -url "https://assets.example.com" -token "token..."
13+
14+
.EXAMPLE
15+
Get-Department -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Department1" }
16+
17+
#>
18+
19+
function Get-Department()
20+
{
21+
Param(
22+
[parameter(mandatory=$true)]
23+
[string]$url,
24+
25+
[parameter(mandatory=$true)]
26+
[string]$apiKey
27+
)
28+
29+
$Parameters = @{
30+
Uri = "$url/api/v1/departments"
31+
Method = 'Get'
32+
Token = $apiKey
33+
}
34+
35+
$result = Invoke-SnipeitMethod @Parameters
36+
37+
$result
38+
}
39+

SnipeitPS/Public/Get-Location.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<#
2+
.SYNOPSIS
3+
# Gets a list of Snipe-it Locations
4+
5+
.PARAMETER url
6+
URL of Snipeit system, can be set using Set-Info command
7+
8+
.PARAMETER apiKey
9+
Users API Key for Snipeit, can be set using Set-Info command
10+
11+
.EXAMPLE
12+
Get-Location -url "https://assets.example.com" -token "token..."
13+
14+
.EXAMPLE
15+
Get-Location -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Location1" }
16+
17+
#>
18+
19+
function Get-Location()
20+
{
21+
Param(
22+
[parameter(mandatory=$true)]
23+
[string]$url,
24+
25+
[parameter(mandatory=$true)]
26+
[string]$apiKey
27+
)
28+
29+
$Parameters = @{
30+
Uri = "$url/api/v1/locations"
31+
Method = 'Get'
32+
Token = $apiKey
33+
}
34+
35+
$result = Invoke-SnipeitMethod @Parameters
36+
37+
$result
38+
}
39+

SnipeitPS/Public/Get-Supplier.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<#
2+
.SYNOPSIS
3+
# Gets a list of Snipe-it Suppliers
4+
5+
.PARAMETER url
6+
URL of Snipeit system, can be set using Set-Info command
7+
8+
.PARAMETER apiKey
9+
Users API Key for Snipeit, can be set using Set-Info command
10+
11+
.EXAMPLE
12+
Get-Supplier -url "https://assets.example.com" -token "token..."
13+
14+
.EXAMPLE
15+
Get-Supplier -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "MySupplier" }
16+
17+
#>
18+
19+
function Get-Supplier()
20+
{
21+
Param(
22+
[parameter(mandatory=$true)]
23+
[string]$url,
24+
25+
[parameter(mandatory=$true)]
26+
[string]$apiKey
27+
)
28+
29+
$Parameters = @{
30+
Uri = "$url/api/v1/suppliers"
31+
Method = 'Get'
32+
Token = $apiKey
33+
}
34+
35+
$result = Invoke-SnipeitMethod @Parameters
36+
37+
$result
38+
}
39+

SnipeitPS/Public/New-Asset.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function New-Asset()
3737
{
3838
[CmdletBinding(
3939
SupportsShouldProcess = $true,
40-
ConfirmImpact = "High"
40+
ConfirmImpact = "Low"
4141
)]
4242

4343
Param(

SnipeitPS/Public/New-Component.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function New-Component()
3131
{
3232
[CmdletBinding(
3333
SupportsShouldProcess = $true,
34-
ConfirmImpact = "High"
34+
ConfirmImpact = "Low"
3535
)]
3636

3737
Param(

0 commit comments

Comments
 (0)