I am writing one powershell script to get display one record of a table from the Azure Database. I am using select query in the powershell script to fetch the specific record. I have to declare a column name as a variable from that table and I have write the if else condition to update that particular column values with the help of update query. Below is my script:
# Import the module
#Import-Module -Name SqlServer
#Set Azure subscription
#az account set --subscription "subscriptionid"
#Query Needs to execute
$query = "select * from Sys_Mst_VMProperties where Name = 'test7777' and idVMProperties = 1961"
# Setup your parameters
$Params = @{
'ServerInstance' = 'instance.database.windows.net';
'Database' = 'dbname';
'Username' = 'userid';
'Password' = 'pwd';
'Query' = $query;
}
# Splat
Invoke-Sqlcmd @Params
From the above output, I have the declare the VMStatus as variable and the variable should read the value from the table.
Kindly help us for above problem.