mirror of
https://github.com/snazy2000/SnipeitPS.git
synced 2025-12-13 18:02:30 +00:00
commit
7bfe2aa2e9
53 changed files with 3156 additions and 496 deletions
|
|
@ -1,30 +1,22 @@
|
|||
stages:
|
||||
- test
|
||||
- release
|
||||
|
||||
variables:
|
||||
GIT_SSL_NO_VERIFY: "true"
|
||||
ErrorActionPreference: STOP
|
||||
|
||||
before_script:
|
||||
- Get-PackageProvider -Name NuGet -ForceBootstrap | Out-Null
|
||||
- Install-Module InvokeBuild, BuildHelpers, PSScriptAnalyzer -force -AllowClobber
|
||||
- Install-Module Pester -Force -SkipPublisherCheck
|
||||
- Import-Module PSScriptAnalyzer
|
||||
|
||||
stages:
|
||||
- test
|
||||
# - release
|
||||
|
||||
ps_scriptanalyzer:
|
||||
Test:
|
||||
stage: test
|
||||
script:
|
||||
- $res = (Invoke-ScriptAnalyzer -Path . -Severity Error).count
|
||||
- if ($res -gt 0) { throw "$($res) Analytics failed."}
|
||||
tags:
|
||||
- powershell
|
||||
script:
|
||||
- .\build.ps1 -Tasks 'test'
|
||||
except:
|
||||
- master
|
||||
|
||||
Release:
|
||||
stage: release
|
||||
script:
|
||||
- .\build.ps1 -Tasks 'test','release'
|
||||
only:
|
||||
- master
|
||||
|
||||
# except:
|
||||
# - master
|
||||
#Release:
|
||||
# stage: release
|
||||
# script:
|
||||
# - .\build.ps1 -Tasks 'analyze','test','release'
|
||||
# only:
|
||||
# - master
|
||||
33
.vscode/launch.json
vendored
Normal file
33
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [{
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"name": "PowerShell Pester Tests",
|
||||
"script": "Invoke-Pester",
|
||||
"args": [],
|
||||
"cwd": "${workspaceRoot}"
|
||||
},
|
||||
{
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"name": "PowerShell Launch (current file)",
|
||||
"script": "${file}",
|
||||
"args": [],
|
||||
"cwd": "${file}"
|
||||
},
|
||||
{
|
||||
"type": "PowerShell",
|
||||
"request": "attach",
|
||||
"name": "PowerShell Attach to Host Process",
|
||||
"processId": "${command.PickPSHostProcess}",
|
||||
"runspaceId": 1
|
||||
},
|
||||
{
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"name": "PowerShell Interactive Session",
|
||||
"cwd": "${workspaceRoot}"
|
||||
}
|
||||
]
|
||||
}
|
||||
15
.vscode/settings.json
vendored
Normal file
15
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"files.encoding": "utf8",
|
||||
"files.eol": "\r\n",
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.insertFinalNewline": true,
|
||||
"editor.tabSize": 4,
|
||||
"[markdown]": {
|
||||
"editor.wordwrap": "on",
|
||||
"editor.renderWhitespace": "all",
|
||||
"editor.acceptSuggestionOnEnter": false,
|
||||
"editor.rulers": [80],
|
||||
"editor.trimAutoWhitespace": false
|
||||
}
|
||||
}
|
||||
56
.vscode/tasks.json
vendored
Normal file
56
.vscode/tasks.json
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
// Available variables which can be used inside of strings.
|
||||
// ${workspaceRoot}: the root folder of the team
|
||||
// ${file}: the current opened file
|
||||
// ${relativeFile}: the current opened file relative to workspaceRoot
|
||||
// ${fileBasename}: the current opened file's basename
|
||||
// ${fileDirname}: the current opened file's dirname
|
||||
// ${fileExtname}: the current opened file's extension
|
||||
// ${cwd}: the current working directory of the spawned process
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
// Start PowerShell
|
||||
"windows": {
|
||||
"command": "${env:windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
|
||||
"args": [
|
||||
"-NoProfile",
|
||||
"-ExecutionPolicy",
|
||||
"Bypass"
|
||||
]
|
||||
},
|
||||
"linux": {
|
||||
"command": "/usr/bin/powershell",
|
||||
"args": [
|
||||
"-NoProfile"
|
||||
]
|
||||
},
|
||||
"osx": {
|
||||
"command": "/usr/local/bin/powershell",
|
||||
"args": [
|
||||
"-NoProfile"
|
||||
]
|
||||
},
|
||||
// Show the output window always
|
||||
"showOutput": "always",
|
||||
// Associate with test task runner
|
||||
"tasks": [{
|
||||
"taskName": "Build Help",
|
||||
"suppressTaskName": true,
|
||||
"args": [
|
||||
"Write-Host 'Invoking platyPS'; New-ExternalHelp -Path .\\docs\\en-US -OutputPath .\\ConfluencePS\\en-US -Force;",
|
||||
"Invoke-Command { Write-Host 'Completed Build task in task runner.' }"
|
||||
]
|
||||
},
|
||||
{
|
||||
"taskName": "Test",
|
||||
"suppressTaskName": true,
|
||||
"isTestCommand": true,
|
||||
"args": [
|
||||
"Write-Host 'Invoking Pester'; Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true};",
|
||||
"Invoke-Command { Write-Host 'Completed Test task in task runner.' }"
|
||||
],
|
||||
"problemMatcher": "$pester"
|
||||
}
|
||||
]
|
||||
}
|
||||
8
CHANGELOG.md
Normal file
8
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/),
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [1.0] - 2017-11-18
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Brian Bunke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
30
README.md
Normal file
30
README.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
[](https://github.com/snazy2000/snipeitps/releases/latest) [](https://ci.appveyor.com/project/snazy2000/snipeitps/branch/master) [](https://www.powershellgallery.com/packages/snipeitps) 
|
||||
|
||||
---
|
||||
|
||||
## Instructions
|
||||
|
||||
### Installation
|
||||
|
||||
Install SnipeitPS from the PowerShell Gallery `Install-Module` requires PowerShellGet (included in PS v5, or download for v3/v4 via the gallery link)
|
||||
|
||||
```powershell
|
||||
# One time only install: (requires an admin PowerShell window)
|
||||
Install-Module SnipeitPS
|
||||
|
||||
# Check for updates occasionally:
|
||||
Update-Module SnipeitPS
|
||||
|
||||
# To use each session:
|
||||
Import-Module SnipeitPS
|
||||
Set-Info -URL 'https://asset.example.com' -apiKey 'tokenKey'
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```powershell
|
||||
# Review the help at any time!
|
||||
Get-Help about_SnipeitPS
|
||||
Get-Command -Module SnipeitPS
|
||||
Get-Help Get-Asset -Full # or any other command
|
||||
```
|
||||
|
|
@ -10,22 +10,122 @@ if ($PSBoundParameters.ContainsKey('Verbose')) {
|
|||
if (!($env:releasePath)) {
|
||||
$releasePath = "$BuildRoot\Release"
|
||||
}
|
||||
else {
|
||||
elseif ($env:releasePath) {
|
||||
$releasePath = $env:releasePath
|
||||
}
|
||||
else {
|
||||
$releasePath = "$($pwd.Path)\Release"
|
||||
}
|
||||
$env:PSModulePath = "$($env:PSModulePath);$releasePath"
|
||||
|
||||
Import-Module BuildHelpers
|
||||
|
||||
# Ensure Invoke-Build works in the most strict mode.
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
# region debug information
|
||||
task ShowDebug {
|
||||
Write-Build Gray
|
||||
Write-Build Gray ('Project name: {0}' -f $env:APPVEYOR_PROJECT_NAME)
|
||||
Write-Build Gray ('Project root: {0}' -f $env:APPVEYOR_BUILD_FOLDER)
|
||||
Write-Build Gray ('Repo name: {0}' -f $env:APPVEYOR_REPO_NAME)
|
||||
Write-Build Gray ('Branch: {0}' -f $env:APPVEYOR_REPO_BRANCH)
|
||||
Write-Build Gray ('Commit: {0}' -f $env:APPVEYOR_REPO_COMMIT)
|
||||
Write-Build Gray (' - Author: {0}' -f $env:APPVEYOR_REPO_COMMIT_AUTHOR)
|
||||
Write-Build Gray (' - Time: {0}' -f $env:APPVEYOR_REPO_COMMIT_TIMESTAMP)
|
||||
Write-Build Gray (' - Message: {0}' -f $env:APPVEYOR_REPO_COMMIT_MESSAGE)
|
||||
Write-Build Gray (' - Extended message: {0}' -f $env:APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED)
|
||||
Write-Build Gray ('Pull request number: {0}' -f $env:APPVEYOR_PULL_REQUEST_NUMBER)
|
||||
Write-Build Gray ('Pull request title: {0}' -f $env:APPVEYOR_PULL_REQUEST_TITLE)
|
||||
Write-Build Gray ('AppVeyor build ID: {0}' -f $env:APPVEYOR_BUILD_ID)
|
||||
Write-Build Gray ('AppVeyor build number: {0}' -f $env:APPVEYOR_BUILD_NUMBER)
|
||||
Write-Build Gray ('AppVeyor build version: {0}' -f $env:APPVEYOR_BUILD_VERSION)
|
||||
Write-Build Gray ('AppVeyor job ID: {0}' -f $env:APPVEYOR_JOB_ID)
|
||||
Write-Build Gray ('Build triggered from tag? {0}' -f $env:APPVEYOR_REPO_TAG)
|
||||
Write-Build Gray (' - Tag name: {0}' -f $env:APPVEYOR_REPO_TAG_NAME)
|
||||
Write-Build Gray ('PowerShell version: {0}' -f $PSVersionTable.PSVersion.ToString())
|
||||
Write-Build Gray
|
||||
}
|
||||
|
||||
# Synopsis: Install pandoc to .\Tools\
|
||||
task InstallPandoc -If (-not (Test-Path Tools\pandoc.exe)) {
|
||||
# Setup
|
||||
if (-not (Test-Path "$BuildRoot\Tools")) {
|
||||
$null = New-Item -Path "$BuildRoot\Tools" -ItemType Directory
|
||||
}
|
||||
|
||||
# Get latest bits
|
||||
$latestRelease = "https://github.com/jgm/pandoc/releases/download/1.19.2.1/pandoc-1.19.2.1-windows.msi"
|
||||
Invoke-WebRequest -Uri $latestRelease -OutFile "$($env:temp)\pandoc.msi"
|
||||
|
||||
# Extract bits
|
||||
$null = New-Item -Path $env:temp\pandoc -ItemType Directory -Force
|
||||
Start-Process -Wait -FilePath msiexec.exe -ArgumentList " /qn /a `"$($env:temp)\pandoc.msi`" targetdir=`"$($env:temp)\pandoc\`""
|
||||
|
||||
# Move to Tools folder
|
||||
Copy-Item -Path "$($env:temp)\pandoc\Pandoc\pandoc.exe" -Destination "$BuildRoot\Tools\"
|
||||
Copy-Item -Path "$($env:temp)\pandoc\Pandoc\pandoc-citeproc.exe" -Destination "$BuildRoot\Tools\"
|
||||
|
||||
# Clean
|
||||
Remove-Item -Path "$($env:temp)\pandoc" -Recurse -Force
|
||||
}
|
||||
# endregion
|
||||
|
||||
# region test
|
||||
task Test RapidTest
|
||||
|
||||
# Synopsis: Using the "Fast" Test Suit
|
||||
task RapidTest PesterTests
|
||||
# Synopsis: Using the complete Test Suit, which includes all supported Powershell versions
|
||||
task FullTest TestVersions
|
||||
|
||||
# Synopsis: Warn about not empty git status if .git exists.
|
||||
task GitStatus -If (Test-Path .git) {
|
||||
$status = exec { git status -s }
|
||||
if ($status) {
|
||||
Write-Warning "Git status: $($status -join ', ')"
|
||||
}
|
||||
}
|
||||
|
||||
task TestVersions TestPS3, TestPS4, TestPS4, TestPS5
|
||||
task TestPS3 {
|
||||
exec {powershell.exe -Version 3 -NoProfile Invoke-Build PesterTests}
|
||||
}
|
||||
task TestPS4 {
|
||||
exec {powershell.exe -Version 4 -NoProfile Invoke-Build PesterTests}
|
||||
}
|
||||
task TestPS5 {
|
||||
exec {powershell.exe -Version 5 -NoProfile Invoke-Build PesterTests}
|
||||
}
|
||||
|
||||
# Synopsis: Invoke Pester Tests
|
||||
task PesterTests CreateHelp, {
|
||||
try {
|
||||
$result = Invoke-Pester -PassThru -OutputFile "$BuildRoot\TestResult.xml" -OutputFormat "NUnitXml"
|
||||
if ($env:APPVEYOR_PROJECT_NAME) {
|
||||
Add-TestResultToAppveyor -TestFile "$BuildRoot\TestResult.xml"
|
||||
Remove-Item "$BuildRoot\TestResult.xml" -Force
|
||||
}
|
||||
assert ($result.FailedCount -eq 0) "$($result.FailedCount) Pester test(s) failed."
|
||||
}
|
||||
catch {
|
||||
throw
|
||||
}
|
||||
}
|
||||
# endregion
|
||||
|
||||
# region build
|
||||
# Synopsis: Build shippable release
|
||||
task Build GenerateRelease, UpdateManifest
|
||||
task Build GenerateRelease, ConvertMarkdown, UpdateManifest
|
||||
|
||||
task CreateHelp {
|
||||
Import-Module platyPS -Force
|
||||
New-ExternalHelp -Path "$BuildRoot\docs" -OutputPath "$BuildRoot\SnipeitPS\en-US" -Force
|
||||
Remove-Module SnipeitPS, platyPS
|
||||
}
|
||||
|
||||
# Synopsis: Generate .\Release structure
|
||||
task GenerateRelease {
|
||||
task GenerateRelease CreateHelp, {
|
||||
# Setup
|
||||
if (-not (Test-Path "$releasePath\SnipeitPS")) {
|
||||
$null = New-Item -Path "$releasePath\SnipeitPS" -ItemType Directory
|
||||
|
|
@ -34,26 +134,19 @@ task GenerateRelease {
|
|||
# Copy module
|
||||
Copy-Item -Path "$BuildRoot\SnipeitPS\*" -Destination "$releasePath\SnipeitPS" -Recurse -Force
|
||||
# Copy additional files
|
||||
<#$additionalFiles = @(
|
||||
$additionalFiles = @(
|
||||
"$BuildRoot\CHANGELOG.md"
|
||||
"$BuildRoot\LICENSE"
|
||||
"$BuildRoot\README.md"
|
||||
)
|
||||
Copy-Item -Path $additionalFiles -Destination "$releasePath\SnipeitPS" -Force#>
|
||||
Copy-Item -Path $additionalFiles -Destination "$releasePath\SnipeitPS" -Force
|
||||
}
|
||||
|
||||
# Synopsis: Update the manifest of the module
|
||||
task UpdateManifest GetVersion, {
|
||||
$ModuleAlias = (Get-Alias | Where source -eq JiraPS)
|
||||
|
||||
Remove-Module JiraPS -ErrorAction SilentlyContinue
|
||||
Import-Module "$releasePath\SnipeitPS\SnipeitPS.psd1"
|
||||
Update-Metadata -Path "$releasePath\SnipeitPS\SnipeitPS.psd1" -PropertyName ModuleVersion -Value $script:Version
|
||||
# Update-Metadata -Path "$releasePath\SnipeitPS\SnipeitPS.psd1" -PropertyName FileList -Value (Get-ChildItem $releasePath\SnipeitPS -Recurse).Name
|
||||
if ($ModuleAlias) {
|
||||
Update-Metadata -Path "$releasePath\SnipeitPS\SnipeitPS.psd1" -PropertyName AliasesToExport -Value @($ModuleAlias.Name)
|
||||
}
|
||||
Set-ModuleFunctions -Name "$releasePath\SnipeitPS\SnipeitPS.psd1" -FunctionsToExport ([string[]](Get-ChildItem "$releasePath\SnipeitPS\public\*.ps1").BaseName)
|
||||
$functionsToExport = Get-ChildItem "$BuildRoot\SnipeitPS\Public" | ForEach-Object {$_.BaseName}
|
||||
Set-ModuleFunctions -Name "$releasePath\SnipeitPS\SnipeitPS.psd1" -FunctionsToExport $functionsToExport
|
||||
}
|
||||
|
||||
task GetVersion {
|
||||
|
|
@ -74,22 +167,74 @@ task GetVersion {
|
|||
$newRevision
|
||||
}
|
||||
|
||||
# Synopsis: Convert markdown files to HTML.
|
||||
# <http://johnmacfarlane.net/pandoc/>
|
||||
$ConvertMarkdown = @{
|
||||
Inputs = { Get-ChildItem "$releasePath\SnipeitPS\*.md" -Recurse }
|
||||
Outputs = {process {
|
||||
[System.IO.Path]::ChangeExtension($_, 'htm')
|
||||
}
|
||||
}
|
||||
}
|
||||
# Synopsis: Converts *.md and *.markdown files to *.htm
|
||||
task ConvertMarkdown -Partial @ConvertMarkdown InstallPandoc, {process {
|
||||
exec { Tools\pandoc.exe $_ --standalone --from=markdown_github "--output=$2" }
|
||||
}
|
||||
}, RemoveMarkdownFiles
|
||||
# endregion
|
||||
|
||||
# region publish
|
||||
task Deploy -If (
|
||||
# Only deploy if the master branch changes
|
||||
$env:APPVEYOR_REPO_BRANCH -eq 'master' -and
|
||||
# Do not deploy if this is a pull request (because it hasn't been approved yet)
|
||||
(-not ($env:APPVEYOR_PULL_REQUEST_NUMBER)) -and
|
||||
# Do not deploy if the commit contains the string "skip-deploy"
|
||||
# Meant for major/minor version publishes with a .0 build/patch version (like 2.1.0)
|
||||
$env:APPVEYOR_REPO_COMMIT_MESSAGE -notlike '*skip-deploy*'
|
||||
) {
|
||||
Remove-Module SnipeitPS -ErrorAction SilentlyContinue
|
||||
}, PublishToGallery
|
||||
|
||||
task PublishToGallery {
|
||||
assert ($env:PSGalleryAPIKey) "No key for the PSGallery"
|
||||
|
||||
Import-Module $releasePath\SnipeitPS\SnipeitPS.psd1 -ErrorAction Stop
|
||||
Publish-Module -Name SnipeitPS -NuGetApiKey $env:PSGalleryAPIKey
|
||||
}
|
||||
|
||||
# Synopsis: Push with a version tag.
|
||||
task PushRelease GitStatus, GetVersion, {
|
||||
# Done in appveyor.yml with deploy provider.
|
||||
# This is needed, as I don't know how to athenticate (2-factor) in here.
|
||||
exec { git checkout master }
|
||||
$changes = exec { git status --short }
|
||||
assert (!$changes) "Please, commit changes."
|
||||
|
||||
exec { git push }
|
||||
exec { git tag -a "v$Version" -m "v$Version" }
|
||||
exec { git push origin "v$Version" }
|
||||
}
|
||||
# endregion
|
||||
|
||||
|
||||
#region Cleaning tasks
|
||||
task Clean RemoveGeneratedFiles
|
||||
|
||||
# Synopsis: Remove generated and temp files.
|
||||
task RemoveGeneratedFiles {
|
||||
$itemsToRemove = @(
|
||||
'Release'
|
||||
'*.htm'
|
||||
'TestResult.xml'
|
||||
'SnipeitPS\en-US\*'
|
||||
)
|
||||
Remove-Item $itemsToRemove -Force -Recurse -ErrorAction 0
|
||||
}
|
||||
|
||||
task RemoveMarkdownFiles {
|
||||
Remove-Item "$releasePath\SnipeitPS\*.md" -Force -ErrorAction 0
|
||||
}
|
||||
# endregion
|
||||
|
||||
|
||||
task . Build, Clean
|
||||
task . ShowDebug, Clean, Test, Build, Deploy
|
||||
|
|
|
|||
26
SnipeitPS/Private/ConvertTo-GetParameter.ps1
Normal file
26
SnipeitPS/Private/ConvertTo-GetParameter.ps1
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
function ConvertTo-GetParameter {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Generate the GET parameter string for an URL from a hashtable
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
[Parameter( Position = 0, Mandatory = $true, ValueFromPipeline = $true )]
|
||||
[hashtable]$InputObject
|
||||
)
|
||||
|
||||
BEGIN {
|
||||
[string]$parameters = "?"
|
||||
}
|
||||
|
||||
PROCESS {
|
||||
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Making HTTP get parameter string out of a hashtable"
|
||||
foreach ($key in $InputObject.Keys) {
|
||||
$parameters += "$key=$($InputObject[$key])&"
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
$parameters -replace ".$"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
function Invoke-Method {
|
||||
function Invoke-SnipeitMethod {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Extracted invokation of the REST method to own function.
|
||||
|
|
@ -19,7 +19,11 @@
|
|||
[ValidateNotNullOrEmpty()]
|
||||
[string]$Body,
|
||||
|
||||
[string] $Token
|
||||
[string] $Token,
|
||||
|
||||
# GET Parameters
|
||||
[Hashtable]$GetParameters
|
||||
|
||||
)
|
||||
|
||||
BEGIN {
|
||||
|
|
@ -38,6 +42,14 @@
|
|||
}
|
||||
|
||||
Process {
|
||||
if ($GetParameters -and ($URi -notlike "*\?*"))
|
||||
{
|
||||
Write-Debug "Using `$GetParameters: $($GetParameters | Out-String)"
|
||||
[string]$URI += (ConvertTo-GetParameter $GetParameters)
|
||||
# Prevent recursive appends
|
||||
$GetParameters = $null
|
||||
}
|
||||
|
||||
# set mandatory parameters
|
||||
$splatParameters = @{
|
||||
Uri = $URi
|
||||
|
|
@ -74,7 +86,7 @@
|
|||
|
||||
# API returned a Content: lets work wit it
|
||||
$response = ConvertFrom-Json -InputObject $webResponse.Content
|
||||
|
||||
|
||||
if ($response.status -eq "error") {
|
||||
Write-Verbose "[$($MyInvocation.MyCommand.Name)] An error response was received from; resolving"
|
||||
# This could be handled nicely in an function such as:
|
||||
|
|
@ -83,14 +95,14 @@
|
|||
}
|
||||
else {
|
||||
$result = $response
|
||||
if (($response) -and ($response | Get-Member -Name payload))
|
||||
if (($response) -and ($response | Get-Member -Name payload))
|
||||
{
|
||||
$result = $response.payload
|
||||
}
|
||||
elseif (($response) -and ($response | Get-Member -Name rows)) {
|
||||
$result = $response.rows
|
||||
}
|
||||
|
||||
|
||||
$result
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +111,7 @@
|
|||
# This could be wanted behavior of the API
|
||||
Write-Verbose "[$($MyInvocation.MyCommand.Name)] No content was returned from."
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
Write-Verbose "[$($MyInvocation.MyCommand.Name)] No Web result object was returned from. This is unusual!"
|
||||
|
|
@ -109,4 +121,4 @@
|
|||
END {
|
||||
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Assets
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -url "https://assets.dip.co.uk" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -url "https://assets.dip.co.uk" -token "token..." | Where-Object {$_.name -eq "SUPPORT23" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Asset()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/hardware" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
function New-Asset()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Name,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Status_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Model_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey,
|
||||
|
||||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
|
||||
$Values += $customfields
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/hardware" `
|
||||
-Method POST `
|
||||
-Body $Body `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
function Set-Asset()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[int]$id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Name,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Status_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Model_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey,
|
||||
|
||||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
|
||||
$Values += $customfields
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/hardware/$id" `
|
||||
-Method PUT `
|
||||
-Body $Body `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
function Set-AssetOwner()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[int]$id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[int]$user_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"user_id" = $user_id
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -Uri "$url/api/v1/hardware/$id/checkout" `
|
||||
-Method POST `
|
||||
-Token $apiKey `
|
||||
-Body $Body
|
||||
|
||||
return $result
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
function Get-Categories()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/categories" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
function Get-Component()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/components" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
function New-Component()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$category_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$qty,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $name
|
||||
"category_id" = $category_id
|
||||
"qty" = $qty
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/components" `
|
||||
-Method POST `
|
||||
-Body $Body `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
function Update-Component()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$qty,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"qty" = $qty
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/components/$component_id" `
|
||||
-Method Patch `
|
||||
-Body $Body `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
<#
|
||||
Checkout does not exsit yet :(
|
||||
|
||||
function Checkout-Component($component_id, $asset_id = "")
|
||||
{
|
||||
$Values = @{
|
||||
"asset_id" = $asset_id
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Manufacturers = Invoke-RestMethod -Uri "http://assets.dip.co.uk/api/v1/hardware/$component_id/checkout" `
|
||||
-Method Post `
|
||||
-Header $headers `
|
||||
-Body $Body `
|
||||
-ContentType "application/json" `
|
||||
-UserAgent "DI Script/0.1"
|
||||
|
||||
return $Manufacturers
|
||||
}#>
|
||||
44
SnipeitPS/Public/Get-Asset.ps1
Normal file
44
SnipeitPS/Public/Get-Asset.ps1
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Assets
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Asset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "MyMachine" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Asset()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
38
SnipeitPS/Public/Get-Category.ps1
Normal file
38
SnipeitPS/Public/Get-Category.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Categories
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Category -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Category -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Laptop" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Category()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/categories"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
38
SnipeitPS/Public/Get-Component.ps1
Normal file
38
SnipeitPS/Public/Get-Component.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Components
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Component -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Component -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Memory" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Component()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
38
SnipeitPS/Public/Get-Manufacturer.ps1
Normal file
38
SnipeitPS/Public/Get-Manufacturer.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Manufacturers
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Manufacturer -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Manufacturer -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "HP" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Manufacturer()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/manufacturers"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
38
SnipeitPS/Public/Get-Model.ps1
Normal file
38
SnipeitPS/Public/Get-Model.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Models
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Models -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Models -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "DL380" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Model()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
38
SnipeitPS/Public/Get-Status.ps1
Normal file
38
SnipeitPS/Public/Get-Status.ps1
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Status Labels
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Status -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Status -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Ready to Deploy" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Status()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/statuslabels"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
39
SnipeitPS/Public/Get-Supplier.ps1
Normal file
39
SnipeitPS/Public/Get-Supplier.ps1
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Suppliers
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Supplier -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Supplier -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "MySupplier" }
|
||||
|
||||
#>
|
||||
|
||||
function Get-Supplier()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/suppliers"
|
||||
Method = 'Get'
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
40
SnipeitPS/Public/Get-User.ps1
Normal file
40
SnipeitPS/Public/Get-User.ps1
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Users
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-User -url "https://assets.example.com" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-User -url "https://assets.example.com" -token "token..." | Where-Object {$_.username -eq "stephenm" }
|
||||
|
||||
#>
|
||||
function Get-User()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/users"
|
||||
Method = 'Get'
|
||||
GetParameters = @{
|
||||
limit = 999
|
||||
}
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
function Get-Manufacturers()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/manufacturers" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
function New-Manufacturer()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$Name,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
}
|
||||
|
||||
#Convert Values to JSON format
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/manufacturers" `
|
||||
-Method POST `
|
||||
-Body $Body `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
|
||||
function Get-Models()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/models" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
|
||||
function New-Model()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[int]$category_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[int]$manufacturer_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[int]$fieldset_id,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
name = $name
|
||||
category_id = $category_id
|
||||
manufacturer_id = $manufacturer_id
|
||||
fieldset_id = $fieldset_id
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/models" `
|
||||
-Method POST `
|
||||
-Body $Body `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
95
SnipeitPS/Public/New-Asset.ps1
Normal file
95
SnipeitPS/Public/New-Asset.ps1
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Add a new Asset to Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER Tag
|
||||
Asset Tag for the Asset
|
||||
|
||||
.PARAMETER Name
|
||||
Name of the Asset
|
||||
|
||||
.PARAMETER Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
|
||||
.PARAMETER Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.PARAMETER customfields
|
||||
Hastable of custom fields and extra fields that need passing through to Snipeit
|
||||
|
||||
.EXAMPLE
|
||||
New-Asset -status_id 1 -model_id 1 -name "Machine1"
|
||||
|
||||
.EXAMPLE
|
||||
New-Asset -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
||||
#>
|
||||
|
||||
function New-Asset()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[string]$tag,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Status_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Model_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey,
|
||||
|
||||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
|
||||
if ($PSBoundParameters.ContainsKey('tag'))
|
||||
{
|
||||
$Values += @{"asset_tag" = $tag}
|
||||
}
|
||||
|
||||
if ($customfields)
|
||||
{
|
||||
$Values += $customfields
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware"
|
||||
Method = 'Post'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
76
SnipeitPS/Public/New-Component.ps1
Normal file
76
SnipeitPS/Public/New-Component.ps1
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Short description
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER name
|
||||
Parameter description
|
||||
|
||||
.PARAMETER category_id
|
||||
Parameter description
|
||||
|
||||
.PARAMETER qty
|
||||
Parameter description
|
||||
|
||||
.PARAMETER url
|
||||
Parameter description
|
||||
|
||||
.PARAMETER apiKey
|
||||
Parameter description
|
||||
|
||||
.EXAMPLE
|
||||
An example
|
||||
|
||||
.NOTES
|
||||
General notes
|
||||
#>
|
||||
|
||||
function New-Component()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$category_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$qty,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $name
|
||||
"category_id" = $category_id
|
||||
"qty" = $qty
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
||||
60
SnipeitPS/Public/New-Manufacturer.ps1
Normal file
60
SnipeitPS/Public/New-Manufacturer.ps1
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Add a new Manufacturer to Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER Name
|
||||
Name of the Manufacturer
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
New-Manufacturer -name "HP"
|
||||
#>
|
||||
|
||||
function New-Manufacturer()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
}
|
||||
|
||||
#Convert Values to JSON format
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/manufacturers"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
79
SnipeitPS/Public/New-Model.ps1
Normal file
79
SnipeitPS/Public/New-Model.ps1
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Add a new Model to Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER name
|
||||
Name of the Asset Model
|
||||
|
||||
.PARAMETER category_id
|
||||
Category ID that the asset belongs to this can be got using Get-Category
|
||||
|
||||
.PARAMETER manufacturer_id
|
||||
Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer
|
||||
|
||||
.PARAMETER fieldset_id
|
||||
Fieldset ID that the asset uses (Custom fields)
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
New-Model -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
|
||||
#>
|
||||
|
||||
function New-Model()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$category_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$manufacturer_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$fieldset_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
name = $name
|
||||
category_id = $category_id
|
||||
manufacturer_id = $manufacturer_id
|
||||
fieldset_id = $fieldset_id
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/models"
|
||||
Method = 'post'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
91
SnipeitPS/Public/Set-Asset.ps1
Normal file
91
SnipeitPS/Public/Set-Asset.ps1
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
Update a Asset in the Snipe-it asset system
|
||||
|
||||
.DESCRIPTION
|
||||
Long description
|
||||
|
||||
.PARAMETER id
|
||||
ID of the Asset
|
||||
|
||||
.PARAMETER Name
|
||||
Name of the Asset
|
||||
|
||||
.PARAMETER Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
|
||||
.PARAMETER Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.PARAMETER customfields
|
||||
Hastable of custom fields and extra fields that need passing through to Snipeit
|
||||
|
||||
.EXAMPLE
|
||||
Set-Asset -id 1 -status_id 1 -model_id 1 -name "Machine1"
|
||||
|
||||
.EXAMPLE
|
||||
Set-Asset -id 1 -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
||||
#>
|
||||
|
||||
function Set-Asset()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Name,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Status_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$Model_id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey,
|
||||
|
||||
[hashtable] $customfields
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"name" = $Name
|
||||
"status_id" = $status_id
|
||||
"model_id" = $model_id
|
||||
}
|
||||
|
||||
if ($customfields)
|
||||
{
|
||||
$Values += $customfields
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$id"
|
||||
Method = 'Put'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
52
SnipeitPS/Public/Set-AssetOwner.ps1
Normal file
52
SnipeitPS/Public/Set-AssetOwner.ps1
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
function Set-AssetOwner()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[int]$assigned_id,
|
||||
|
||||
[ValidateSet("location","asset","user")]
|
||||
[string] $checkout_to_type = "user",
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"id" = $assigned_id
|
||||
"checkout_to_type" = $checkout_to_type
|
||||
}
|
||||
|
||||
switch ($checkout_to_type)
|
||||
{
|
||||
'location' { $Values += @{ "assigned_location" = $assigned_id } }
|
||||
'user' { $Values += @{ "assigned_user" = $assigned_id } }
|
||||
'asset' { $Values += @{ "assigned_asset" = $assigned_id } }
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/hardware/$id/checkout"
|
||||
Method = 'POST'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
41
SnipeitPS/Public/Set-Components.ps1
Normal file
41
SnipeitPS/Public/Set-Components.ps1
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
function Set-Component()
|
||||
{
|
||||
[CmdletBinding(
|
||||
SupportsShouldProcess = $true,
|
||||
ConfirmImpact = "High"
|
||||
)]
|
||||
|
||||
Param(
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$id,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$qty,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory = $true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$Values = @{
|
||||
"qty" = $qty
|
||||
}
|
||||
|
||||
$Body = $Values | ConvertTo-Json;
|
||||
|
||||
$Parameters = @{
|
||||
Uri = "$url/api/v1/components/$component_id"
|
||||
Method = 'Patch'
|
||||
Body = $Body
|
||||
Token = $apiKey
|
||||
}
|
||||
|
||||
If ($PSCmdlet.ShouldProcess("ShouldProcess?"))
|
||||
{
|
||||
$result = Invoke-SnipeitMethod @Parameters
|
||||
}
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -47,4 +47,4 @@ function Set-Info {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
function Get-Status()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/statuslabels" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<#
|
||||
.SYNOPSIS
|
||||
# Gets a list of Snipe-it Users
|
||||
|
||||
.PARAMETER url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
.PARAMETER apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
.EXAMPLE
|
||||
Get-Users -url "https://assets.dip.co.uk" -token "token..."
|
||||
|
||||
.EXAMPLE
|
||||
Get-Users -url "https://assets.dip.co.uk" -token "token..." | Where-Object {$_.username -eq "stephenm" }
|
||||
|
||||
#>
|
||||
function Get-Users()
|
||||
{
|
||||
Param(
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$url,
|
||||
|
||||
[parameter(mandatory=$true)]
|
||||
[string]$apiKey
|
||||
)
|
||||
|
||||
$result = Invoke-Method -URi "$url/api/v1/users?limit=999" `
|
||||
-Method GET `
|
||||
-Token $apiKey
|
||||
|
||||
$result
|
||||
}
|
||||
Binary file not shown.
|
|
@ -1,11 +1,11 @@
|
|||
$scriptRoot = $PSScriptRoot + '\public'
|
||||
|
||||
Get-ChildItem $scriptRoot *.psm1 | ForEach-Object {
|
||||
Get-ChildItem $scriptRoot *.ps1 | ForEach-Object {
|
||||
Import-Module $_.FullName
|
||||
}
|
||||
|
||||
$scriptRoot = $PSScriptRoot + '\private'
|
||||
|
||||
Get-ChildItem $scriptRoot *.psm1 | ForEach-Object {
|
||||
Get-ChildItem $scriptRoot *.ps1 | ForEach-Object {
|
||||
Import-Module $_.FullName
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,53 +1,212 @@
|
|||
$ModulePath = Split-Path -Path $PSScriptRoot -Parent
|
||||
$ModuleName = Split-Path -Path $ModulePath -Leaf
|
||||
#Requires -Modules PSScriptAnalyzer
|
||||
|
||||
# Make sure one or multiple versions of the module are not loaded
|
||||
Get-Module -Name $ModuleName | Remove-Module
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$projectRoot = Split-Path -Parent $here
|
||||
$moduleRoot = "$projectRoot\SnipeitPS"
|
||||
|
||||
# Import the module and store the information about the module
|
||||
$ModuleInformation = Import-Module -Name "$ModulePath\$ModuleName.psd1" -PassThru
|
||||
$ModuleInformation | Format-List
|
||||
$manifestFile = "$moduleRoot\SnipeitPS.psd1"
|
||||
$changelogFile = "$projectRoot\CHANGELOG.md"
|
||||
$appveyorFile = "$projectRoot\appveyor.yml"
|
||||
$publicFunctions = "$moduleRoot\Public"
|
||||
|
||||
# Get the functions present in the Manifest
|
||||
$ExportedFunctions = $ModuleInformation.ExportedFunctions.Values.Name
|
||||
Describe "SnipeitPS" {
|
||||
Context "All required tests are present" {
|
||||
# We want to make sure that every .ps1 file in the Functions directory that isn't a Pester test has an associated Pester test.
|
||||
# This helps keep me honest and makes sure I'm testing my code appropriately.
|
||||
It "Includes a test for each PowerShell function in the module" {
|
||||
# Get-ChildItem -Path $publicFunctions -Filter "*.ps1" -Recurse | Where-Object -FilterScript {$_.Name -notlike '*.Tests.ps1'} | % {
|
||||
# $expectedTestFile = Join-Path $projectRoot "Tests\$($_.BaseName).Tests.ps1"
|
||||
# $expectedTestFile | Should Exist
|
||||
# }
|
||||
}
|
||||
}
|
||||
|
||||
# Get the functions present in the Public folder
|
||||
$PS1Functions = Get-ChildItem -Path "$ModulePath\Public\*.ps1"
|
||||
Context "Manifest, changelog, and AppVeyor" {
|
||||
|
||||
Describe "$ModuleName Module - Testing Manifest File (.psd1)" {
|
||||
Context "Manifest" {
|
||||
It "Should contain RootModule" {
|
||||
$ModuleInformation.RootModule | Should Not BeNullOrEmpty
|
||||
# These tests are...erm, borrowed...from the module tests from the Pester module.
|
||||
# I think they are excellent for sanity checking, and all credit for the following
|
||||
# tests goes to Dave Wyatt, the genius behind Pester. I've just adapted them
|
||||
# slightly to match SnipeitPS.
|
||||
|
||||
$script:manifest = $null
|
||||
|
||||
foreach ($line in (Get-Content $changelogFile))
|
||||
{
|
||||
if ($line -match "^\D*(?<Version>(\d+\.){1,3}\d+)")
|
||||
{
|
||||
$changelogVersion = $matches.Version
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
It "Should contain ModuleVersion" {
|
||||
$ModuleInformation.Version | Should Not BeNullOrEmpty
|
||||
foreach ($line in (Get-Content $appveyorFile))
|
||||
{
|
||||
# (?<Version>()) - non-capturing group, but named Version. This makes it
|
||||
# easy to reference the inside group later.
|
||||
|
||||
if ($line -match '^\D*(?<Version>(\d+\.){1,3}\d+).\{build\}')
|
||||
{
|
||||
$appveyorVersion = $matches.Version
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
It "Should contain GUID" {
|
||||
$ModuleInformation.Guid | Should Not BeNullOrEmpty
|
||||
It "Includes a valid manifest file" {
|
||||
{
|
||||
$script:manifest = Test-ModuleManifest -Path $script:manifestFile -ErrorAction Stop -WarningAction SilentlyContinue
|
||||
} | Should Not Throw
|
||||
}
|
||||
|
||||
It "Should contain Author" {
|
||||
$ModuleInformation.Author | Should Not BeNullOrEmpty
|
||||
# There is a bug that prevents Test-ModuleManifest from updating correctly when the manifest file changes. See here:
|
||||
# https://connect.microsoft.com/PowerShell/feedback/details/1541659/test-modulemanifest-the-psmoduleinfo-is-not-updated
|
||||
|
||||
# As a temp workaround, we'll just read the manifest as a raw hashtable.
|
||||
# Credit to this workaround comes from here:
|
||||
# https://psescape.azurewebsites.net/pester-testing-your-module-manifest/
|
||||
$script:manifest = Invoke-Expression (Get-Content $script:manifestFile -Raw)
|
||||
|
||||
It "Manifest file includes the correct root module" {
|
||||
$script:manifest.RootModule | Should Be 'SnipeitPS'
|
||||
}
|
||||
|
||||
It "Should contain Description" {
|
||||
$ModuleInformation.Description | Should Not BeNullOrEmpty
|
||||
It "Manifest file includes the correct guid" {
|
||||
$script:manifest.Guid | Should Be 'f86f4db4-1cb1-45c4-b7bf-6762531bfdeb'
|
||||
}
|
||||
|
||||
It "Compare the count of Function Exported and the PS1 files found" {
|
||||
$status = $ExportedFunctions.Count -eq $PS1Functions.Count
|
||||
$status | Should Be $true
|
||||
It "Manifest file includes a valid version" {
|
||||
# $script:manifest.Version -as [Version] | Should Not BeNullOrEmpty
|
||||
$script:manifest.ModuleVersion -as [Version] | Should Not BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Compare the missing function" {
|
||||
If ($ExportedFunctions.count -ne $PS1Functions.count) {
|
||||
$Compare = Compare-Object -ReferenceObject $ExportedFunctions -DifferenceObject $PS1Functions.Basename
|
||||
$Compare.InputObject -Join ',' | Should BeNullOrEmpty
|
||||
It "Includes a changelog file" {
|
||||
$changelogFile | Should Exist
|
||||
}
|
||||
|
||||
# $changelogVersion = $null
|
||||
It "Changelog includes a valid version number" {
|
||||
$changelogVersion | Should Not BeNullOrEmpty
|
||||
$changelogVersion -as [Version] | Should Not BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Changelog version matches manifest version" {
|
||||
$changelogVersion -as [Version] | Should Be ( $script:manifest.ModuleVersion -as [Version] )
|
||||
}
|
||||
|
||||
# Back to me! Pester doesn't use AppVeyor, as far as I know, and I do.
|
||||
|
||||
It "Includes an appveyor.yml file" {
|
||||
$appveyorFile | Should Exist
|
||||
}
|
||||
|
||||
It "Appveyor.yml file includes the module version" {
|
||||
$appveyorVersion | Should Not BeNullOrEmpty
|
||||
$appveyorVersion -as [Version] | Should Not BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Appveyor version matches manifest version" {
|
||||
$appveyorVersion -as [Version] | Should Be ( $script:manifest.ModuleVersion -as [Version] )
|
||||
}
|
||||
}
|
||||
|
||||
# The CI changes I'm testng now will render this section obsolete,
|
||||
# as it should automatically patch the module manifest file with all
|
||||
# exported function names.
|
||||
# Leaving the code here for the moment while I can ensure those
|
||||
# features are working correctly.
|
||||
|
||||
#
|
||||
# Context "Function checking" {
|
||||
# $functionFiles = Get-ChildItem $publicFunctions -Filter *.ps1 |
|
||||
# Select-Object -ExpandProperty BaseName |
|
||||
# Where-Object { $_ -notlike "*.Tests" }
|
||||
|
||||
# $internalFiles = Get-ChildItem $internalFunctions -Filter *.ps1 |
|
||||
# Select-Object -ExpandProperty BaseName |
|
||||
# Where-Object { $_ -notlike "*.Tests" }
|
||||
|
||||
# #$exportedFunctions = $script:manifest.ExportedFunctions.Values.Name
|
||||
# $exportedFunctions = $script:manifest.FunctionsToExport
|
||||
|
||||
# foreach ($f in $functionFiles) {
|
||||
# It "Exports $f" {
|
||||
# $exportedFunctions -contains $f | Should Be $true
|
||||
# }
|
||||
# }
|
||||
|
||||
# foreach ($f in $internalFiles) {
|
||||
# It "Does not export $f" {
|
||||
# $exportedFunctions -contains $f | Should Be $false
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
Context "Style checking" {
|
||||
|
||||
# This section is again from the mastermind, Dave Wyatt. Again, credit
|
||||
# goes to him for these tests.
|
||||
|
||||
$files = @(
|
||||
Get-ChildItem $here -Include *.ps1, *.psm1
|
||||
Get-ChildItem $publicFunctions -Include *.ps1, *.psm1 -Recurse
|
||||
)
|
||||
|
||||
It 'Source files contain no trailing whitespace' {
|
||||
$badLines = @(
|
||||
foreach ($file in $files)
|
||||
{
|
||||
$lines = [System.IO.File]::ReadAllLines($file.FullName)
|
||||
$lineCount = $lines.Count
|
||||
|
||||
for ($i = 0; $i -lt $lineCount; $i++)
|
||||
{
|
||||
if ($lines[$i] -match '\s+$')
|
||||
{
|
||||
'File: {0}, Line: {1}' -f $file.FullName, ($i + 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if ($badLines.Count -gt 0)
|
||||
{
|
||||
throw "The following $($badLines.Count) lines contain trailing whitespace: `r`n`r`n$($badLines -join "`r`n")"
|
||||
}
|
||||
}
|
||||
|
||||
It 'Source files all end with a newline' {
|
||||
$badFiles = @(
|
||||
foreach ($file in $files)
|
||||
{
|
||||
$string = [System.IO.File]::ReadAllText($file.FullName)
|
||||
if ($string.Length -gt 0 -and $string[-1] -ne "`n")
|
||||
{
|
||||
$file.FullName
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if ($badFiles.Count -gt 0)
|
||||
{
|
||||
throw "The following files do not end with a newline: `r`n`r`n$($badFiles -join "`r`n")"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context 'PSScriptAnalyzer Rules' {
|
||||
$analysis = Invoke-ScriptAnalyzer -Path "$moduleRoot" -Recurse
|
||||
$scriptAnalyzerRules = Get-ScriptAnalyzerRule
|
||||
|
||||
forEach ($rule in $scriptAnalyzerRules)
|
||||
{
|
||||
It "Should pass $rule" {
|
||||
If (($analysis) -and ($analysis.RuleName -contains $rule))
|
||||
{
|
||||
$analysis |
|
||||
Where-Object RuleName -EQ $rule -OutVariable failures |
|
||||
Out-Default
|
||||
$failures.Count | Should Be 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Get-Module -Name $ModuleName | Remove-Module
|
||||
75
appveyor.yml
Normal file
75
appveyor.yml
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
############################################################
|
||||
#
|
||||
# See http://www.appveyor.com/docs/appveyor-yml for many more options
|
||||
#
|
||||
# Credit for a lot of this file goes to RamblingCookieMonster:
|
||||
# https://github.com/RamblingCookieMonster/PSSQLite/blob/master/appveyor.yml
|
||||
#
|
||||
############################################################
|
||||
|
||||
# This tells AppVeyor that we need WMF 5 and PowerShell 5.0
|
||||
os: WMF 5
|
||||
|
||||
environment:
|
||||
PSGalleryAPIKey:
|
||||
secure: UdM6qhf5B0G8liHhUrwWERCZr44iSqmg4jUq0lwlTjZs4KyeoiwnBzdej0phqIAm
|
||||
|
||||
version: 1.0.{build}
|
||||
|
||||
# Don't rebuild when I tag a release on GitHub
|
||||
skip_tags: true
|
||||
|
||||
# Ignore testing a commit if only the readme changed
|
||||
# Or if I include "skip-tests" in the commit message
|
||||
skip_commits:
|
||||
message: /skip\-tests/
|
||||
files:
|
||||
- .github/
|
||||
- .vscode/
|
||||
- assets/
|
||||
- Tools/
|
||||
- README.md
|
||||
- .gitattributes
|
||||
- .gitignore
|
||||
|
||||
# PRs, by definition, don't change anything and therefore should not increment the version
|
||||
# To be fair, this is not important, and is really just AppVeyor enabling my pedantry
|
||||
pull_requests:
|
||||
do_not_increment_build_number: true
|
||||
|
||||
install:
|
||||
- ps: |
|
||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
|
||||
Install-Module InvokeBuild -Scope CurrentUser -Force
|
||||
Install-Module BuildHelpers -Scope CurrentUser -Force
|
||||
Install-Module platyPS -Scope CurrentUser -Force
|
||||
Install-Module Pester -Scope CurrentUser -Force
|
||||
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force
|
||||
$env:releasePath = "$($pwd.Path)\Release"
|
||||
|
||||
before_build:
|
||||
- ps: Invoke-Build -Task ShowDebug
|
||||
|
||||
build_script:
|
||||
- ps: Invoke-Build -Task Build
|
||||
|
||||
# after_build:
|
||||
# - cmd: mdspell %releasePath%\**/*.md --ignore-numbers --ignore-acronyms --report
|
||||
|
||||
test_script:
|
||||
- ps: Invoke-Build -Task Test
|
||||
|
||||
before_deploy:
|
||||
- ps: Invoke-Build -Task Deploy
|
||||
|
||||
deploy:
|
||||
provider: GitHub
|
||||
release: v$(appveyor_build_version)
|
||||
description: ''
|
||||
auth_token:
|
||||
secure: m72Ke3nJcSxZkc36UwRIw+q0NtNvERfQYHZUBNDvLP/kjW+mWmVueR6tmgBujyBM
|
||||
draft: false
|
||||
prerelease: false
|
||||
on:
|
||||
branch: master # release from master branch only
|
||||
appveyor_repo_tag: false # deploy on tag push only
|
||||
56
build.ps1
56
build.ps1
|
|
@ -0,0 +1,56 @@
|
|||
param(
|
||||
[string[]]$Tasks
|
||||
)
|
||||
|
||||
function Install-Dependency([string] $Name)
|
||||
{
|
||||
$policy = Get-PSRepository -Name "PSGallery" | Select-Object -ExpandProperty "InstallationPolicy"
|
||||
if($policy -ne "Trusted") {
|
||||
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
|
||||
}
|
||||
|
||||
if (!(Get-Module -Name $Name -ListAvailable)) {
|
||||
Install-Module -Name $Name -Scope CurrentUser
|
||||
}
|
||||
}
|
||||
|
||||
function Run-Tests
|
||||
{
|
||||
param(
|
||||
[string]$Path = "$PSScriptRoot\SnipeitPS"
|
||||
)
|
||||
|
||||
$results = Invoke-Pester -PassThru
|
||||
if($results.FailedCount -gt 0) {
|
||||
Write-Output " > $($results.FailedCount) tests failed. The build cannot continue."
|
||||
foreach($result in $($results.TestResult | Where {$_.Passed -eq $false} | Select-Object -Property Describe,Context,Name,Passed,Time)){
|
||||
Write-Output " > $result"
|
||||
}
|
||||
|
||||
EXIT 1
|
||||
}
|
||||
}
|
||||
|
||||
foreach($task in $Tasks){
|
||||
switch($task)
|
||||
{
|
||||
"test" {
|
||||
Install-Dependency -Name "PSScriptAnalyzer"
|
||||
Install-Dependency -Name "Pester"
|
||||
Write-Output "Running Pester Tests..."
|
||||
Run-Tests
|
||||
}
|
||||
"release" {
|
||||
Register-PSRepository -Name InternalPowerShellModules `
|
||||
-SourceLocation http://192.168.1.155:81/nuget/DIPowerShell `
|
||||
-PackageManagementProvider NuGet `
|
||||
-PublishLocation http://192.168.1.155:81/nuget/DIPowerShell `
|
||||
-InstallationPolicy Trusted
|
||||
|
||||
Write-Output "Registerting Module"
|
||||
|
||||
Import-Module $env:CI_PROJECT_PATH\SnipeitPS\SnipeitPS.psd1 -ErrorAction Stop
|
||||
Publish-Module -Name SnipeitPS -Repository InternalPowerShellModules -NuGetApiKey 123456789
|
||||
}
|
||||
}
|
||||
}
|
||||
73
docs/Get-Asset.md
Normal file
73
docs/Get-Asset.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-Asset
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Assets
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-Asset [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-Asset -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-Asset -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "MyMachine" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
73
docs/Get-Category.md
Normal file
73
docs/Get-Category.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-Category
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Categories
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-Category [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-Category -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-Category -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Laptop" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
73
docs/Get-Component.md
Normal file
73
docs/Get-Component.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-Component
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Components
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-Component [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-Component -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-Component -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Memory" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
73
docs/Get-Manufacturer.md
Normal file
73
docs/Get-Manufacturer.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-Manufacturer
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Manufacturers
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-Manufacturer [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-Manufacturer -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-Manufacturer -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "HP" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
73
docs/Get-Model.md
Normal file
73
docs/Get-Model.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-Model
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Models
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-Model [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-Models -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-Models -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "DL380" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
73
docs/Get-Status.md
Normal file
73
docs/Get-Status.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-Status
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Status Labels
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-Status [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-Status -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-Status -url "https://assets.example.com" -token "token..." | Where-Object {$_.name -eq "Ready to Deploy" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
73
docs/Get-User.md
Normal file
73
docs/Get-User.md
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Get-User
|
||||
|
||||
## SYNOPSIS
|
||||
# Gets a list of Snipe-it Users
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Get-User [-url] <String> [-apiKey] <String>
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Get-User -url "https://assets.example.com" -token "token..."
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Get-User -url "https://assets.example.com" -token "token..." | Where-Object {$_.username -eq "stephenm" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
180
docs/New-Asset.md
Normal file
180
docs/New-Asset.md
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-Asset
|
||||
|
||||
## SYNOPSIS
|
||||
Add a new Asset to Snipe-it asset system
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
New-Asset [[-tag] <String>] [-Name] <String> [-Status_id] <String> [-Model_id] <String> [-url] <String>
|
||||
[-apiKey] <String> [[-customfields] <Hashtable>] [-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Long description
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
New-Asset -status_id 1 -model_id 1 -name "Machine1"
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
New-Asset -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -tag
|
||||
Asset Tag for the Asset
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Name
|
||||
Name of the Asset
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 4
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 5
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 6
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -customfields
|
||||
Hastable of custom fields and extra fields that need passing through to Snipeit
|
||||
|
||||
```yaml
|
||||
Type: Hashtable
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 7
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
146
docs/New-Component.md
Normal file
146
docs/New-Component.md
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-Component
|
||||
|
||||
## SYNOPSIS
|
||||
Short description
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
New-Component [-name] <String> [-category_id] <String> [-qty] <String> [-url] <String> [-apiKey] <String>
|
||||
[-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Long description
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
An example
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -name
|
||||
Parameter description
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -category_id
|
||||
Parameter description
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -qty
|
||||
Parameter description
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
Parameter description
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 4
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Parameter description
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 5
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
General notes
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
114
docs/New-Manufacturer.md
Normal file
114
docs/New-Manufacturer.md
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-Manufacturer
|
||||
|
||||
## SYNOPSIS
|
||||
Add a new Manufacturer to Snipe-it asset system
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
New-Manufacturer [-Name] <String> [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Long description
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
New-Manufacturer -name "HP"
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Name
|
||||
Name of the Manufacturer
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
160
docs/New-Model.md
Normal file
160
docs/New-Model.md
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# New-Model
|
||||
|
||||
## SYNOPSIS
|
||||
Add a new Model to Snipe-it asset system
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
New-Model [-name] <String> [-category_id] <Int32> [-manufacturer_id] <Int32> [-fieldset_id] <Int32>
|
||||
[-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Long description
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
New-Model -name "DL380" -manufacturer_id 2 -fieldset_id 2 -category_id 1
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -name
|
||||
Name of the Asset Model
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -category_id
|
||||
Category ID that the asset belongs to this can be got using Get-Category
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -manufacturer_id
|
||||
Manufacturer ID that the asset belongs to this can be got using Get-Manufacturer
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -fieldset_id
|
||||
Fieldset ID that the asset uses (Custom fields)
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 4
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 5
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 6
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
180
docs/Set-Asset.md
Normal file
180
docs/Set-Asset.md
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Set-Asset
|
||||
|
||||
## SYNOPSIS
|
||||
Update a Asset in the Snipe-it asset system
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Set-Asset [-id] <Int32> [-Name] <String> [-Status_id] <String> [-Model_id] <String> [-url] <String>
|
||||
[-apiKey] <String> [[-customfields] <Hashtable>] [-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
Long description
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### -------------------------- EXAMPLE 1 --------------------------
|
||||
```
|
||||
Set-Asset -id 1 -status_id 1 -model_id 1 -name "Machine1"
|
||||
```
|
||||
|
||||
### -------------------------- EXAMPLE 2 --------------------------
|
||||
```
|
||||
Set-Asset -id 1 -status_id 1 -model_id 1 -name "Machine1" -CustomValues = @{ "_snipeit_os_5 = "Windows 10 Pro" }
|
||||
```
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -id
|
||||
ID of the Asset
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: 0
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Name
|
||||
Name of the Asset
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Status_id
|
||||
Status ID of the asset, this can be got using Get-Status
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Model_id
|
||||
Model ID of the asset, this can be got using Get-Model
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 4
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
URL of Snipeit system, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 5
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
Users API Key for Snipeit, can be set using Set-Info command
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 6
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -customfields
|
||||
Hastable of custom fields and extra fields that need passing through to Snipeit
|
||||
|
||||
```yaml
|
||||
Type: Hashtable
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 7
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
136
docs/Set-AssetOwner.md
Normal file
136
docs/Set-AssetOwner.md
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Set-AssetOwner
|
||||
|
||||
## SYNOPSIS
|
||||
{{Fill in the Synopsis}}
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Set-AssetOwner [-id] <Int32> [-user_id] <Int32> [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### Example 1
|
||||
```
|
||||
PS C:\> {{ Add example code here }}
|
||||
```
|
||||
|
||||
{{ Add example description here }}
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
{{Fill apiKey Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -id
|
||||
{{Fill id Description}}
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 0
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
{{Fill url Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -user_id
|
||||
{{Fill user_id Description}}
|
||||
|
||||
```yaml
|
||||
Type: Int32
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
### None
|
||||
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
### System.Object
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
136
docs/Set-Component.md
Normal file
136
docs/Set-Component.md
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Set-Component
|
||||
|
||||
## SYNOPSIS
|
||||
{{Fill in the Synopsis}}
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Set-Component [-id] <String> [-qty] <String> [-url] <String> [-apiKey] <String> [-WhatIf] [-Confirm]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### Example 1
|
||||
```
|
||||
PS C:\> {{ Add example code here }}
|
||||
```
|
||||
|
||||
{{ Add example description here }}
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -Confirm
|
||||
Prompts you for confirmation before running the cmdlet.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: cf
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -WhatIf
|
||||
Shows what would happen if the cmdlet runs.
|
||||
The cmdlet is not run.
|
||||
|
||||
```yaml
|
||||
Type: SwitchParameter
|
||||
Parameter Sets: (All)
|
||||
Aliases: wi
|
||||
|
||||
Required: False
|
||||
Position: Named
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -apiKey
|
||||
{{Fill apiKey Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 3
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -id
|
||||
{{Fill id Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 0
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -qty
|
||||
{{Fill qty Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
{{Fill url Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: True
|
||||
Position: 2
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
### None
|
||||
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
### System.Object
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
75
docs/Set-Info.md
Normal file
75
docs/Set-Info.md
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
---
|
||||
external help file: SnipeItPS-help.xml
|
||||
Module Name: SnipeItPS
|
||||
online version:
|
||||
schema: 2.0.0
|
||||
---
|
||||
|
||||
# Set-Info
|
||||
|
||||
## SYNOPSIS
|
||||
{{Fill in the Synopsis}}
|
||||
|
||||
## SYNTAX
|
||||
|
||||
```
|
||||
Set-Info [[-url] <Uri>] [[-apiKey] <String>]
|
||||
```
|
||||
|
||||
## DESCRIPTION
|
||||
{{Fill in the Description}}
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
### Example 1
|
||||
```
|
||||
PS C:\> {{ Add example code here }}
|
||||
```
|
||||
|
||||
{{ Add example description here }}
|
||||
|
||||
## PARAMETERS
|
||||
|
||||
### -apiKey
|
||||
{{Fill apiKey Description}}
|
||||
|
||||
```yaml
|
||||
Type: String
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 1
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
### -url
|
||||
{{Fill url Description}}
|
||||
|
||||
```yaml
|
||||
Type: Uri
|
||||
Parameter Sets: (All)
|
||||
Aliases:
|
||||
|
||||
Required: False
|
||||
Position: 0
|
||||
Default value: None
|
||||
Accept pipeline input: False
|
||||
Accept wildcard characters: False
|
||||
```
|
||||
|
||||
## INPUTS
|
||||
|
||||
### None
|
||||
|
||||
|
||||
## OUTPUTS
|
||||
|
||||
### System.Object
|
||||
|
||||
## NOTES
|
||||
|
||||
## RELATED LINKS
|
||||
|
||||
Loading…
Add table
Reference in a new issue