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-BcContainerBcUser fails with 'Invoke-SqlCmd' error when running BC24 #3404

Closed
MikeGlue opened this issue Mar 10, 2024 · 2 comments · Fixed by #3405
Closed

New-BcContainerBcUser fails with 'Invoke-SqlCmd' error when running BC24 #3404

MikeGlue opened this issue Mar 10, 2024 · 2 comments · Fixed by #3405
Assignees
Labels

Comments

@MikeGlue
Copy link
Contributor

MikeGlue commented Mar 10, 2024

PLEASE DO NOT INCLUDE ANY PASSWORDS OR TOKENS IN YOUR ISSUE!!!

Describe the issue
When executing 'New-BcContainerBcUser' on an existing container, the command fails with the following error:

The term 'Invoke-Sqlcmd' is not recognized as a name of a cmdlet, function, script file, or executable program.

Scripts used to create container and cause the issue

After creating a container with user/password authentication, run the following script:

$containerName = 'mycontainer'
$tenant = 'default'
$password = ConvertTo-SecureString -String 'Pass@word1' -AsPlainText -Force

'user1','user2' | ForEach-Object {
    $credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $_, $password
    New-BcContainerBcUser -Credential $credential -containerName $containerName -tenant $tenant -assignPremiumPlan -ChangePasswordAtNextLogOn:$false
}

Full output of scripts

PS C:\WINDOWS\system32> D:\Downloads\CreateUser.ps1
Creating User user1
Assigning Permission Set SUPER to user1
Assigning Premium plan for USER1
The term 'Invoke-Sqlcmd' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Container Free Physical Memory: 8.1Gb

Services in container mycontainer:
New-BcContainerBcUser Telemetry Correlation Id: 3b850d78-fa1a-4870-9829-be7ede65263b
The term 'Invoke-Sqlcmd' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.8\ContainerHandling\Invoke-ScriptInNavContainer.ps1:304 char:25
+                         throw $errorMessage
+                         ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (The term 'Invok... and try again.:String) [], RuntimeException
    + FullyQualifiedErrorId : The term 'Invoke-Sqlcmd' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
...

Screenshots
n/a

Additional context

  • I am using BcContainerHelper 6.0.8
  • This has broke in the past week as I have a similar script running every Saturday. It ran fine on March 2, and failed on March 9.
  • I am creating a container with v24 artifacts (specifically, I am using the next-minor artifacts)
  • I had a similar script I was running where I was using 'Invoke-ScriptInBcContainer' to call 'Invoke-SqlCmd' and it had the same error. I fixed that by adding '-usePwsh $false' to the 'Invoke-ScriptInBcContainer' call
  • Seems related to Invoke-ScriptInBcContainer/Enter-BcContainer fails to load other powershell modules #3330
@freddydk
Copy link
Contributor

freddydk commented Mar 11, 2024

This is caused by the fact that invoke-scriptinBcContainer uses pwsh in BC 24+ instead of powerShell
Reason for this is that all BC commandlets in BC24 now need PowerShell 7.4.1 and running a bridge from PowerShell 5 to PowerShell 7 is very expensive.

BTW, this is not related to 3330 (which is a problem with different locale in a container) - this is simply invoke-sqlcmd not available in pwsh.

@freddydk freddydk changed the title New-BcContainerBcUser fails with 'Invoke-SqlCmd' error New-BcContainerBcUser fails with 'Invoke-SqlCmd' error when running BC24 Mar 11, 2024
freddydk added a commit that referenced this issue Mar 11, 2024
And remove support for pre 1.0.2.15 generic images (these no longer
exists)
Fixes #3404
Fixes #3406

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
@MikeGlue
Copy link
Contributor Author

MikeGlue commented Mar 11, 2024

thanks Freddy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants