Adding powershell requirements to individual command list documentation (Idea?) #7060
Replies: 2 comments 2 replies
-
on the SQL side of things the module doesn't enforce checking for particular permissions (except a small bunch). it's expected that you have enough permissions to do what's needed, and usually the error message will tell you clearly that you lack some permission. As for "local admin": usually they're tied to commands operating on servers rather than sql instances, and it's totally dependant on your setup (like GPO, secpol, registry et similia). Documenting what's needed in that particular case would be cumbersome, as there are dozens of involved variables. |
Beta Was this translation helpful? Give feedback.
-
We had discussed updating the help docs a long time ago (way before we got to 500+ commands 😁 ) on providing some link or detail on the permissions. Overall the issue with doing this (and maintaining it) is that SMO documentation does not include the section Permissions like T-SQL documentation does. SMO itself could be calling 2 views or 5 system procedures. There was no feasible way for us to detect all of that and maintain it as SMO updates. All in all though if you take a given command and determine the base action it will take via T-SQL then you can have a quick start method of what least-privilege is required. A few examples:
You can see just from these two if you trace them on a given instance that n+ number of system views, functions, or procedures get called by SMO. The most efficient method is to simply run them on a test instance and start collecting the permission errors. We do offer a command that can assist with this: Get-DbatoolsLog |
Beta Was this translation helpful? Give feedback.
-
This may be more my exposure thus far to powershell in combination with trying to apply the principals of minimal access first. I'll be the first to disclose my powershell script-fu is not as strong as I'd like it to be.
I have a couple of scheduled powershell scripts that connect to various SQL servers. I've come to notice that some powershell scripts run fine, while others require an elevated permission (such as local admin).
It would be great if there was additional documentation on minimal permissions required to run each of the powershell scripts available in dbatools.
Alternatively, opening it up more so to discussion:
If this is transparent to someone more versed in powershell or dbatools that this is more so a knowledge gap in powershell and you believe updating the documentation isn't needed:
I'd appreciate any feedback and links to documentation on PS you may have to share so that I may bridge the knowledge gap. I've found that because dbatools is open source, that it's an amazing resource and I'd like to contribute where I can if possible.
Beta Was this translation helpful? Give feedback.
All reactions