error to get backup sql azure from powershell - sql

I need create and download backup sql database. I installed Azure powershell. But my script does not work.
$dt = Get-Date -Format yyyyMMddHHmmss
$dbname = 'AnimalTranslate'
Backup-SqlDatabase $dbname "C:\drops" "XXX.database.windows.net" "login" "password"
I see error:
Backup-Database : The term 'Backup-Database' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
How it's fixed?

You can't use Backup-SqlDatabase to backup Azure SQL. You need to use one of the methods in this article:
http://msdn.microsoft.com/en-us/library/windowsazure/jj650016.aspx

Related

New-DbaConnectionString : The term 'New-DbaConnectionString' is not recognized as the name of a cmdlet, function

I am trying to connect to SQL Server through powershell, when trying to create a SQL instance with the following variable:
$sqlInstance = New-DbaConnectionString -SqlInstance $server -Datbase $database -TrustServerCertificate
When I run the script I get the following error:
New-DbaConnectionString : The term 'New-DbaConnectionString' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I can connect to the database with an Invoke-Sqlcmd and it produces the query expected
Invoke-Sqlcmd -Query $SQL_Command -ServerInstance $server -Database $database
I tried looking if I need to install the function / a module as I am also getting the following error when I try and call Import-DbaCsv:
Import-DbaCsv : The term 'Import-DbaCsv' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The term 'Get-AzureSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program

I installed Az Module with the following command, but I still get the following error.
Install-Module -Name Az -AllowClobber -Scope AllUsers
Get-AzureSubscription: The term 'Get-AzureSubscription' 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.
Any ideas?
The command to get the subscription is Get-AzSubscription.
Most Azure commands include Az, not Azure.
You might need to login first with Connect-AzAccount, and logging in through the browser popup.
Sign in with Azure Powershell - Microsoft
Get-AzSubscription no longer works. Use Get-AzureRmSubscription to retrieve your Azure Subscription details.

Running SQL against multiple DB in azure pipeline

I want to set up the step in release process for azure pipeline where I can run the SQL from the file checked into the repo against multiple databases.
In my environment, I have one central db, one of the table for e.g "Control" table, keeps the connection to all the databases against which I need to run the sql during the deployment.
What I dont want to do is to setup the deployment step for each database. Is Powershell my only friend?
If so, how can I let powershell know what is the SQL in the file checked in during the deployment?
What I dont want to do is to setup the deployment step for each database. Is Powershell my only friend? If so, how can I let powershell know what is the SQL in the file checked in during the deployment?
In your case, Powershell seems to be the most appropriate.
In order to get the SQL in the file checked in during the deployment, we could use the powershell scripts to get the file names and paths, like:
$files=$(git diff HEAD HEAD~ --name-only)
$temp=$files -split ' '
$count=$temp.Length
echo "Total changed $count files"
For ($i=0; $i -lt $temp.Length; $i++)
{
$name=$temp[$i]
echo "this is $name file"
Copy-Item "$name" -Destination "$(System.DefaultWorkingDirectory)\SQLDeploymentFolder"
}
Check the ticket for some more details.
Then, we could use the extension Run SQL Server Scripts or Run SQL / SQLCMD Scripts passing multiple SQLCMD variables to all SQL Scripts in a folder.
Hope this helps.

Recompose VM using vmware 5.5 power cli

How can I recompose a VM v1 with existing parent VM v2's snapshot s2 ?
After referring few documents, I saw command Send-LinkedCloneRecompose for recomposing VM.
I am trying this command as follows:
$myVM = 'v1'
$clone = Get-DesktopVM -Name $myVM
$pool = Get-Pool -pool_id $clone.pool_id
$date = Get-Date
$date = $date.AddSeconds(10)
Write-Host "Recomposing" $clone.name
Send-LinkedCloneRecompose -machine_id $clone.machine_id -parentVMPath $pool.parentVMPath -parentSnapshotPath $pool.parentVMSnapshotPath -schedule $date -forcelogoff $true | tee-object -variable vmState
Here I am getting error as Get-DesktopVM : The term 'Get-DesktopVM' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
I am getting the same error for powercli commandlets Get-Pool and Send-LinkedCloneRecompose as well.
I am using VMware VSphere power cli 5.5 release 2 patch 1.
Can anyone please help me in understanding the problem here ?
I missed to add
& "C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1"
before executing above commands. So the commandlets were not recognized.

Command line start ssms with localdb does not work

I have a requirement to start ssms (SQL Management Studio) from the command line that connects to a (localdb)\myinstance. The instance exists
sqllocaldb info myinstance
but using the command line and the -S parameter with (localdb)\myinstance throws an error.
PS C:\workingArea> ssms -S(localdb)\myinstance
localdb : The term 'localdb' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:9
+ ssms -S(localdb)\myinstance
I can connect using the named pipe but would ideally like to use the known name.
You can try the following: ssms -S LOCALHOST\myinstanceto connect to a LocalDb instance