Export-SqlVulnerabilityAssessmentScan
將弱點評估掃描匯出至檔案。
語法
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 |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-Force
如果檔案已經存在,是否要強制覆寫檔案。 如果此參數不存在,系統會在作業繼續之前提示您。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ScanResult
要匯出的弱點評量掃描結果。 掃描結果必須包含相關的安全性檢查中繼資料。
類型: | ScanResult |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
輸入
Microsoft.SqlServer.VulnerabilityAssessment.ScanResult
輸出
System.Object