server name is in the environment variable
$env:ComputerNameWhat does your script look like? Can you post it?
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.
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.
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.
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
Can you post the script that runs on the central SQL server?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 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
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.
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.
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 }