Theldron Posted January 25, 2024 Posted January 25, 2024 Hi all, Hope you are well. I was wondering has anyone setup SnipeIT automated inventory using the API? There is a SnipeIT powershell wrapper for the API, has anyone tried this? Thanks
mavhc Posted January 25, 2024 Posted January 25, 2024 My version, that I changed from someone else's is: https://gist.github.com/mavhc/dda09504a91f5007d4202e0f7ea4c5b0
Theldron Posted January 25, 2024 Author Posted January 25, 2024 You're a star thanks so much. Sorry not much of a programmer, quick question if you don't mind. I notice that the script check the existence of the assets by the asset tag, which is the device serial number, as we put barcodes of 5 digit numbers as asset tags, so it wouldn't be the serial number. Is there a way to change the check to the serial number? Again sorry for basic question.
Theldron Posted January 25, 2024 Author Posted January 25, 2024 Sorry, I am getting this when it tries to connect to the SnipeIT Website. Any ideas? Invoke-SnipeitMethod : Cannot connect to Snipe It: Unauthorized. At C:\Program Files\WindowsPowerShell\Modules\SnipeitPS\1.10.227\Private\Test-SnipeitPSConnection.ps1:10 char:16 + $contest = Invoke-SnipeitMethod @Parameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-SnipeitMethod Cannot verify connection to snipe it. For the start try to check url and provided apikey or credential parameters At C:\Program Files\WindowsPowerShell\Modules\SnipeitPS\1.10.227\Public\Connect-SnipeitPS.ps1:146 char:13 + throw "Cannot verify connection to snipe it. For the star ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Cannot verify c...tial parameters:String) [], RuntimeException + FullyQualifiedErrorId : Cannot verify connection to snipe it. For the start try to check url and provided apikey or credential parameters
Theldron Posted January 25, 2024 Author Posted January 25, 2024 Sorry, I am getting this when it tries to connect to the SnipeIT Website. Any ideas? Invoke-SnipeitMethod : Cannot connect to Snipe It: Unauthorized. At C:\Program Files\WindowsPowerShell\Modules\SnipeitPS\1.10.227\Private\Test-SnipeitPSConnection.ps1:10 char:16 + $contest = Invoke-SnipeitMethod @Parameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-SnipeitMethod Cannot verify connection to snipe it. For the start try to check url and provided apikey or credential parameters At C:\Program Files\WindowsPowerShell\Modules\SnipeitPS\1.10.227\Public\Connect-SnipeitPS.ps1:146 char:13 + throw "Cannot verify connection to snipe it. For the star ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Cannot verify c...tial parameters:String) [], RuntimeException + FullyQualifiedErrorId : Cannot verify connection to snipe it. For the start try to check url and provided apikey or credential parameters Sorry I obviously don't know the difference between APP key and API key.
Theldron Posted January 25, 2024 Author Posted January 25, 2024 You're a star thanks so much. Sorry not much of a programmer, quick question if you don't mind. I notice that the script check the existence of the assets by the asset tag, which is the device serial number, as we put barcodes of 5 digit numbers as asset tags, so it wouldn't be the serial number. Is there a way to change the check to the serial number? Again sorry for basic question. Ignore I have managed to sort this as well. AssetTag is a required field, so I added it so that both assettag and serialnumber get populated with the same thing, then I can manually edit the assettag. Not great but better than it could have been, so thanks so much for passing this on.
mavhc Posted February 1, 2024 Posted February 1, 2024 I guess so, seems like it's not actually storing them here
kesmatt Posted February 5, 2024 Posted February 5, 2024 Hi all, I just stumbled across this thread and thought I would give it a try in our environment as we have snipe-it setup. I can get it to connect using the url and the apikey but I keep getting the following error any ideas or did you come across this? Get detailsInvoke-SnipeitMethod : manufacturer_id --------------- {The selected manufacturer id is invalid.}At C:\Program Files\WindowsPowerShell\Modules\SnipeitPS\1.10.227\Public\New-SnipeitModel.ps1:102 char:23+ $result = Invoke-SnipeitMethod @Parameters+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-SnipeitMethod Admittedly my knowledge is pretty basic, but I am working my way through it, it says WriteError soi I was thinking permissions but where?
mavhc Posted February 5, 2024 Posted February 5, 2024 You'll need to create the manufacturers in snipe-it iirc
kesmatt Posted February 6, 2024 Posted February 6, 2024 I think that's the bit I am struggling with, we have lots of manufacturers already created, I dont seem to be able to match them up. At a minimum I would like to be able to pull OS information and then update that into Snipe!
mavhc Posted February 6, 2024 Posted February 6, 2024 Do they match exactly? If not add some lines to the script to rewrite them, or add the exact matches
kesmatt Posted February 6, 2024 Posted February 6, 2024 Thanks, I will double check the manufacturers, although I have a sneeky suspision I am going down the wrong route and it might be easier to try and start again and uncomplicate things.
Theldron Posted February 21, 2024 Author Posted February 21, 2024 Hi, Really odd, I have started to get this error. I assume it is something about the model numbers in SnipeIT? New-SnipeitAsset : Cannot process argument transformation on parameter 'model_id'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32". At C:\Program Files\SnipeIT\AssetInventory_SnipeIT.ps1:70 char:83 + ... Name -tag $assetTag -serial $serial -Model_id $modelSelection -Status ... + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: ( [New-SnipeitAsset], ParameterBindingArgumentTransformationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-SnipeitAsset
Theldron Posted February 21, 2024 Author Posted February 21, 2024 (edited) Hi, Really odd, I have started to get this error. I assume it is something about the model numbers in SnipeIT? New-SnipeitAsset : Cannot process argument transformation on parameter 'model_id'. Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Int32". At C:\Program Files\SnipeIT\AssetInventory_SnipeIT.ps1:70 char:83 + ... Name -tag $assetTag -serial $serial -Model_id $modelSelection -Status ... + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: ( [New-SnipeitAsset], ParameterBindingArgumentTransformationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,New-SnipeitAsset Ok ignore the previous post seemed to be an issue with the Asset Models. Now though each model is being created as a Monitor. Any ideas? - Found I just needed to change the category numbers...... I am going home. Edited February 21, 2024 by Theldron
Theldron Posted February 22, 2024 Author Posted February 22, 2024 I should have added comments! bad mavhc No not you mate, I appreciate your help, more muppet Theldron. Making things too complicated. Out of interest how do you deploy the script, it only seems to work for me when somebody is logged in?
mavhc Posted February 22, 2024 Posted February 22, 2024 No not you mate, I appreciate your help, more muppet Theldron. Making things too complicated. Out of interest how do you deploy the script, it only seems to work for me when somebody is logged in? gpo startup script, run as system user
Theldron Posted February 22, 2024 Author Posted February 22, 2024 Hmmmm.... doesn't seem to work for me that way for me. Mind you we are using Sophos firewall with AD sync, and with it downloading the API wrapper etc. It might be that.
Theldron Posted March 4, 2024 Author Posted March 4, 2024 Hi all, having another weird thing, with the automation script. Even though I manually entered the models for the devices, it is generating duplicate models but not linking anything to them. Problem is with the duplicate models, it is causing the script to error and not run. When I remove the duplicates and run the script manually it works, but then the duplicates get generated again and it stops working..... Any ideas?
adrian_tisca Posted April 7, 2025 Posted April 7, 2025 hi, I have an error regarding AssetId " AssetId is null or empty. Cannot update an asset" but asset id is autoincremental in DB. any idea? thank you!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now