共用方式為


Export-SqlVulnerabilityAssessmentScan

將弱點評量掃描匯出至檔案。

語法

Default (預設值)

Export-SqlVulnerabilityAssessmentScan
    -ScanResult <ScanResult>
    -FolderPath <String>
    [-Force]
    [<CommonParameters>]

Description

Export-SqlVulnerabilityAssessmentScan Cmdlet 會將弱點評量掃描匯出至檔案。 命令目前僅支援將掃描匯出至 Excel (.xlsx) 檔案格式。

Module requirements: version 21+ on PowerShell 5.1; version 22+ on PowerShell 7.x.

This cmdlet was removed in v22.3+ of the module.

範例

範例 1:將弱點評量掃描導出至 Excel 檔案

PS C:\> $scanResult = Invoke-SqlVulnerabilityAssessmentScan -ServerInstance "MyComputer\MainInstance" -Database some_database
PS C:\> $scanResult | Export-SqlVulnerabilityAssessmentScan -FolderPath "ScanResult.xlsx"

在此範例中,我們會在資料庫上叫用弱點評量掃描,然後將它匯出至 Excel 檔案。

範例 2:逐一查看某些伺服器上的資料庫,並將 VA 掃描匯出至 Excel 檔案

PS C:\> @('localhost\SQL2016', 'localhost\SQL2017') |
  Get-SqlDatabase |
  Where-Object { $_.Name -like 'keep_*' } |
  ForEach-Object  {
    Invoke-SqlVulnerabilityAssessmentScan -ServerInstance $_.Parent -Database $_.Name |
    Export-SqlVulnerabilityAssessmentScan -FolderPath "$($env:TEMP)\$(($_.Parent).Name -replace '\\', '_' )_$($_.Name)_ScanResult.xlsx"
  }

PS C:\> dir "$env:TEMP\*_ScanResult.xlsx"

    Directory: C:\Users\someuser\AppData\Local\Temp

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        10/6/2018   1:19 AM          80050 SQL2016_keep_MDW_ScanResult.xlsx
-a----        10/6/2018   1:19 AM          80355 SQL2017_keep_MyDB_ScanResult.xlsx
-a----        10/6/2018   1:19 AM          79416 SQL2017_Keep_WideWorldImporters_ScanResult.xlsx

在此範例中,我們會示範一種簡單的方式來快速掃描一組 SQL Server 上的資料庫(在此案例中,是在本機計算機上執行的 2 個實例)。 資料庫清單會依名稱進行篩選,因此只會掃描名稱開頭為 「keep_」 的資料庫清單。 結果會儲存在 Excel 檔案中的 TEMP 資料夾下,其名稱可識別伺服器和所參考掃描的資料庫。

參數

-FolderPath

將儲存導出的檔案的位置

參數屬性

類型:String
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:True
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Force

如果檔案已經存在,是否強制覆寫檔案。 如果此參數不存在,系統會在作業繼續之前提示您。

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-ScanResult

要導出的弱點評量掃描結果。 掃描結果必須包含相關的安全性檢查元數據。

參數屬性

類型:ScanResult
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:True
來自管線的值:True
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

CommonParameters

此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters

輸入

Microsoft.SqlServer.VulnerabilityAssessment.ScanResult

輸出

System.Object