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
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