Export-SqlVulnerabilityAssessmentScan
Exports a Vulnerability Assessment scan to a file.
语法
Default (默认值)
Export-SqlVulnerabilityAssessmentScan
-ScanResult <ScanResult>
-FolderPath <String>
[-Force]
[<CommonParameters>]
说明
The Export-SqlVulnerabilityAssessmentScan cmdlet exports a Vulnerability Assessment scan to a file. Currently the command supports exporting a scan to Excel (.xlsx) file format only.
Module requirements: version 21+ on PowerShell 5.1; version 22+ on PowerShell 7.x.
This cmdlet was removed in v22.3+ of the module.
示例
Example 1: Export a Vulnerability Assessment scan to Excel file
PS C:\> $scanResult = Invoke-SqlVulnerabilityAssessmentScan -ServerInstance "MyComputer\MainInstance" -Database some_database
PS C:\> $scanResult | Export-SqlVulnerabilityAssessmentScan -FolderPath "ScanResult.xlsx"
In this example, we invoke a Vulnerability Assessment scan on a database then export it to an Excel file.
Example 2: Iterate over databases on some servers and export VA scans to Excel files
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
In this example, we show a simple way to quickly scan databases on a set of SQL Servers (in this case, 2 instances running on the local machine). The list of databases is filtered on the name, so only the ones whose names start with "keep_" are scanned). The results are stored under the TEMP folder in Excel files with a name that identifies the server and the databases the scan referred to.
参数
-FolderPath
Where the exported file will be saved
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Force
Whether to force overwrite of the file if it already exists. If this parameter is not present, you will be prompted before the operation continues.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-ScanResult
The Vulnerability Assessment scan result to export. The scan result must contain the relevant security checks' metadata.
参数属性
类型: | ScanResult |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | True |
来自管道的值: | True |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.