Create replica of Azure DB for my SQL Server using powershell - azure-sql-database

While creating replica of Azure DB for my SQL Server using powershell getting the below error. Please help me to fix.
Command to create replica of DB server:
1st command tried:
$TargetDBServerName2= Get-AzMySqlServer -ResourceGroupName $ResourceGroupName -ServerName $TargetDBServerName
New-AzMySqlReplica -Master $TargetDBServerName2 -Replica $TargetDBServerName-replica -ResourceGroupName $ResourceGroupName
2nd command tried:
Get-AzMySqlServer -ResourceGroupName $ResourceGroupName -ServerName $TargetDBServerName | New-AzMySqlReplica -Replica $TargetDBServerName-replica -ResourceGroupName $ResourceGroupName
Error when I ran first command:
PS /home/praveen> New-AzMySqlReplica -Master $TargetDBServerName2 -Replica $TargetDBServerName-replica -ResourceGroupName $ResourceGroupName
New-AzMySqlServer_Create: /usr/local/share/powershell/Modules/Az.MySql/1.0.0/custom/New-AzMySqlReplica.ps1:139
Line |
139 | Az.MySql.internal\New-AzMySqlServer #PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| An unexpected error occured while processing the request. Tracking ID: '0268ff12-7c60-49de-8de5-ccdb844d8329'
Error when I ran 2nd command:
PS /home/praveen> Get-AzMySqlServer -ResourceGroupName $ResourceGroupName -ServerName $TargetDBServerName | New-AzMySqlReplica -Replica $TargetDBServerName-replica -ResourceGroupName $ResourceGroupName
New-AzMySqlServer_Create: /usr/local/share/powershell/Modules/Az.MySql/1.0.0/custom/New-AzMySqlReplica.ps1:139
Line |
139 | Az.MySql.internal\New-AzMySqlServer #PSBoundParameters
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| An unexpected error occured while processing the request. Tracking ID: '3aea208b-0a59-4be9-ad95-aef3593b2c71'

Related

How to install Microsoft SQL server as userdata(powershell) on windows machine in AWS? or powershell error resolution for below

Its and windows machine and trying to install Sql Server(unattended) using powershell
Write-Host "`nStarting the install of SQL Server" -ForegroundColor Green
[string]$userName = 'domain\username'
[string]$userPassword = 'xyz'
[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword)
Start-Process -Filepath "$driveLetter\setup.exe" -ArgumentList "/ConfigurationFile=`"$temp_file_location`"" -Credential $credObject -NoNewWindow -Wait -RedirectStandardOutput $standardOutputFile -RedirectStandardError $errorOutputFile
ERROR:
PS C:\Windows\system32> C:\Users\manish\Desktop\custommain.ps1
domain
eu-west-1
fetching the password from parameter stores
Cleaning the outputfile error
finding and replacing the domains and secrets
writting the content of ini into temp file C:\xyz-softwares\ms-sql-server\scripts\batch-files\temp_ConfigurationFile.ini
Mounting SQL Server Image
Getting Disk drive of the mounted image
Starting the install of SQL Server
Start-Process : This command cannot be run due to the error: The user name or password is incorrect.
At C:\xyz-softwares\ms-sql-server\scripts\powershell\ms-sqlserver-installation.ps1:65 char:2
+ Start-Process -Filepath "$driveLetter\setup.exe" -ArgumentList "/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
SQL Installation Failed Installation with exit code
SQL Installation Failed Installation with exit code
At C:\xyz-softwares\ms-sql-server\scripts\powershell\ms-sqlserver-installation.ps1:72 char:9
+ throw $error_message
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (SQL Installatio... with exit code:String) [], RuntimeException
+ FullyQualifiedErrorId : SQL Installation Failed Installation with exit code
PS C:\Windows\system32>
I have tried with powershell with domain credentials.
Although i have exe file and windows machine is connected with domain
Tried to start process command with domain credetials.

Add-AzTableRow command is not available in Azure Cloud Shell

I'm trying to insert new row in my table storage by using Azure Cloud Shell but I'm facing below exception. So let me know any other command that we need to use to insert.
Blockquote
Add-AzTableRow: The term 'Add-AzTableRow' 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.
Blockquote
Below are the command:
$partitionKey1 = "partition1"
$partitionKey2 = "partition2"
Add-AzTableRow `
-table $cloudTable `
-partitionKey $partitionKey1 `
-rowKey ("CA") -property #{"username"="Chris";"userid"=1}
According to the error, it seems that you do not install the module AzTable. Please run the command Get-InstalledModule to check if you have installed the module.
If you have not installed the module, please run the command Install-Module -Name AzTable -Force to install it.
For example
Install-Module -Name AzTable -Force
Import-Module AzTable
$resourceGroup = "<your group name>"
$storageAccountName ="<your account name>"
$storageAccount=Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName
$ctx = $storageAccount.Context
$tableName = "<table name>"
$cloudTable = (Get-AzStorageTable –Name $tableName –Context $ctx).CloudTable
$partitionKey1 = "partition1"
Add-AzTableRow -table $cloudTable -partitionKey $partitionKey1 -rowKey ("CA") -property #{"username"="Chris";"userid"=1}

