大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#Defined Connection String
$connstring = "server=lync\rtclocal;database=rtcdyn;
trusted_connection=true;"
$connstring2 = "server=lync2\rtclocal;database=rtcdyn;
trusted_connection=true;"
创新互联主要从事成都做网站、成都网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务青海,十年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
#Define SQL Command
$command = New-Object System.Data.SqlClient.SqlCommand
$command.CommandText = "Select (cast (RE.ClientApp as
varchar (100))) as ClientVersion,
R.UserAtHost as UserName,
Reg.Fqdn
From
rtcdyn.dbo.RegistrarEndpoint RE
Inner Join
rtc.dbo.Resource R on R.ResourceId = RE.OwnerId
Inner Join
rtcdyn.dbo.Registrar Reg on Reg.RegistrarId =
RE.PrimaryRegistrarClusterId `
Order By ClientVersion, UserName "
#Make the connection to Server 1
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connstring
$connection.Open()
$command.Connection = $connection
$sqladapter = New-Object System.Data.SqlClient.SqlDataAdapter
$sqladapter.SelectCommand = $command
$results = New-Object System.Data.Dataset
$recordcount=$sqladapter.Fill($results)
$connection.Close()
$overallrecords = $overallrecords + $Results.Tables[0]
#Make the connection to Server 2
$connection.ConnectionString = $connstring2
$connection.Open()
$command.Connection = $connection
$results = New-Object System.Data.Dataset
$recordcount=$sqladapter.Fill($results)
$connection.Close()
$overallrecords = $overallrecords + $Results.Tables[0]
#End Section 2
$overallrecords | Export-Csv "PoolDistribution.csv"
Write-Host -ForegroundColor Green "Query complete"