From 96dc4e09079613b30a4d91ff74977747b2416cf9 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 3 Sep 2021 15:54:36 +0300 Subject: [PATCH 1/2] update readme --- CHANGELOG.md | 18 ++++++++++++++++++ README.md | 18 ++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2abdaf..47069fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ 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/). +# [v.1.10.x] - 2021-09-03 + +## New secure ways to connect Snipe it + +### -secureApiKey allow pass apiKey as SecureString +Connect-SnipeitPS -URL 'https://asset.example.com' -secureApiKey 'tokenKey' + +### Set connection with safely saved credentials, first save credentials +$SnipeCred= Get-Credential -message "Use url as username and apikey as password" +$SnipeCred | Export-CliXml snipecred.xml + +### ..then use your saved credentials like +Connect-SnipeitPS -siteCred (Import-CliXml snipecred.xml) + +## Fix for content encoding in invoke-snipeitmethod +Version 1.9 introduced bug that converted non ascii characters to ascii +during request. + # [v.1.9.x] - 2021-07-14 ## Image uploads diff --git a/README.md b/README.md index 294f257..7d18afd 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,23 @@ Install-Module SnipeitPS # Check for updates occasionally: Update-Module SnipeitPS -# To use each session: +# import module to session: Import-Module SnipeitPS -Set-SnipeitInfo -URL 'https://asset.example.com' -apiKey 'tokenKey' + +# Set connection +Connect-SnipeitPS -URL 'https://asset.example.com' -apiKey 'tokenKey' + +# Or set connection with safely saved credentials, first save credentials +$SnipeCred =Get-Credential -message "Use url as username and apikey as password" +$SnipeCred | Export-CliXml snipecred.xml + +# ..then use your saved credentials like +Connect-SnipeitPS -siteCred (Import-CliXml snipecred.xml) + +# OR use -secureApiKey that allow pass apiKey as SecureString +# if you are usin Microsoft.PowerShell.SecretManagement or like +Connect-SnipeitPS -URL 'https://asset.example.com' -secureApiKey 'tokenKey' + ``` ### Usage From 8c79c0fe6dd7407c3db1da6411de785f22de2084 Mon Sep 17 00:00:00 2001 From: Petri Asikainen Date: Fri, 3 Sep 2021 15:54:55 +0300 Subject: [PATCH 2/2] fix content encoding --- SnipeitPS/Private/Invoke-SnipeitMethod.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 index 075a41a..96ecc3c 100644 --- a/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 +++ b/SnipeitPS/Private/Invoke-SnipeitMethod.ps1 @@ -79,7 +79,7 @@ } if ($Body -and $splatParameters.Keys -notcontains 'Form') { - $splatParameters["Body"] = $Body | Convertto-Json + $splatParameters["Body"] = [System.Text.Encoding]::UTF8.GetBytes(($Body | Convertto-Json)) } $script:PSDefaultParameterValues = $global:PSDefaultParameterValues