Invoke-SqlAssessment

선택한 SQL Server 개체에 대한 SQL 평가 모범 사례 검사를 실행하고 결과를 반환합니다.

Syntax

Invoke-SqlAssessment
      [-Check <Object[]>]
      [[-InputObject] <PSObject>]
      [-Configuration <PSObject>]
      [-MinSeverity <SeverityLevel>]
      [-FlattenOutput]
      [<CommonParameters>]

Description

Invoke-SqlAssessment cmdlet은 각 입력 개체에 대한 평가를 실행하고 지정된 개체에 적용해야 하는 모범 사례 권장 사항 목록을 반환합니다. 지정된 권장 사항을 따르는 것은 사용자에게 달려 있습니다. 자세한 내용은 SQL 평가 API 개요를 참조하세요.

이 cmdlet은 다음 입력 형식을 허용합니다.

  • Microsoft.SqlServer.Management.Smo.Server
  • Microsoft.SqlServer.Management.Smo.Database
  • Microsoft.SqlServer.Management.Smo.AvailabilityGroup
  • Microsoft.SqlServer.Management.Smo.FileGroup
  • Microsoft.SqlServer.Management.Smo.RegisteredServers.RegisteredServer
  • 위 형식의 개체에 대한 경로가 포함된 문자열
  • 개체 컬렉션

Get-SqlInstance 및 Get-SqlDatabase 같은 SqlServer cmdlet 또는 Get-Item 및 Get-ChildItem과 같은 기본 PowerShell cmdlet을 사용하여 입력 개체를 가져올 수 있습니다. 또한 cmdlet은 SQL Server PowerShell 공급자를 지원하므로 경로에서 개체를 가져올 수 있습니다. 경로를 명시적으로 전달할 수 있으며, 그렇지 않으면 현재 경로가 사용됩니다.

선택한 개체에 대한 검사 가용성은 SQL Server 버전, 플랫폼 및 개체 유형에 따라 달라집니다. 또한 또는 master와 같은 tempdb 특정 데이터베이스를 대상으로 하는 검사가 있습니다. -MinSeverity 및 -Check 매개 변수를 사용하여 태그, 이름 및 심각도별로 검사를 추가로 필터링할 수 있습니다.

Get-SqlAssessmentItem cmdlet을 사용하여 지정된 SQL Server 개체에 적용 가능한 검사 목록을 가져올 수 있습니다.

cmdlet은 입력 개체에 적용할 수 있는 검사만 실행합니다. 예를 들어 데이터베이스 검사는 -Check 목록에 지정된 경우에도 SQL Server instance 또는 가용성 그룹에 대해 실행되지 않습니다.

사용자 지정 구성은 -Configuration 매개 변수를 사용하여 적용할 수 있습니다. 사용자 지정 예제는 Github에서 사용할 수 있습니다.

참고. 첫 번째 공개 미리 보기 에서 Invoke-SqlAssessment 는 각각 Check의 ID와 DisplayName이 포함된 CheckId 및 CheckName 속성이 있는 AssessmentNote 개체를 반환했습니다. 두 번째 공개 미리 보기에서 두 속성은 훨씬 더 많은 데이터를 제공하는 단일 Check 속성으로 대체되었습니다. $note Invoke-SqlAssessment에서 반환된 개체라고 가정하면 검사 ID에 $note 대신 $note.Check.Id 액세스할 수 있습니다. CheckId 또는 $note 검사 설명입니다. Check.Description. -FlattenOutput 매개 변수를 사용하여 CheckId 및 CheckName을 사용하여 이전 형식의 결과를 가져올 수 있습니다. 또한 이 매개 변수는 Write-SqlTableData와 같은 일부 cmdlet과의 호환성을 유지하는 데 도움이 됩니다. 자세한 내용은 예제 12-14를 참조하세요.

Invoke-SqlAssessment cmdlet의 출력은 지정된 모든 SQL Server 개체에 대해 위반된 모범 사례 목록입니다. Description 속성을 사용하여 모범 사례 및 Message 속성에 대해 알아보고 해결 방법을 알아봅니다. 또한 모든 검사 결과에는 온라인 설명서에 대한 링크가 포함되어 있어 문제를 더 잘 파악하는 데 도움이 됩니다.

Azure VM 지원의 SQL Server

SQL 평가 cmdlet을 사용하면 온-프레미스 SQL Server 뿐만 아니라 Azure VM의 SQL Server 관련된 규칙(가상 머신 구성에 대한 정보를 사용하는 규칙)을 사용하여 Azure VM에서 SQL Server instance 평가할 수 있습니다. 예를 들어 AzSqlVmSize 규칙은 Azure VM에서 SQL Server instance 호스트하는 VM의 크기가 권장되는지 확인합니다.

