Add Windows User to local SQL Server with PowerShell

后端 未结 4 1892
清歌不尽
清歌不尽 2021-01-24 18:08

I would like to add an existing local user to the SQL Server as a sysadmin, with PowerShell. fter some research I have the following script so far:

$Username = \         


        
4条回答
  •  攒了一身酷
    2021-01-24 18:17

    Change

    '$Username'
    

    with

    "$Username"
    

    Note that in powershell variable aren't expanded in single quote, then '$Username' is take as literal and not for the value of the variable.

提交回复
热议问题