It seems Get-PWUsersByMatch always returns "LastLogin" no matter if the switch is set to True or False. If I don't provide the switch it should default be set to False, but "LastLogin" is still returned making the query very slow. Is there a way to turn the switch off?PW server: 10.00.03.280
PW Explorer: 10.00.03.334
PWPW_DAB version: 184.108.40.206
Can you post the command line you're using?
I have tried:
All examples returns same result including LastLogin information - first and last example should not return LastLogin information.
I just looked at the code and verified that the parameter -LastLogin is indeed no longer used but it wasn't removed from the Cmdlet or noted in the documentation. We tend not to "remove" things so that users' existing scripts don't "break", but we should have documented that this parameter is now ignored, etc.
Sorry about that!
I'll put this on the list of "fixes", i.e. document the change in the help. For now, it doesn't "hurt" anything other than the obvious, wasting folks time trying to figure out if they should use it or not.
As for performance, the ProjectWise API function that is selecting the user properties is aaApi_SelectUserWithLoginDataBuffer() and that can be much slower than just selecting the user properties without any login data. You might be able to improve performance if you can remove some of the user information "Keep records for..." from your audit trail settings.
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
Hi Dan. Thanks a lot for confirming the behavior. Yes, then it is down to Audit Trail discussions.
To avoid performance issues the switch actually makes perfect sense. Since LastLogin details are still saved in and queried from the Audit Trail table, we are down to Audit Trail table performance and how the table is tweaked, cleaned up, custom indexes, secondary table etc.
What is the reason to always include LastLogin details now and not give the user the option to decide? Are there another cmdlet that can be used to get all PW Users without LastLogin?
I don't know why the option to specify to include the last login details was "removed".
I don't know of any other Cmdlets that will allow you to select "all PW Users without LastLogin". You could get a list of users in specific groups or user lists, but if a user isn't in a group or a userlist, then I don't see a way. GetPWUsersInGroup Get-PWUserInUserList do not populate the LastLogin property.
Thanks Dan for the reply. I have also investigated the two options you mentioned - besides a user not being in a group/list, a user could also be in multiple groups/lists.
What I am trying to achieve is actually very simple - looping through all users every night and update the Identity to the User-email. Only problem is the performance of Get-PWUsersByMatch. I might end up using the SDK instead.
Who would be able to share some light on why the option "LastLogin" has been deprecated in PWPS_DAB - Dave Brumbaugh? And where do we raise an enhancement request - in the Communities?
Morten Bjerre Stougaard, I ran this by Dave Brumbaugh and his best guess is that when this Cmdlet was refactored to use a different API function, the -LastLogin logic wasn't considered. Dave has already fixed this oversight and the fix should be in the next release of PWPS_DAB.
Answer Verified By: Morten Bjerre Stougaard
Great. Thanks a lot Dan for following up on this.
Thanks for the upcoming fix Dan/Dave! By the way, adjusting the User Audit Trail Settings to archive to the secondary table causes it to archive all the user setting audits, not just login/logoff so need to watch out for that side-effect. Fortunately somebody wrote this neat PowerShell cmdlet that just moves the login/logoff entries:
Moves user login/logout audit trail entries from the primary audit trail table to the secondary.
Move-PWLogInOutAuditTrailRecords [[-StartDate] <string>] [[-EndDate] <string>] [<CommonParameters>]
(our solution was a bit more drastic introduced years ago -- database routine to automatically delete all login/logoff entries over a certain age, before even automatic moving comes into play)