이러한 규칙을 사용하려면 Azure PowerShell 모듈을 사용하여 Azure에 연결하고 Az.ResourceGraph 모듈이 설치되어 있는지 확인합니다.

Azure VM instance SQL Server 대해 SQL 평가를 호출하기 전에 Azure PowerShell 로그인합니다. 예제 16은 대화형 로그인 프로세스 및 구독 선택을 보여줍니다.

참고. PowerShell 세션 간에 유지되는 Azure 계정 연결을 사용할 수 있습니다. 즉, 한 세션에서 Connect-AzAccount 호출하고 나중에 이 명령을 생략할 수 있습니다. 그러나 현재 버전의 SQL 평가 cmdlet은 Az.ResourceGraph 모듈을 명시적으로 가져와야 합니다. Import-Module Az.ResourceGraph

예제

예제 1: 로컬 기본 instance 대한 평가 호출

PS:> Get-SqlInstance -ServerInstance localhost | Invoke-SqlAssessment

   TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                 Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                         
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.                                                                                      
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources.
...

이 예제에서는 현재 컴퓨터에서 실행되는 SQL Server 기본 instance 대한 모든 모범 사례 권장 사항을 가져오는 방법을 보여 줍니다.

예제 2: PSProvider cmdlet을 사용하여 평가 호출

PS:> Get-Item SQLSERVER:\SQL\localhost\default | Invoke-SqlAssessment

   TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                 Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                         
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.                                                                                      
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources.
...

이 예제에서는 SQL Server 기본 instance 대한 모든 모범 사례 권장 사항을 가져오는 방법을 보여 줍니다.

예제 3: PS 공급자 경로를 사용하여 평가 호출

PS:> Invoke-SqlAssessment SQLSERVER:\SQL\localhost\default

TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                 Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                         
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.                                                                                      
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources.
...

이 예제에서는 SQL Server 기본 instance 대한 모든 모범 사례 권장 사항을 가져오는 방법을 보여 줍니다.

예제 4: 사용자 지정 구성을 사용하여 평가 호출

PS:> Get-SqlInstance -ServerInstance '(local)' | Invoke-SqlAssessment -Configuration C:\profileA.json, C:\profileB.json

TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.
Medi A custom rule violation detected.                                  CustomRuleA           Profile A 1.0
...

이 예제에서는 사용자 지정 구성을 적용하여 수정된 모범 사례 권장 사항 집합을 가져오는 방법을 보여 줍니다. 사용자 지정 구성은 JSON 파일에 설명되어 있습니다. 사용자 지정 규칙 집합 profileA.json 및 profileB.json은 일부 검사를 사용하지 않도록 설정했으며 몇 가지 새로운 검사를 도입했습니다. profileA.json의 새 검사 중 하나가 SQL Server instance 현재 구성에 문제가 있는 것을 발견했습니다. 사용자 지정 방법을 알아보려면 Github의 SQL 평가 샘플 폴더 를 방문하세요.

예제 5: 모든 인스턴스에 대한 평가 호출

PS:> dir SQLSERVER:\SQL\localhost | Invoke-SqlAssessment

    TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                 Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                         
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.                                                                                      
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources.

    TargetPath : Server[@Name='LOCAL\INSTANCE1']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Medi Product version 14.0.1000 is not the latest available. Keep your   LatestCU              Microsoft Ruleset 0.1.202
     your SQL Server up to date and install Service Packs and
     Cumulative Updates as they are released.
...

이 예제에서는 파이프라인을 통해 SQL Server 인스턴스 집합을 수락하는 Invoke-SqlAssessment cmdlet을 보여 줍니다.

예제 6: 필터링된 집합 ot tragets에 대한 평가 실행

PS:> Get-SqlInstance -ServerInstance . | Where { $_.Name -Match '.*\d+' } | Invoke-SqlAssessment

    TargetPath : Server[@Name='LOCAL\INSTANCE1']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Medi Product version 14.0.1000 is not the latest available. Keep your   LatestCU              Microsoft Ruleset 0.1.202
     your SQL Server up to date and install Service Packs and
     Cumulative Updates as they are released.
...

이 예제에서는 파이프라인을 통해 SQL Server 인스턴스 집합을 수락하는 Invoke-SqlAssessment cmdlet을 보여 줍니다. 집합은 표준 PowerShell Where-Object cmdlet으로 필터링됩니다.

예제 7: 이름으로 데이터베이스에 대한 평가 호출

PS:> Get-SqlDatabase master -ServerInstance localhost | Invoke-SqlAssessment -Verbose
VERBOSE: Base ruleset version: 0.2.
VERBOSE: No recommendations for [master].

이 예제에서는 데이터베이스 이름을 수락하는 Invoke-SqlAssessment cmdlet을 보여 줍니다. 이 경우 문제가 발견되지 않았습니다.

예제 8: 경로별 데이터베이스 평가 호출

PS:> Invoke-SqlAssessment SQLSERVER:\SQL\localhost\default\Databases\master -Verbose
VERBOSE: Base ruleset version: 0.2.
VERBOSE: No recommendations for [master].

이 예제에서는 SQL Server 데이터베이스의 경로를 수락하는 Invoke-SqlAssessment cmdlet을 보여 줍니다.

예제 9: 데이터베이스에 대한 높은 문제 검색

PS:> cd SQLSERVER:\SQL\localhost\default\Databases\master
PS:> Invoke-SqlAssessment -MinSeverity High
VERBOSE: Base ruleset version: 0.2.
VERBOSE: No recommendations for [master].

이 예제에서는 현재 위치를 평가하는 Invoke-SqlAssessment cmdlet을 보여 줍니다. 높은 문제만 보고됩니다.

예제 10: 태그로 선택한 검사 실행

PS:> Get-SqlInstance -ServerInstance . | Invoke-SqlAssessment -Check Backup -Verbose
VERBOSE: Base ruleset version: 0.2.
VERBOSE: No recommendations for [LOCAL].

이 예제에서는 로컬 서버의 모든 SQL Server instance 대한 모든 백업 관련 검사를 실행하는 Invoke-SqlAssessment cmdlet을 보여 줍니다.

예제 11: 대화형으로 선택한 검사 실행

PS:> $serverInstance = Get-SqlInstance -ServerInstance '(local)'
PS:> $checks = Get-SqlAssessmentItem $serverInstance | Select Name, Description | Out-GridView -PassThru
PS:> Invoke-SqlAssessment $serverInstance -Check $checks

    TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID               Origin               
---- -------                                                            --------               ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                  Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                     
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures     Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.

이 예제의 두 번째 줄에서는 $serverInstance 대한 검사를 가져오고 그 중 일부를 대화형으로 선택하는 방법을 보여줍니다. 선택한 항목은 배열 변수에 저장된 다음 Invoke-SqlAssessment cmdlet에 대한 입력으로 사용됩니다. 선택한 검사만 평가 프로세스 중에 실행됩니다.

예제 12: -FlattenOutput 매개 변수의 효과

PS> $inst = Get-SqlInstance -ServerInstance . 
PS> Invoke-SqlAssessment $inst -FlattenOutput | Select -First 1 | Get-Member


   TypeName: Microsoft.SqlServer.Management.Assessment.Cmdlets.AssessmentNoteFlat

Name           MemberType Definition                    
----           ---------- ----------                    
Equals         Method     bool Equals(System.Object obj)
GetHashCode    Method     int GetHashCode()             
GetType        Method     type GetType()                
ToString       Method     string ToString()             
CheckId        Property   string CheckId {get;}         
CheckName      Property   string CheckName {get;}       
HelpLink       Property   string HelpLink {get;}        
Message        Property   string Message {get;}         
RulesetName    Property   string RulesetName {get;}     
RulesetVersion Property   string RulesetVersion {get;}  
Severity       Property   string Severity {get;}        
TargetPath     Property   string TargetPath {get;}      
TargetType     Property   string TargetType {get;}      


PS> Invoke-SqlAssessment $inst | Select -First 1 | Get-Member


   TypeName: Microsoft.SqlServer.Management.Assessment.Cmdlets.AssessmentNote

Name        MemberType Definition                                                             
----        ---------- ----------                                                             
Equals      Method     bool Equals(System.Object obj)                                         
GetHashCode Method     int GetHashCode()                                                      
GetType     Method     type GetType()                                                         
ToString    Method     string ToString()                                                      
Check       Property   Microsoft.SqlServer.Management.Assessment.Checks.ICheck Check {get;}   
HelpLink    Property   string HelpLink {get;}                                                 
Message     Property   string Message {get;}                                                  
Severity    Property   Microsoft.SqlServer.Management.Assessment.SeverityLevel Severity {get;}
TargetPath  Property   string TargetPath {get;}                                               
TargetType  Property   string TargetType {get;}

PS> (Invoke-SqlAssessment $inst | Select -First 1).Check | Get-Member


   TypeName: Microsoft.SqlServer.Management.Assessment.Checks.Check

Name          MemberType Definition                                                                                                                                     
----          ---------- ----------                                                                                                                                     
Equals        Method     bool Equals(System.Object obj)                                                                                                                 
GetHashCode   Method     int GetHashCode()                                                                                                                              
GetType       Method     type GetType()                                                                                                                                 
ToString      Method     string ToString()                                                                                                                              
Condition     Property   Microsoft.SqlServer.Management.Assessment....
Description   Property   string Description {get;set;}                                                                                                                  
DisplayName   Property   string DisplayName {get;set;}                                                                                                                  
Enabled       Property   bool Enabled {get;set;}                                                                                                                        
HelpLink      Property   string HelpLink {get;set;}                                                                                                                     
Id            Property   string Id {get;set;}                                                                                                                           
Level         Property   Microsoft.SqlServer.Management.Assessment....
Message       Property   string Message {get;set;}                                                                                                                      
OriginName    Property   string OriginName {get;set;}                                                                                                                   
OriginVersion Property   version OriginVersion {get;set;}                                                                                                               
Parameters    Property   System.Collections.Generic.IDictionary[str...
Probes        Property   System.Collections.Generic.List[Microsoft....
Tags          Property   System.Collections.Generic.HashSet[string]...
Target        Property   Microsoft.SqlServer.Management.Assessment....

이 예제에서는 -FlattenOutput 매개 변수를 사용하거나 사용하지 않고 반환된 개체 간의 차이점을 보여 있습니다. 매개 변수는 거대한 복합 Check 개체를 두 개의 문자열 속성 CheckId 및 CheckName으로 바꿉니다. 직렬화 용도로 유용합니다(다음 예제 참조).

첫 번째 명령은 문자열 형식의 모든 속성을 가진 단순 개체를 표시합니다.

두 번째 명령은 Check 및 Severity라는 두 개의 문자열이 아닌 속성이 있는 다른 개체를 표시합니다.

세 번째 명령은 Check 속성을 사용하여 액세스할 수 있는 풍부한 데이터 집합을 보여줍니다.

예제 13: 실패한 검사를 다시 실행

PS> $inst = Get-SqlInstance -ServerInstance .
PS> $results = Invoke-SqlAssessment $inst
PS> $results

   TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                 Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                         
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.                                                                                      
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources. 

PS> $results[1].Check.Description
This check detects deprecated or discontinued features used on target SQL Server instance. Deprecated features may be 
removed in a future release of SQL Server. Discontinued features have been removed from specific versions of SQL Server.

PS> Invoke-SqlAssessment $inst -Check $results[1].Check
   
   TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------                                                                                      
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000. 

PS> Invoke-SqlAssessment $inst -Check ($results).Check

   TargetPath : Server[@Name='LOCAL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Info Enable trace flag 834 to use large-page allocations to improve     TF834                 Microsoft Ruleset 0.1.202
     analytical and data warehousing workloads.                                                                         
Low  Detected deprecated or discontinued feature uses: String literals  DeprecatedFeatures    Microsoft Ruleset 0.1.202
     as column aliases, syscolumns, sysusers, SET FMTONLY ON, XP_API,                                                   
     Table hint without WITH, More than two-part column name. We                                                        
     recommend to replace them with features actual for SQL Server                                                      
     version 14.0.1000.                                                                                      
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources.

이 예제에서는 평가 결과와 함께 반환된 Check를 다시 사용할 수 있는 방법을 보여 줍니다. 이전에 AssessmentNotes를 생성한 검사를 다시 실행할 수 있습니다.

예제 14: 평가 결과를 테이블에 저장

PS:> $serverInstance = Get-SqlInstance -ServerInstance '(local)'
PS:> Invoke-SqlAssessment $serverInstance -FlattenOutput | 
     Write-SqlTableData -ServerInstance localhost -DatabaseName SqlAssessment -SchemaName Assessment -TableName Results -Force

이 예제의 두 번째 줄에서는 -FlattenOutput 매개 변수를 Write-SqlTableData cmdlet과 함께 사용하여 평가 결과를 SQL 데이터베이스에 저장하는 방법을 보여 줍니다.

예제 15: 자격 증명을 명시적으로 지정

PS> $cred = Get-Credential

PowerShell credential request
Enter your credentials.
User: Administrator
Password for user Administrator: ********

PS> $inst = Get-SqlInstance -ServerInstance 10.0.3.118 -Credential $cred
PS> Invoke-SqlAssessment $inst

   TargetPath : Server[@Name='ContosSQL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources

이 예제에서는 명시적으로 지정된 자격 증명을 사용하여 SQL 평가를 호출하는 방법을 보여 줍니다.

예제 16: Azure VM instance SQL Server 대한 평가 호출

PS> Connect-AzAccount
PS> Set-Subscription My-Pay-As-You-Go
PS> $cred = Get-Credential

PowerShell credential request
Enter your credentials.
User: Administrator
Password for user Administrator: ********

PS> $inst = Get-SqlInstance -ServerInstance 10.0.3.118 -Credential $cred
PS> Invoke-SqlAssessment $inst

   TargetPath : Server[@Name='ContosoAzureSQL']

Sev. Message                                                            Check ID              Origin               
---- -------                                                            --------              ------               
Medi Amount of single use plans in cache is high (100%). Consider       PlansUseRatio         Microsoft Ruleset 0.1.202
     enabling the Optimize for ad hoc workloads setting on heavy OLTP                                                   
     ad-hoc workloads to conserve resources 
Info Use memory optimized virtual machine sizes for the best            AzSqlVmSize           Microsoft Ruleset 0.1.202 
     performance of SQL Server workloads

이 예제에서는 Azure VM instance SQL Server 대한 평가를 호출하는 방법을 보여 줍니다.

활성 Azure 구독 연결을 사용하면 Azure VM 관련 검사에서 SQL Server 수 있습니다(이 예제에서는 AzSqlVmSize). 첫 번째 줄은 Azure 계정에 연결하여 Azure Resource Graph 데이터를 가져옵니다. 두 번째 줄은 선택 사항입니다.

이러한 검사를 실행하려면 SQL 평가에 Az.ResourceGraph 모듈이 필요합니다.

매개 변수

-Check

하나 이상의 검사, 검사 ID 또는 태그.

모든 검사 개체에 대해 Invoke-SqlAssessment는 입력 개체를 지원하는 경우 검사 실행됩니다.

모든 검사 ID에 대해 Invoke-SqlAssessment는 입력 개체를 지원하는 경우 해당 검사 실행합니다.

태그의 경우 Invoke-SqlAssessment 는 해당 태그를 사용하여 검사를 실행합니다.

Type:Object[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Configuration

사용자 지정 구성을 포함하는 파일의 경로를 지정합니다. 사용자 지정 파일은 지정된 순서로 기본 구성에 적용됩니다. scope 이 cmdlet 호출로만 제한됩니다.

Type:PSObject
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-FlattenOutput

이 cmdlet은 Microsoft.SqlServer.Management.Assessment.Cmdlets.AssessmentNote 대신 Microsoft.SqlServer.Management.Assessment.Cmdlets.AssessmentNote 형식의 간단한 개체를 생성 한다는 것을 나타냅니다.

Invoke-SqlAssessment 반환된 일반 AssessmentNote에는 Check와 같은 다른 유용한 복합 개체에 대한 참조가 포함되어 있습니다(예제 12 참조). Check 속성을 사용하면 검사 설명을 얻거나 검사 다시 사용할 수 있습니다(예제 13 참조). 그러나 일부 cmdlet은 복잡한 속성을 지원하지 않습니다. 예를 들어 Write-SqlTableData 데이터베이스에 AssessmentNote를 작성하는 동안 오류가 발생합니다. 이를 방지하려면 -FlattenOutput 매개 변수를 사용하여 Check 속성을 CheckId 및 CheckName이라는 두 개의 간단한 문자열로 바꿀 수 있습니다(예제 14 참조).

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InputObject

SQL Server 개체 또는 이러한 개체의 경로를 지정합니다. cmdlet은 이 개체에 대한 평가를 실행합니다. 이 매개 변수를 생략하면 현재 위치가 입력 개체로 사용됩니다. 현재 위치가 지원되는 SQL Server 개체가 아니면 cmdlet에서 오류를 알 수 있습니다.

Type:PSObject
Aliases:Target
Position:10
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-MinSeverity

검사를 찾을 수 있는 최소 심각도 수준을 지정합니다. 예를 들어 -MinSeverity High인 경우 낮음, 중간 또는 정보 수준에 대한 검사는 반환되지 않습니다.

Type:SeverityLevel
Aliases:Severity
Accepted values:Information, Low, Medium, High
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

입력

System.String[]

Microsoft.SqlServer.Management.Smo.SqlSmoObject[]

출력

Microsoft.SqlServer.Assessment.Cmdlets.AssessmentNote