Get-AzScheduledQueryRule what is same funtion script for azurerm

In az Get-AzScheduledQueryRule but in azurerm there is no query rule. I f any alternative script means pls share.
Well, the Get-AzScheduledQueryRule command gets the alert rule whose SIGNAL TYPE is Log Search, its resource type is microsoft.insights/scheduledqueryrules.
For the AzureRM module, your option is to use the Get-AzureRmResource command, specify the -ResourceType with "microsoft.insights/scheduledqueryrules".
Sample:
Get-AzureRmResource -ResourceGroupName "<ResourceGroupName>" -ResourceType "microsoft.insights/scheduledqueryrules" -Name "<alert rule name>" | ConvertTo-Json

weblogic.Admin: command not found

I am using linux terminal with below code to get server status but i am getting weblogic.Admin: command not found, any lead would be appreciable.
cd /opt/SP/WEB_DATA/weblogic/wls12130/user_projects/domains/pega/bin
. ./setDomainEnv.sh
export CLASSPATH=/WEB_DATA/weblogic/wls12130/wlserver/server/lib/weblogic.jar
ServerState=/opt/SP/WEB_DATA/mw/jdk1.8.0_91/bin/java weblogic.Admin -url http://t3://localhost:7001 -username weblogic -password weblogic1
GET -pretty -type ServerRuntime -property State |grep -i State|awk '{print $2}'| rev | cut -c 1- | rev
weblogic.Admin has been deprecated for a while now. Use wlst instead.
(location of ORACLE_HOME)/wlserver/common/bin/wlst.sh
wls:/offline>connect('weblogic','weblogic1','t3://localhost:7001')
wls:/DOMAIN/serverConfig>state('WLAdmin','Server')
WLAdmin is the name of the admin server
You can place the above commands in a python script and execute it using wlst

Manage Azure classic storage accounts using the RM mode

I am only using the new RM mode with PowerShell. Although I see all the storage cmdlets, but they do not seem to work with the classic storage accounts.
If I run these two commands, no account are returned:
Get-AzureRmSubscription –SubscriptionName "mysubs | Select-AzureRmSubscription
Get-AzureRmStorageAccount -ResourceGroupName "myrg"
Also....if I try this command:
Set-AzureRmStorageAccount -ResourceGroupName "myrg" -Name "myaccount" -Type Standard_GRS
It says no storage account exists. I think it is only looking for new storage accounts which I don't have any.
Is there a way to force the RM storage module to retrieve/manager classic storage accounts?
Regards
I don't think I can. So I used the following non-RM Cmdlts and it worked fine:
Add-AzureAccount
Select-AzureSubscription -SubscriptionName $subscription
Set-AzureSubscription -SubscriptionName $subscription -CurrentStorageAccountName $storageAccount
Get-AzureStorageBlob -Container $containerName
Get-AzureStorageBlob -Container $containerName | Export-Csv $csv -NoTypeInformation -Encoding UTF8 -Delimiter ','