AdhocAdam / smletsexchangeconnector

SMLets PowerShell based Exchange Connector for controlling Microsoft System Center Service Manager 2016+
https://adhocadam.github.io/smletsexchangeconnector/
GNU General Public License v3.0
29 stars 19 forks source link

New-CMDBUser: Check for existing user & improved logging #462

Closed alexaxb closed 1 year ago

alexaxb commented 1 year ago

Describe the change
Provide an explanation of the changes being made and why you want to make them New-CMDBUser is called when an e-mail address cannot be found in SCSM, but if the username/domain combo already exists in SCSM but without the mail address the user creation will fail without an error message. This has happened to me a couple of times now, and is kind of hard to detect. Added a simple check to see if the user object already exists before creation, and if the creation should fail for some reason, it will be logged as an error.

AdhocAdam commented 1 year ago

Two things:

alexaxb commented 1 year ago

Hmm.. $startTime was not intentional, so I've removed it now. Probably a leftover from dev testing.

A plan B if we don't won't to update the user automatically, could be that we simply create a tailored error message for this scenario when it happens, so it's clear in the log why the connector stops importing new mail when it occurs.

AdhocAdam commented 1 year ago

Cherry picked the commit to maintain a cleaner history while still ensuring you're given proper credit. Closing this PR and moving over to #470