Forum Discussion
Prashant Sharma
May 09, 2020Brass Contributor
How to get SQL Server Version on multiple Servers on Azure using Power shell.
I have 300 servers on azure, i have to find the details of SQL Server Version in all servers on Azure. how to do this using Power shell? (like i can put the name of the servers in a file and get th...
Prashant Sharma
May 09, 2020Brass Contributor
Hello,
Thanks for the answer.
I am confused in this, where to put which value.
suppose my Server name is ABC and resource group is XYZ. actually i am confused in parameters and in string.
Get-AzureRmSqlServer [[-XYZ] <String>] [[-ABC] <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
Animesh Joshi
May 11, 2020Brass Contributor
The command would be:
get-azureRmSqlServer -resourceGroupname XYZ -serverName ABC
What follows after the dash(-) is the parameter name and it takes a value.
You mentioned you have 300 servers so you'll have to use a looping mechanism to run the command for each server name. One of the ways is to have a .txt file with each server name on a separate line and pipe it to a forEach-object. Example:
get-content -path c:\temp\server-list.txt | forEach-object {get-azureRmSqlServer -resourceGroupname XYZ -serverName $_}
get-azureRmSqlServer -resourceGroupname XYZ -serverName ABC
What follows after the dash(-) is the parameter name and it takes a value.
You mentioned you have 300 servers so you'll have to use a looping mechanism to run the command for each server name. One of the ways is to have a .txt file with each server name on a separate line and pipe it to a forEach-object. Example:
get-content -path c:\temp\server-list.txt | forEach-object {get-azureRmSqlServer -resourceGroupname XYZ -serverName $_}