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

New-DBALogin - Bug in creating windows login #5138

Closed
3 of 5 tasks
supercyberal opened this issue Mar 1, 2019 · 2 comments
Closed
3 of 5 tasks

New-DBALogin - Bug in creating windows login #5138

supercyberal opened this issue Mar 1, 2019 · 2 comments

Comments

@supercyberal
Copy link

Before submitting a bug report:

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)
  • If issue is with Copy-DbaDatabase, using Backup-DbaDatabase | Restore-DbaDatabase still does not work

Note that we do not have the resources to make Copy-DbaDatabase work in every environment. Instead, we try to ensure Backup & Restore work in your enviornment.

Steps to Reproduce

/*
    Any T-SQL commands involved or used to produce test objects/data.
*/
$cSQLInst = "SERVER\INST"
$cLoginName = "DM\weinser-adm"
$cDefaultDB = "NewDB"

# Windows Login.
New-DbaLogin -SqlInstance $cSQLInst -Login $cLoginName -DefaultDatabase $cDefaultDB -Force -Verbose

Expected Behavior

Actual Behavior

VERBOSE: Performing the operation "Creating login [DM\weinser-adm] on SERVER\INST" on target "SERVER\INST".
VERBOSE: [12:59:50][New-DbaLogin] Adding as login type WindowsUser
VERBOSE: [12:59:50][New-DbaLogin] Failed to create [DM\weinser-adm] on SERVER\INST using SMO, trying T-SQL.
WARNING: [12:59:50][New-DbaLogin] Failed to add [DM\weinser-adm] to SERVER\INST. | Unclosed quotation mark after the character string '[DM\weinser-adm] FROM WINDOWS WITH CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF'.
Incorrect syntax near '[DM\weinser-adm] FROM WINDOWS WITH CHECK_EXPIRATION = OFF, CHECK_POLICY = OFF'.

Environmental data

  • PowerShell:
    • SQL Server:
@nvarscar
Copy link
Contributor

nvarscar commented Mar 1, 2019

Based on the verbose output, it seems that the login string that you have provided contains square brackets ('[login]'). The login name string should not contain those symbols.

@potatoqualitee
Copy link
Member

agreed, cannot repro

image

I can, however, strip the SMO part of the brackets, let's see

potatoqualitee added a commit that referenced this issue Mar 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants