Home
%3CLINGO-SUB%20id%3D%22lingo-sub-386232%22%20slang%3D%22en-US%22%3EAzure%20SQL%20Vulnerability%20Assessment%20-%20now%20with%20PowerShell%20support!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-386232%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Aug%2002%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20You%20can%20now%20manage%20your%20SQL%20Vulnerability%20Assessments%20at%20scale%20using%20the%20new%20SQL%20VA%20PowerShell%20cmdlets.%20The%20cmdlets%20can%20be%20found%20in%20the%20Azure%20Resource%20Manager%20module%2C%20AzureRM%206.6.0%2C%20within%20the%20AzureRM.Sql%20package.%20Take%20a%20look%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FAzureRM%2F6.6.0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20AzureRM%20PowerShell%20Gallery%20%3C%2FA%3E%20for%20more%20details.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-1706729153%22%20id%3D%22toc-hId-1734433910%22%3EManaging%20Vulnerability%20Assessment%20with%20cmdlets%3C%2FH2%3E%3CBR%20%2F%3E%20SQL%20Vulnerability%20Assessment%20(VA)%20is%20a%20service%20that%20provides%20visibility%20into%20your%20security%20state%2C%20and%20includes%20actionable%20steps%20to%20resolve%20security%20issues%2C%20and%20enhance%20your%20database%20security.%20For%20more%20details%2C%20please%20see%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-vulnerability-assessment%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Vulnerability%20Assessment%20Getting%20Started%20guide%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Vulnerability%20Assessment%20is%20part%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-advanced-threat-protection%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20SQL%20Advanced%20Threat%20Protection%20%3C%2FA%3E%20package%20for%20Azure%20SQL%20Database.%20The%20full%20package%20provides%20a%20single%20go-to%20location%20for%20discovering%20and%20classifying%20sensitive%20data%20(%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-database-data-discovery-and-classification%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Information%20Protection%20%3C%2FA%3E%20)%2C%20detecting%20database%20threats%20(%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-database-threat-detection%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Threat%20Detection%20%3C%2FA%3E%20)%20and%20running%20vulnerability%20assessments%20with%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-vulnerability-assessment%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20SQL%20Vulnerability%20Assessment%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20new%20cmdlets%20can%20be%20used%20initially%20to%20turn%20on%20the%20Advanced%20Threat%20Protection%20(ATP)%20package%20on%20your%20database.%20Additionally%2C%20there%20are%20cmdlets%20available%20for%20setting%20up%20Vulnerability%20Assessment%20parameters%2C%20running%20scans%2C%20managing%20scan%20results%20and%20managing%20baselines.%20Using%20these%20capabilities%2C%20you%20can%20now%20run%20and%20manage%20assessments%20across%20a%20fleet%20of%20databases%2C%20all%20from%20the%20comfort%20of%20your%20PowerShell%20console.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId--845427808%22%20id%3D%22toc-hId--817723051%22%3EExample%20script%20using%20Vulnerability%20Assessment%20cmdlets%3C%2FH2%3E%3CBR%20%2F%3E%20The%20following%20PowerShell%20script%20demonstrates%20the%20use%20of%20the%20new%20VA%20cmdlets.%20The%20script%20walks%20through%20the%20following%20steps%3A%20%3CBR%20%2F%3E%3COL%3E%3CBR%20%2F%3E%3CLI%3ETurn%20on%20Advanced%20Threat%20Protection%20on%20the%20server%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3ESet%20up%20Vulnerability%20Assessment%20for%20all%20databases%20on%20that%20server%2C%20including%20setting%20recurring%20scans%20to%20run%20automatically%20once%20per%20week.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3ESet%20a%20customized%20baseline%20value%20for%20one%20of%20the%20checks%20run%20by%20the%20scan%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3ERun%20a%20vulnerability%20scan%20on%20the%20database%2C%20and%20consume%20the%20results%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EDownload%20the%20scan%20results%20to%20an%20Excel%20summary%20file%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FOL%3E%3CBR%20%2F%3E%20%3CSTRONG%3E%20Sample%20script%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBLOCKQUOTE%3E%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20set%20parameters%20-%20resource%20group%2C%20server%2C%20database%20and%20storage%20account%20%3CBR%20%2F%3E%20%24params%20%3D%26nbsp%3B%20%40%7B%20rgname%20%3D%20%22rg%22%3B%20%3CBR%20%2F%3E%20serverName%20%3D%20%22my-server%22%3B%20%3CBR%20%2F%3E%20databaseName%20%3D%20%22my-db%22%3B%20%3CBR%20%2F%3E%20storageAccount%20%3D%20%22mystorage%22%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%23%20Turn%20on%20ATP%20%3CBR%20%2F%3E%20Enable-AzureRmSqlServerAdvancedThreatProtection%20-ResourceGroupName%20%24params.rgname%20-ServerName%20%24params.serverName%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Set%20Vulnerability%20Assessment%20storage%20settings%20for%20all%20the%20databases%20in%20the%20server%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Get-AzureRmSqlDatabase%20-ResourceGroupName%20%24params.rgname%20-ServerName%20%24params.serverName%20%60%20%3CBR%20%2F%3E%20%7C%20where%20%7B%24_.DatabaseName%20-ne%20%22master%22%7D%26nbsp%3B%20%60%20%3CBR%20%2F%3E%20%7C%20Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%20%60%20%3CBR%20%2F%3E%20-StorageAccountName%20%24params.storageAccount%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Update%20vulnerability%20assessment%20settings%20to%20turn%20ON%20recurring%20scans%2C%20and%20provide%20email%20to%20receive%20results%20%3CBR%20%2F%3E%20%24scanNotificationEmail%20%3D%20%40(%22%20%3CA%3E%20user1%40microsoft.com%20%3C%2FA%3E%20%22)%20%3CBR%20%2F%3E%20Get-AzureRmSqlDatabase%20-ResourceGroupName%20%24params.rgname%20-ServerName%20%24params.serverName%60%20%3CBR%20%2F%3E%20%7C%20where%20%7B%24_.DatabaseName%20-ne%20%22master%22%7D%26nbsp%3B%20%60%20%3CBR%20%2F%3E%20%7C%20Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%20%60%20%3CBR%20%2F%3E%20-RecurringScansInterval%20Weekly%20%60%20%3CBR%20%2F%3E%20-NotificationEmail%20%24scanNotificationEmail%20%60%20%3CBR%20%2F%3E%20-EmailAdmins%20%24true%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Set%20Vulnerability%20Assessment%20baseline%20for%20rule%20VA1143%20on%20all%20the%20databases%20in%20the%20server%20%3CBR%20%2F%3E%20%24ruleId%20%3D%20%22VA1143%22%20%3CBR%20%2F%3E%20%24baselineResult%20%3D%20%40(%20'1')%20%3CBR%20%2F%3E%20Get-AzureRmSqlDatabase%20-ResourceGroupName%20%24params.rgname%20-ServerName%20%24params.serverName%20%60%20%3CBR%20%2F%3E%20%7C%20where%20%7B%24_.DatabaseName%20-ne%20%22master%22%7D%26nbsp%3B%20%60%20%3CBR%20%2F%3E%20%7C%20Set-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%20%60%20%3CBR%20%2F%3E%20-RuleId%20%24ruleId%20%60%20%3CBR%20%2F%3E%20-BaselineResult%20%24baselineResult%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Run%20a%20new%20scan%20on%20a%20database%20%3CBR%20%2F%3E%20%24scanId1%20%3D%20%22custom-scan1%22%20%3CBR%20%2F%3E%20%24scanJob%20%3D%20Start-AzureRmSqlDatabaseVulnerabilityAssessmentScan%20%60%20%3CBR%20%2F%3E%20-ResourceGroupName%20%24params.rgname%20%60%20%3CBR%20%2F%3E%20-ServerName%20%24params.serverName%20%60%20%3CBR%20%2F%3E%20-DatabaseName%20%24params.databaseName%20%60%20%3CBR%20%2F%3E%20-ScanId%20%24scanId1%20%60%20%3CBR%20%2F%3E%20-AsJob%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%24scanJob%20%7C%20Wait-Job%20%3CBR%20%2F%3E%20%24scanRecord%20%3D%20%24scanJob%20%7C%20Receive-Job%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Convert%20the%20raw%20scan%20results%20to%20an%20Excel%20file%20%3CBR%20%2F%3E%20%24convertScanResult%20%3D%20Convert-AzureRmSqlDatabaseVulnerabilityAssessmentScan%20%60%20%3CBR%20%2F%3E%20-ResourceGroupName%20%24params.rgname%20%60%20%3CBR%20%2F%3E%20-ServerName%20%24params.serverName%20%60%20%3CBR%20%2F%3E%20-DatabaseName%20%24params.databaseName%20%60%20%3CBR%20%2F%3E%20-ScanId%20%24scanId1%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%23%20Download%20the%20scan%20results%20Excel%20summary%20file%20%3CBR%20%2F%3E%20%24connectionStringToStorageAccount%20%3D%20%22DefaultEndpointsProtocol%3Dhttps%3BAccountName%3D.......%22%20%3CBR%20%2F%3E%20%24convertedScanResultsDownloadLocalFolder%20%3D%20%22C%3A%5CScanResults%5C%22%20%3CBR%20%2F%3E%20%24storageAccountContext%20%3D%20New-AzureStorageContext%20-ConnectionString%20%24connectionStringToStorageAccount%20%3CBR%20%2F%3E%20%24convertScanResultSplitted%20%3D%20%24convertScanResult.ExportedReportLocation%20-split%20%22%2F%22%20%3CBR%20%2F%3E%20%24containerName%20%3D%20%24convertScanResultSplitted%5B3%5D%20%3CBR%20%2F%3E%20Get-AzureStorageBlobContent%20-Blob%20(%24convertScanResult.ExportedReportLocation%20-split%20%24containerName%20%2B%20'%2F')%5B1%5D%20%60%20%3CBR%20%2F%3E%20-Container%20%24containerName%20%60%20%3CBR%20%2F%3E%20-Destination%20%24convertedScanResultsDownloadLocalFolder%20%60%20%3CBR%20%2F%3E%20-Context%20%24storageAccountContext%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-897382527%22%20id%3D%22toc-hId-925087284%22%3EReference%3C%2FH2%3E%3CBR%20%2F%3E%20For%20a%20full%20set%20of%20Azure%20SQL-related%20PowerShell%20cmdlets%2C%20take%20a%20look%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpowershell%2Fmodule%2Fazurerm.sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Azure%20RM%20SQL%20PowerShell%20%3C%2FA%3E%20documentation.%20The%20new%20cmdlets%20supporting%20Advanced%20Threat%20Protection%20and%20SQL%20Vulnerability%20Assessment%20are%3A%20%3CBR%20%2F%3E%3CDIV%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CTABLE%3E%0A%20%20%20%20%3CTBODY%3E%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CSTRONG%3E%20Cmdlet%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3E%3CSTRONG%3E%20Usage%20%3C%2FSTRONG%3E%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FEnable-AzureRmSqlServerAdvancedThreatProtection%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Enable-AzureRmSqlServerAdvancedThreatProtection%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EEnables%20Advanced%20Threat%20Protection%20on%20a%20server.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FGet-AzureRmSqlServerAdvancedThreatProtectionPolicy%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Get-AzureRmSqlServerAdvancedThreatProtectionPolicy%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EGets%20the%20Advanced%20Threat%20Protection%20policy%20of%20a%20server.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FDisable-AzureRmSqlServerAdvancedThreatProtection%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Disable-AzureRmSqlServerAdvancedThreatProtection%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EDisables%20Advanced%20Threat%20Protection%20on%20a%20server.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FUpdate-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EUpdates%20the%20vulnerability%20assessment%20settings%20of%20a%20database%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FGet-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Get-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EReturns%20the%20vulnerability%20assessment%20settings%20of%20a%20database%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FClear-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Clear-AzureRmSqlDatabaseVulnerabilityAssessmentSettings%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EClear%20the%20vulnerability%20assessment%20settings%20of%20a%20database%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FSet-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Set-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3ESets%20the%20vulnerability%20assessment%20rule%20baseline.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FGet-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Get-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EGets%20the%20vulnerability%20assessment%20rule%20baseline%20for%20a%20given%20rule.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FClear-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Clear-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EClears%20the%20vulnerability%20assessment%20rule%20baseline.%20First%20set%20the%20baseline%20before%20using%20this%20cmdlet%20to%20clear%20it.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FStart-AzureRmSqlDatabaseVulnerabilityAssessmentScan%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Start-AzureRmSqlDatabaseVulnerabilityAssessmentScan%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3ETriggers%20the%20start%20of%20a%20vulnerability%20assessment%20scan%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FGet-AzureRmSqlDatabaseVulnerabilityAssessmentScanRecord%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Get-AzureRmSqlDatabaseVulnerabilityAssessmentScanRecord%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EGets%20all%20vulnerability%20assessment%20scan%20record(s)%20associated%20with%20a%20given%20database.%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%20%3CTR%3E%0A%20%20%20%20%20%3CTD%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fazurerm.sql%2FConvert-AzureRmSqlDatabaseVulnerabilityAssessmentScan%3Fview%3Dazurermps-6.6.0%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Convert-AzureRmSqlDatabaseVulnerabilityAssessmentScan%20%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FTD%3E%0A%20%20%20%20%20%3CTD%3EConverts%20vulnerability%20assessment%20scan%20results%20to%20an%20Excel%20file%3C%2FTD%3E%0A%20%20%20%20%3C%2FTR%3E%0A%20%20%20%3C%2FTBODY%3E%3C%2FTABLE%3E%3CBR%20%2F%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId--1654774434%22%20id%3D%22toc-hId--1627069677%22%3E%3C%2FH2%3E%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-88035901%22%20id%3D%22toc-hId-115740658%22%3EGet%20started%20now%20with%20VA%20PowerShell%20Cmdlets%3C%2FH2%3E%3CBR%20%2F%3E%20Get%20started%20now%20with%20managing%20your%20Azure%20SQL%20vulnerability%20assessments%20at%20scale%20using%20PowerShell%20cmdlets.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Install%20the%20latest%20Azure%20Resource%20Manager%20Module%20containing%20the%20new%20cmdlets%20at%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FAzureRM%2F6.6.0%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20AzureRM%20PowerShell%20Gallery%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Documentation%20for%20all%20supported%20Azure%20SQL-related%20PowerShell%20cmdlets%20can%20be%20found%20at%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fpowershell%2Fmodule%2Fazurerm.sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Azure%20RM%20SQL%20PowerShell%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20For%20more%20details%20on%20the%20SQL%20Vulnerability%20Assessment%2C%20see%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsql-database%2Fsql-vulnerability-assessment%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20SQL%20Vulnerability%20Assessment%20documentation%20%3C%2FA%3E%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20To%20learn%20more%20about%20VA%2C%20and%20see%20an%20assessment%20in%20action%20on%20Azure%20SQL%20Database%2C%20check%20out%20this%20Channel%209%20demo%20.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Try%20it%20out%20and%20let%20us%20know%20what%20you%20think!%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-386232%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Aug%2002%2C%202018%20You%20can%20now%20manage%20your%20SQL%20Vulnerability%20Assessments%20at%20scale%20using%20the%20new%20SQL%20VA%20PowerShell%20cmdlets.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-386232%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerSecurity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on Aug 02, 2018
You can now manage your SQL Vulnerability Assessments at scale using the new SQL VA PowerShell cmdlets. The cmdlets can be found in the Azure Resource Manager module, AzureRM 6.6.0, within the AzureRM.Sql package. Take a look at the AzureRM PowerShell Gallery for more details.

Managing Vulnerability Assessment with cmdlets


SQL Vulnerability Assessment (VA) is a service that provides visibility into your security state, and includes actionable steps to resolve security issues, and enhance your database security. For more details, please see the Vulnerability Assessment Getting Started guide .

Vulnerability Assessment is part of the SQL Advanced Threat Protection package for Azure SQL Database. The full package provides a single go-to location for discovering and classifying sensitive data ( Information Protection ), detecting database threats ( Threat Detection ) and running vulnerability assessments with SQL Vulnerability Assessment .

The new cmdlets can be used initially to turn on the Advanced Threat Protection (ATP) package on your database. Additionally, there are cmdlets available for setting up Vulnerability Assessment parameters, running scans, managing scan results and managing baselines. Using these capabilities, you can now run and manage assessments across a fleet of databases, all from the comfort of your PowerShell console.

Example script using Vulnerability Assessment cmdlets


The following PowerShell script demonstrates the use of the new VA cmdlets. The script walks through the following steps:

  1. Turn on Advanced Threat Protection on the server

  2. Set up Vulnerability Assessment for all databases on that server, including setting recurring scans to run automatically once per week.

  3. Set a customized baseline value for one of the checks run by the scan

  4. Run a vulnerability scan on the database, and consume the results

  5. Download the scan results to an Excel summary file


Sample script

{

# set parameters - resource group, server, database and storage account
$params =  @{ rgname = "rg";
serverName = "my-server";
databaseName = "my-db";
storageAccount = "mystorage"
}
# Turn on ATP
Enable-AzureRmSqlServerAdvancedThreatProtection -ResourceGroupName $params.rgname -ServerName $params.serverName

# Set Vulnerability Assessment storage settings for all the databases in the server

Get-AzureRmSqlDatabase -ResourceGroupName $params.rgname -ServerName $params.serverName `
| where {$_.DatabaseName -ne "master"}  `
| Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings `
-StorageAccountName $params.storageAccount

# Update vulnerability assessment settings to turn ON recurring scans, and provide email to receive results
$scanNotificationEmail = @(" user1@microsoft.com ")
Get-AzureRmSqlDatabase -ResourceGroupName $params.rgname -ServerName $params.serverName`
| where {$_.DatabaseName -ne "master"}  `
| Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings `
-RecurringScansInterval Weekly `
-NotificationEmail $scanNotificationEmail `
-EmailAdmins $true

# Set Vulnerability Assessment baseline for rule VA1143 on all the databases in the server
$ruleId = "VA1143"
$baselineResult = @( '1')
Get-AzureRmSqlDatabase -ResourceGroupName $params.rgname -ServerName $params.serverName `
| where {$_.DatabaseName -ne "master"}  `
| Set-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline `
-RuleId $ruleId `
-BaselineResult $baselineResult

# Run a new scan on a database
$scanId1 = "custom-scan1"
$scanJob = Start-AzureRmSqlDatabaseVulnerabilityAssessmentScan `
-ResourceGroupName $params.rgname `
-ServerName $params.serverName `
-DatabaseName $params.databaseName `
-ScanId $scanId1 `
-AsJob

$scanJob | Wait-Job
$scanRecord = $scanJob | Receive-Job

# Convert the raw scan results to an Excel file
$convertScanResult = Convert-AzureRmSqlDatabaseVulnerabilityAssessmentScan `
-ResourceGroupName $params.rgname `
-ServerName $params.serverName `
-DatabaseName $params.databaseName `
-ScanId $scanId1

# Download the scan results Excel summary file
$connectionStringToStorageAccount = "DefaultEndpointsProtocol=https;AccountName=......."
$convertedScanResultsDownloadLocalFolder = "C:\ScanResults\"
$storageAccountContext = New-AzureStorageContext -ConnectionString $connectionStringToStorageAccount
$convertScanResultSplitted = $convertScanResult.ExportedReportLocation -split "/"
$containerName = $convertScanResultSplitted[3]
Get-AzureStorageBlobContent -Blob ($convertScanResult.ExportedReportLocation -split $containerName + '/')[1] `
-Container $containerName `
-Destination $convertedScanResultsDownloadLocalFolder `
-Context $storageAccountContext
}

Reference


For a full set of Azure SQL-related PowerShell cmdlets, take a look at the Azure RM SQL PowerShell documentation. The new cmdlets supporting Advanced Threat Protection and SQL Vulnerability Assessment are:
























































Cmdlet Usage

Enable-AzureRmSqlServerAdvancedThreatProtection


Enables Advanced Threat Protection on a server.

Get-AzureRmSqlServerAdvancedThreatProtectionPolicy


Gets the Advanced Threat Protection policy of a server.

Disable-AzureRmSqlServerAdvancedThreatProtection


Disables Advanced Threat Protection on a server.

Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings


Updates the vulnerability assessment settings of a database

Get-AzureRmSqlDatabaseVulnerabilityAssessmentSettings


Returns the vulnerability assessment settings of a database

Clear-AzureRmSqlDatabaseVulnerabilityAssessmentSettings


Clear the vulnerability assessment settings of a database

Set-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline


Sets the vulnerability assessment rule baseline.

Get-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline


Gets the vulnerability assessment rule baseline for a given rule.

Clear-AzureRmSqlDatabaseVulnerabilityAssessmentRuleBaseline


Clears the vulnerability assessment rule baseline. First set the baseline before using this cmdlet to clear it.

Start-AzureRmSqlDatabaseVulnerabilityAssessmentScan


Triggers the start of a vulnerability assessment scan

Get-AzureRmSqlDatabaseVulnerabilityAssessmentScanRecord


Gets all vulnerability assessment scan record(s) associated with a given database.

Convert-AzureRmSqlDatabaseVulnerabilityAssessmentScan


Converts vulnerability assessment scan results to an Excel file




Get started now with VA PowerShell Cmdlets


Get started now with managing your Azure SQL vulnerability assessments at scale using PowerShell cmdlets.

Install the latest Azure Resource Manager Module containing the new cmdlets at the AzureRM PowerShell Gallery .

Documentation for all supported Azure SQL-related PowerShell cmdlets can be found at Azure RM SQL PowerShell .

For more details on the SQL Vulnerability Assessment, see the SQL Vulnerability Assessment documentation .

To learn more about VA, and see an assessment in action on Azure SQL Database, check out this Channel 9 demo .

Try it out and let us know what you think!