SnipeitPS
SnipeitPS copied to clipboard
Forbidden: New-SnipeItAsset
Context
I'm trying to create a PowerShell script that will run on multiple different clients machines using different "Automation" accounts that have API keys associated with them. Each client having their own automation account for now. It is important to have separate accounts for this so we can limit the read/write scope of each account to their allocated client. This script gathers local device information and uses the SnipeitPS module to push this data into the relevant areas of SnipeIt.
I've given the automation account everything except Super Admin and the command fails. As soon as I give it SuperAdmin the New-SnipeItAsset command works. If I run the command with the -verbose parameter I get the following output.
It's worth mentioning that I am able to run the Set-SnipeItAsset command on an existing asset to update the fields with the limited permissions I've set and it works fine. The error only occurs on new assets.
IsMutuallyAuthenticated : False Cookies : {snipeit_session=OBFUSCATED} Headers : {Pragma, Vary, X-RateLimit-Limit, X-RateLimit-Remaining...} SupportsHeaders : True ContentLength : 49 ContentEncoding : ContentType : application/json CharacterSet : Server : Microsoft-IIS/10.0 LastModified : 06/02/2024 15:23:08 StatusCode : Forbidden StatusDescription : Forbidden ProtocolVersion : 1.1 ResponseUri : https://OBFUSCATED/api/v1/hardware Method : POST IsFromCache : False
Your Environment
- SnipitPS Module version used: 1.10.227
- Operating System and PowerShell version: Windows 10 Powershell 5.1.22621
- Snipe It version: 6.3.0
Expected Behavior
Run New-SnipeItAsset and it creates the asset.
Current Behavior
New-SnipeitAsset -status_id 6 -warranty_months $deviceDetails.warranty_months -name $deviceDetails.name -model_id $onlineModel.id -serial $deviceDetails.serial -notes $deviceDetails.notes -ErrorAction Stop -Verbose -Debug
DEBUG: Invoke-SnipeitMethod url: https://OBFUSCATED DEBUG: { "status_id": 6, "checkout_to_type": "user", "notes": "--- System Specifications ---\r\n\r\nCPU\r\n----------\r\n12th Gen Intel(R) Core(TM) i7-12700H\r\n\r\nRAM\r\n----------\r\n40 GB\r\n\r\nStorage\r\n----------\r\nPC SN740 NVMe WD 512GB | 477GB", "name": "USER-LPT07", "model_id": 74, "ErrorAction": 1, "serial": "OBFUSCATED", "warranty_months": 36 } VERBOSE: [Invoke-SnipeitMethod] Invoking method Post to URI DEBUG: [Invoke-SnipeitMethod] Invoke-WebRequest with: Name Value
Method Post
UseBasicParsing True
Uri https://OBFUSCATED/api/v1/hardware
Headers {Authorization, Content-Type, Accept}
Body {123, 13, 10, 32...}
ErrorAction SilentlyContinue
VERBOSE: POST with -1-byte payload VERBOSE: [Invoke-SnipeitMethod] Failed to get an answer from the server DEBUG: [Invoke-SnipeitMethod] Executed WebRequest. Access System.Net.HttpWebResponse to see details VERBOSE: [Invoke-SnipeitMethod] Status code: Forbidden VERBOSE: System.Net.HttpWebResponse VERBOSE: Status: VERBOSE: Messages: VERBOSE: [Invoke-SnipeitMethod] Function ended
IsMutuallyAuthenticated : False Cookies : {snipeit_session=OBFUSCATED} Headers : {Pragma, Vary, X-RateLimit-Limit, X-RateLimit-Remaining...} SupportsHeaders : True ContentLength : 49 ContentEncoding : ContentType : application/json CharacterSet : Server : Microsoft-IIS/10.0 LastModified : 06/02/2024 15:31:36 StatusCode : Forbidden StatusDescription : Forbidden ProtocolVersion : 1.1 ResponseUri : https://OBFUSCATED/api/v1/hardware Method : POST IsFromCache : False
Possible Solution
N/A
Steps to Reproduce (for bugs)
- Run command New-SnipeItAsset with required parameters.