dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Export-DbaUser not exporting users from version 1.0.91 onwards

Open NielsKok84 opened this issue 6 years ago • 4 comments

Environmental information

PowerShell version:

Name Value


PSVersion 5.1.17134.858
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.858
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

dbatools Module version:

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.97\dbatools.psd1 Version : 1.0.97

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.91\dbatools.psd1 Version : 1.0.91

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.90\dbatools.psd1 Version : 1.0.90

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.88\dbatools.psd1 Version : 1.0.88

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.77\dbatools.psd1 Version : 1.0.77

Name : dbatools Path : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.75\dbatools.psd1 Version : 1.0.75

SQL Server:

Microsoft SQL Server 2016 (SP2-CU11) (KB4527378) - 13.0.5598.27 (X64) Nov 27 2019 18:09:22 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: ) (Hypervisor)

Report

From version 1.0.91 onwards we are getting an empty file when using the Export-DbaUser function. It seems the issue is because of this 'if' statement: " if (@($perms.Count) -gt 0)" (row 441). Think it should be "if ($NULL -ne $perms -or @($perms.Count) -gt 0)".

Host used

  • [X ] powershell.exe
  • [ ] ISE
  • [ ] VS Code
  • [ ] Other (please specify)

If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe

  • [ X] Still buggy in powershell.exe

Errors Received

None.

Steps to Reproduce

Create a simple database add an user with e.g. db_owner permission. Execute the 'Export-DbaUser' command, e.g: Export-DbaUser -SqlInstance MySqlInstance -Database Dummy -FilePath "e:\temp\users.sql"

Expected Behavior

Export of all users as in e.g. version 1.0.90.

Actual Behavior

Empty file

NielsKok84 avatar Feb 20 '20 12:02 NielsKok84

#6424

wsmelton avatar Mar 18 '20 13:03 wsmelton

Seeing the re-open with the new issue here. That one didn't look different, I think it's just the fix wasn't out in the published version yet.

sequeltom avatar Mar 19 '20 14:03 sequeltom

Ah, dang...yeah I see now we have not done a release in an extremely long time.

wsmelton avatar Mar 19 '20 14:03 wsmelton

Hello I confirmed the version [1.0.102] fixed this issue and the export of [Export-DbaUser] is working accordingly. Thank you!

ghost avatar Mar 20 '20 09:03 ghost