Hi
I have to do a powershell that return values from the SQL-Server Settings.
If i run the sqlps part on the server, then i get the result after about 2 sec. But if i wanna store them in a variable, it takes about an hour. Does anyone have an idea why it takes so long?
Here is the code.
$a should be the array where all data is stored
Thanks
$a = sqlps.exe {
CD \sql\localhost\
$Instanzen = dir
$return = @{}
foreach($inst in $Instanzen){
$pschildd = $inst.pschildname
$srv = get-item $pschildd
$srvInfo = $srv.Information
$nodename = $srvInfo.netname
$osversion = $srvInfo.OSVersion
$Processor = ""
$countProcessor= $srvInfo.Processors
$sqlV= $srvInfo.ResourceVersionString
$sqlsp= $srvInfo.productlevel
$Instanz = $srv
$serverColl = $srvInfo.Collation
$dbs=$srv.Databases
$TotRam = $srvInfo.PhysicalMemory
$minRam = $srv.Configuration.MinServerMemory.ConfigValue
$maxRam = $srv.Configuration.MaxServerMemory.ConfigValue
$return.$pschildd += ($nodename,$osversion,$Processor,$countProcessor,$sqlV,$sqlsp,$Instanz, $serverColl, $dbs, $TotRam,$minram, $maxRam)
}
return $return
}