February 10, 2011
$SQLServerName="10.11.12.13" $SQLDatabase="Inventory" $DBConnection=New-Object System.Data.SQLClient.SQLConnection $DBConnection.ConnectionString="Server=$SQLServerName;Database=$SQLDatabase;` Trusted_Connection=False;User ID='sa';Password='password'" $DBConnection.Open() $DBCommand=New-Object System.Data.SQLClient.SQLCommand $DBCommand.Connection = $DBConnection $SelectStatement="SELECT *, Server AS Expr1 FROM tblServer" $DBCommand.CommandText=$SelectStatement $DBResult=$DBCommand.ExecuteReader() $ServerTable=New-Object system.data.datatable $ServerTable.load($DBResult) $list = $ServerTable | Where-Object {$_.Synlig -eq 'True'} | ` Select-Object Server,IP_adress | Sort-Object Server
foreach ($item in $list) {$item}
Subscribe to:
Post Comments (Atom)
Tags
Links
About Me
- Catherina
- I took the PowerShell Master Class for Thomas Lee in Stockholm in march 2010.
0 kommentarer:
Post a Comment