|
- function Invoke-sql {
- param(
- [Parameter(Mandatory=$true)]
- $sql = "select * from Kunden",[Parameter(Mandatory=$true)]
- $connectionstring
- )
-
- $db = New-Object -comObject ADODB.Connection
- $db.Open($connectionstring)
- $rs = $db.Execute($sql)
- while (!$rs.EOF) {
- $hash = @{}
- foreach ($fIEld in $rs.FIElds) {
- $hash.$($fIEld.name) = $fIEld.Value
- }
- $rs.MoveNext()
- New-Object PSObject -property $hash
- }
- $rs.Close()
- $db.Close()
- }
复制代码 |
|