dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.48k stars 803 forks source link

Harmonize the description of the parameter SqlInstance #9396

Open andreasjordan opened 5 months ago

andreasjordan commented 5 months ago

After harmonizing the description of the parameter EnableException with #9395 I would like to work on SqlInstance

I have used this code to get the data for some of the parameters at once:

Import-Module -Name dbatools
$commands = Get-Command -Module dbatools -CommandType Function
$data = foreach ($command in $commands) {
    # $command = $commands[0]
    $parameters = (Get-Help -Name $command.Name).parameters.parameter
    [PSCustomObject]@{
        Command         = $command.Name
        SqlInstance     = ($parameters | Where-Object name -eq SqlInstance).description.text
        SqlCredential   = ($parameters | Where-Object name -eq SqlCredential).description.text
        Database        = ($parameters | Where-Object name -eq Database).description.text
        ExcludeDatabase = ($parameters | Where-Object name -eq ExcludeDatabase).description.text
        IncludeSystem   = ($parameters | Where-Object name -eq IncludeSystem).description.text
        Force           = ($parameters | Where-Object name -eq Force).description.text
        Confirm         = ($parameters | Where-Object name -eq Confirm).description.text
        WhatIf          = ($parameters | Where-Object name -eq WhatIf).description.text
        EnableException = ($parameters | Where-Object name -eq EnableException).description.text
        ParameterNames  = $parameters.name
    }
    Write-Host $command.Name
}

To show the mostly used description I have used this code:

$data | 
    Select-Object Command, SqlInstance | 
    Group-Object SqlInstance |
    Where-Object Name |
    Sort-Object Count -Descending |
    Select-Object Count, @{ n = 'Description' ; e = { $_.Name } }, @{ n = 'Command' ; e = { $_.Group.Command } } |
    Out-GridView -PassThru |
    Format-List *

And here is the result: 214: The target SQL Server instance or instances.

44: The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.

30: The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.

29: The target SQL Server instance or instances

19: The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or greater.

18: The target SQL Server instance

17: The target SQL Server instance or instances. Server version must be SQL Server version 2012 or higher.

17: The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2008 or higher.

10: The target SQL Server instance or instances. Defaults to localhost.

8: The target SQL Server instance or instances. This can be a collection and receive pipeline input.

6: The target SQL Server instance or instances. This can be a collection and receive pipeline input

5: The target SQL Server instance or instances. You must have sysadmin access and server version must be SQL Server version 2000 or higher.

4: The target SQL Server instance or instances.You must have sysadmin access and server version must be SQL Server version 2000 or higher.

4: Use a combination of computername and instancename to get the SQL Server related services for specific instances on specific computers. Parameters ComputerName and InstanceName will be ignored if SqlInstance is used.

niphlod commented 2 months ago

I concur that some work can be done in this area, but I also feel that trying to use the exact same description for every function could cut useful infos (as in "you must have sysadmin access"). What are we looking for, specifically ?