Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Grant-DbaAgPermission doesn't perform GRANT #5889

Closed
1 of 4 tasks
JanK-Orb opened this issue Jul 10, 2019 · 5 comments
Closed
1 of 4 tasks

[Bug] Grant-DbaAgPermission doesn't perform GRANT #5889

JanK-Orb opened this issue Jul 10, 2019 · 5 comments
Labels
bugs life stale Stale Bot label used to identify issues that are no longer active and bot has closed them

Comments

@JanK-Orb
Copy link

JanK-Orb commented Jul 10, 2019

Environmental information

#### PowerShell version

Name                           Value                                                                                                                                                          
----                           -----                                                                                                                                                          
PSVersion                      5.1.17763.503                                                                                                                                                  
PSEdition                      Desktop                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                        
BuildVersion                   10.0.17763.503                                                                                                                                                 
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.9\dbatools.psd1
Version : 1.0.9

SQL Server:

Microsoft SQL Server 2017 (RTM-CU15) (KB4498951) - 14.0.3162.1 (X64)   May 15 2019 19:14:30   Copyright (C) 2017 Microsoft Corporation  Enterprise Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) 

Report

A bug:
line 114 : if ($perm -contains "CreateAnyDatabase") {
At this point $perm is undefined, parameter should be named $Permission

Could also consider changing the ALTER statement by wrapping the $ag parameter with [] to allow non-alphanumeric characters in AG names.
ALTER AVAILABILITY GROUP [$ag] GRANT CREATE ANY DATABASE

Host used

  • 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

Actually, a lack of error is one way to observe the issue. (Though the command does not currently execute the Grant at all as it exits the if at line 114)

Steps to Reproduce

Execute Grant-DbaAgPermission with a -SqlInstance that doesn't exist.

Grant-DbaAgPermission -SqlInstance foo -Type AvailabilityGroup -AvailabilityGroup myAg -Permission CreateAnyDatabase

Also, executing the command with a real -SqlInstance doesn't actually execute the GRANT

Expected Behavior

When executing with a wrong -SqlInstance , an error message : "Error occurred while establishing connection to ..."

When executing with a correct -SqlInstance, a GRANT is executed.

Actual Behavior

GRANT isn't executed with a correct SqlInstance
No error when wrong SqlInstance is specified

@JanK-Orb
Copy link
Author

Please note that once this issue is fixed, we'll no longer enter our elseif ($Login) at line 129, and we'll not populate $InputObject with the list of accounts passed in. That means the entire section starting at line 144, foreach ($account in $InputObject) { will no longer execute.

@JanK-Orb JanK-Orb changed the title [Bug] Grant-DbaAgPermission doesn't perform GRANT Jul 10, 2019
@JanK-Orb JanK-Orb changed the title Grant-DbaAgPermission doesn't perform GRANT [Bug] Grant-DbaAgPermission doesn't perform GRANT Jul 10, 2019
@potatoqualitee
Copy link
Member

Thanks for the report, @JanK-Orb ! Any chance you would be able to fix this issue? I will not have time until at least next week.

@stale
Copy link

stale bot commented Sep 30, 2019

This issue has been automatically marked as stale because it has not had recent activity. If you would like this issue to remain open:

  • Verify that you can still reproduce the issue in the latest version of dbatools
  • Comment that the issue is still reproducible and include:
    • What version of dbatools you reproduced the issue on
    • What OS and version you reproduced the issue on
    • What steps you followed to reproduce the issue

@stale stale bot added the stale Stale Bot label used to identify issues that are no longer active and bot has closed them label Sep 30, 2019
@stale
Copy link

stale bot commented Oct 30, 2019

This issue has been automatically closed because it has not had activity in the last three months. If this issue is still valid, please add a comment

@stale stale bot closed this as completed Oct 30, 2019
@lowlydba
Copy link
Contributor

lowlydba commented Mar 17, 2021

shakes fist at stale bot

This is very much still a bug :(

I'm happy to make the quick-fix.

Would ya'll like/need additional tests around this? If so, I may not have the bandwidth to go that deep for a few weeks.

@potatoqualitee - @'ing since stale bot doesn't seem like it wants to re-open after my comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs life stale Stale Bot label used to identify issues that are no longer active and bot has closed them
Projects
None yet
Development

No branches or pull requests

3 participants