internal/Get-SaLoginName.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Function Get-SaLoginName
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [Alias("ServerInstance", "SqlInstance")]
        [object]$SqlServer,
        [System.Management.Automation.PSCredential]$SqlCredential
    )
    
    
    $server = Connect-SqlServer -SqlServer $SqlServer -SqlCredential $SqlCredential
    $saname = ($server.logins | Where-Object { $_.id -eq 1 }).Name
    
    return $saname
}