Pwershell script
need to retrieve information (sp_configure)from multiple SQL server with powershell script.But sp_configure doesn't have sql server name when it provide the output.I need output of sp_configure with server name in powershell script since I am retrieving information from multiple server.
January 31st, 2015 1:52am

server name is in the environment variable

$env:ComputerName
What does your script look like? Can you post it?

Free Windows Admin Tool Kit Click here and download it now
January 31st, 2015 1:59am

I need to retrieve information from multiple server in same domain.I need to run a powershell script which should connect multiple server and need to retrieve sp_configure information with server name.

January 31st, 2015 2:25am

How can you retrieve information from remote servers without knowing their names?

I think your request is a bit "fishy" or "buggy".

Do not wear a hat if you are not a member of the infamous "hat" squad.  It could be dangerous.

Free Windows Admin Tool Kit Click here and download it now
January 31st, 2015 3:49am

I am retrieving the information  from central server which is intern connected to multiple server. And in the sp_configure output I could not see the server information from where the data is retrieved. My requirement is upon collecting the information from multiple server I need the information of server name in it on running the powershell script.

February 2nd, 2015 1:50am

Hi Brindhat,

do I understand this correctly:

You have n SQL Servers and one Server that is collecting the information from all of them. Your script gets the information from the one collecting Server, not the individual SQL Servers.

In that case check out the collecting SQL Server - either it stores where it got its information from, or you are out of luck. You may be able to simply get the list of SQL Servers from the configuration of the collecting server, and then directly query the SQL Servers.

Cheers,
Fred

Free Windows Admin Tool Kit Click here and download it now
February 2nd, 2015 4:03am

I am retrieving the information  from central server which is intern connected to multiple server. And in the sp_configure output I could not see the server information from where the data is retrieved. My requirement is upon collecting the information from multiple server I need the information of server name in it on running the powershell script.

Can you post the script that runs on the central SQL server?
February 2nd, 2015 5:56am

I am retrieving the information  from central server which is intern connected to multiple server. And in the sp_configure output I could not see the server information from where the data is retrieved. My requirement is upon collecting the information from multiple server I need the information of server name in it on running the powershell script.

I repeat - this is not a SQLServer forum.  sp_configure is a SQL stored procedure.  You need to post in SQLServer forumm for T-SQL quesitons.

See this: https://msdn.microsoft.com/en-us/library/ms188787.aspx

Free Windows Admin Tool Kit Click here and download it now
February 2nd, 2015 7:24am

my powershell script will connect multiple server

for each($svr in get-content 'q:\drive\server.txt)

{

$con="server=$svr;database=master;integrated security=sspi"

$cmd="sp_configure"

}

From this script I am getting output as

Name minimum maximum config_value run_value

but I want output like

Servername Name minimum maximum config_value run_value

I want each server name from where I am retrieving this information.

February 3rd, 2015 2:26pm

We do not have all of your bits.  THe sp_configure output i what it is.  YOu canupdate it to add the server to the result and cutomize the object.

The script you have posted is incomplete and would produce no output.

Free Windows Admin Tool Kit Click here and download it now
February 3rd, 2015 2:33pm

Here is a hint:
foreach($svr in (get-content q:\drive\server.txt)){
    invoke-sqlcmd sp_configure -serverinstance $srv | 
        select @{N='Server';E={$srv}}, name, minimum,maximum,config_value, run_value
}		
February 3rd, 2015 2:38pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics