mattcarras / snipeitsyncps Goto Github PK
View Code? Open in Web Editor NEWUser and asset syncing solution in PowerShell utilizing Snipe-It's REST API.
License: MIT License
User and asset syncing solution in PowerShell utilizing Snipe-It's REST API.
License: MIT License
I'm using Sync-ADUsers.ps1 without any changes outside of the 'configuration' options, and am seeing strange behaviour.
The script seems to find a department or company but then goes on to try and create it anyway, obviously failing
.\Sync-ADUsers.ps1 -EmailDeletedUsersReport
Transcript started, output file is .\Logs\snipeit-ad-sync_2023-11-16.log
VERBOSE: [2023/11/16 11:55:21] Connecting to Snipe-It instance at []
VERBOSE: [Get-SnipeItEntityAll] Collecting all existing [users] from Snipe-It...
VERBOSE: [Get-SnipeItEntityAll] Got back 315 results for [users]
VERBOSE: [Get-SnipeItEntityAll] Collecting all existing [companies] from Snipe-It...
VERBOSE: [Get-SnipeItEntityAll] Got back 4 results for [companies]
VERBOSE: [Get-SnipeItEntityAll] Collecting all existing [departments] from Snipe-It...
VERBOSE: [Get-SnipeItEntityAll] Got back 54 results for [departments]
VERBOSE: [Get-ADUsersByGroup] Collecting all users from AD group [] (Nested=True, With FilterMap=False)...
VERBOSE: [Get-ADUsersByGroup] Getting properties for 215 users...
VERBOSE: [Get-ADUsersByGroup] Total filtered AD users collected: 215
VERBOSE: [Get-ADUsersByGroup] Collecting all users from AD group [] (Nested=True, With FilterMap=False)...
VERBOSE: [Get-ADUsersByGroup] Getting properties for 63 users...
VERBOSE: [Get-ADUsersByGroup] Total filtered AD users collected: 63
[2023/11/16 11:55:53] Formatting users...
[2023/11/16 11:55:55] Starting sync...
VERBOSE: [Sync-SnipeItUser] Processing user [] with employee_num [***]
Write-Error: ***\Documents\PowerShell\Modules\SnipeitPS\1.10.227\Public\New-SnipeitCompany.ps1:68:23
Line |
68 | $result = Invoke-SnipeitMethod @parameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| name ---- {The name has already been taken.}
Sync-SnipeItUser: \Sync-ADUsers.ps1:428:24
Line |
428 | … $sp_user = Sync-SnipeItUser -User $user -Verbose @extraParams
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| [Get-SnipeItEntityByName] Fatal ERROR creating new snipeit companies with name []! Returned entity has invalid ID
Sync-SnipeItUser: \Sync-ADUsers.ps1:428:24
Line |
428 | … $sp_user = Sync-SnipeItUser -User $user -Verbose @extraParams
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| [Get-SnipeItEntityByName] Fatal ERROR creating new snipeit departments with name []! Returned entity has invalid ID
I tried to use the functions to mimic the behaviour and have been successful:
Get-SnipeItDepartment | ?{$_.Name -eq "IT"}
id : 88
name : IT
phone :
fax :
image :
company :
manager :
location :
users_count : 0
created_at : @{datetime=2023-11-16 12:17:57; formatted=2023-11-16 12:17 PM}
updated_at : @{datetime=2023-11-16 12:17:57; formatted=2023-11-16 12:17 PM}
available_actions : @{update=True; delete=True}
Get-SnipeItDepartmentByName -Name "IT"
OperationStopped: ...\Snipeit-Sync-PS.ps1:1030:21
Line |
1030 | … Throw [System.Net.WebException] ("[Get-SnipeItEntityByNam …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| [Get-SnipeItEntityByName] Fatal ERROR creating new snipeit departments with name [IT]! Returned entity has invalid ID
It is mentioned about using Export-SnipeItCredentials function, but not where we can get this function from?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.