How to get SQL Server Version on multiple Servers on Azure using Power shell.

%3CLINGO-SUB%20id%3D%22lingo-sub-1376255%22%20slang%3D%22en-US%22%3EHow%20to%20get%20SQL%20Server%20Version%20on%20multiple%20Servers%20on%20Azure%20using%20Power%20shell.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1376255%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20300%20servers%20on%20azure%2C%20i%20have%20to%20find%20the%20details%26nbsp%3Bof%20SQL%20Server%20Version%20in%20all%20servers%20on%20Azure.%3C%2FP%3E%3CP%3Ehow%20to%20do%20this%20using%20Power%20shell%3F%3C%2FP%3E%3CP%3E(like%20i%20can%20put%20the%20name%20of%20the%20servers%20in%20a%20file%20and%20get%20the%20output%20in%20another%20file).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1376255%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Automation%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IaaS%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1376432%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20SQL%20Server%20Version%20on%20multiple%20Servers%20on%20Azure%20using%20Power%20shell.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1376432%22%20slang%3D%22en-US%22%3E%3CP%3Ehi%2C%3C%2FP%3E%3CP%3EFollow%20this%20script%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22hljs-pscommand%22%3EGet-AzureRmSqlServer%3C%2FSPAN%3E%3CSPAN%3E%20%5B%5B-ResourceGroupName%5D%20%3CSTRING%3E%5D%20%5B%5B-ServerName%5D%20%3CSTRING%3E%5D%20%5B-DefaultProfile%20%3CIAZURECONTEXTCONTAINER%3E%5D%20%5B-WhatIf%5D%20%5B-Confirm%5D%20%5B%3CCOMMONPARAMETERS%3E%5D%3C%2FCOMMONPARAMETERS%3E%3C%2FIAZURECONTEXTCONTAINER%3E%3C%2FSTRING%3E%3C%2FSTRING%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20hope%20this%20helps!%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ERegards.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1376808%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20SQL%20Server%20Version%20on%20multiple%20Servers%20on%20Azure%20using%20Power%20shell.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1376808%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425529%22%20target%3D%22_blank%22%3E%40RuskinF%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EThanks%20for%20the%20answer.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20confused%20in%20this%2C%20where%20to%20put%20which%20value.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esuppose%20my%20Server%20name%20is%20ABC%20and%20resource%20group%20is%20XYZ.%20actually%20i%20am%20confused%20in%20parameters%20and%20in%20string.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22hljs-pscommand%22%3EGet-AzureRmSqlServer%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%5B%5B-%3CSTRONG%3EXYZ%3C%2FSTRONG%3E%5D%20%3CSTRING%3E%5D%20%5B%5B-%3CSTRONG%3EABC%3C%2FSTRONG%3E%5D%20%3CSTRING%3E%5D%20%5B-DefaultProfile%20%3CIAZURECONTEXTCONTAINER%3E%5D%20%5B-WhatIf%5D%20%5B-Confirm%5D%20%5B%3CCOMMONPARAMETERS%3E%5D%3C%2FCOMMONPARAMETERS%3E%3C%2FIAZURECONTEXTCONTAINER%3E%3C%2FSTRING%3E%3C%2FSTRING%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1378571%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20get%20SQL%20Server%20Version%20on%20multiple%20Servers%20on%20Azure%20using%20Power%20shell.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1378571%22%20slang%3D%22en-US%22%3EThe%20command%20would%20be%3A%3CBR%20%2F%3Eget-azureRmSqlServer%20-resourceGroupname%20XYZ%20-serverName%20ABC%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20follows%20after%20the%20dash(-)%20is%20the%20parameter%20name%20and%20it%20takes%20a%20value.%3CBR%20%2F%3EYou%20mentioned%20you%20have%20300%20servers%20so%20you'll%20have%20to%20use%20a%20looping%20mechanism%20to%20run%20the%20command%20for%20each%20server%20name.%20One%20of%20the%20ways%20is%20to%20have%20a%20.txt%20file%20with%20each%20server%20name%20on%20a%20separate%20line%20and%20pipe%20it%20to%20a%20forEach-object.%20Example%3A%3CBR%20%2F%3Eget-content%20-path%20c%3A%5Ctemp%5Cserver-list.txt%20%7C%20forEach-object%20%7Bget-azureRmSqlServer%20-resourceGroupname%20XYZ%20-serverName%20%24_%7D%3C%2FLINGO-BODY%3E
Contributor

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 the output in another file).

3 Replies

hi,

Follow this script:

Get-AzureRmSqlServer [[-ResourceGroupName] <String>] [[-ServerName] <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]

 

I hope this helps!

Regards.

@RuskinF

 

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>]

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 $_}