Invoke-SqlAssessment

Esegue i controlli delle procedure consigliate per la valutazione SQL per un oggetto SQL Server scelto e restituisce i relativi risultati.

Sintassi

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

Descrizione

Il cmdlet Invoke-SqlAssessment esegue una valutazione per ogni oggetto di input e restituisce un elenco di raccomandazioni consigliate che devono essere applicate agli oggetti specificati. È consigliabile seguire i consigli specificati o meno. Per altre informazioni, vedere panoramica dell'API di valutazione SQL.

Questo cmdlet accetta i tipi di input seguenti:

  • 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
  • Stringa contenente il percorso di qualsiasi oggetto dei tipi precedenti
  • Raccolta di oggetti

È possibile ottenere oggetti di input con cmdlet SqlServer come Get-SqlInstance e Get-SqlDatabase o cmdlet di PowerShell di base, ad esempio Get-Item e Get-ChildItem. Inoltre, il cmdlet supporta il provider di PowerShell SQL Server, in modo che possa ottenere un oggetto dal relativo percorso. Il percorso può essere passato in modo esplicito, altrimenti verrà usato il percorso corrente.

La disponibilità di un controllo per un oggetto scelto varia in base alla versione SQL Server, alla piattaforma e al tipo di oggetto. Sono inoltre disponibili controlli che riguardano database specifici come tempdb o master. È anche possibile filtrare i controlli in base a tag, nomi e gravità con i parametri -MinSeverity e -Check.

È possibile ottenere un elenco di controlli applicabili all'oggetto SQL Server specificato con il cmdlet Get-SqlAssessmentItem.

Il cmdlet esegue solo controlli applicabili a un oggetto di input. Ad esempio, i controlli del database non verranno eseguiti per un'istanza SQL Server o un gruppo di disponibilità, anche se specificato in -Check list.

È possibile applicare configurazioni personalizzate con il parametro -Configuration. Gli esempi di personalizzazione sono disponibili in Github.

NOTA: Nella prima anteprima pubblica Invoke-SqlAssessment restituito oggetti AssessmentNote con proprietà CheckId e CheckName contenenti rispettivamente ID check e DisplayName. Nella seconda anteprima pubblica le due proprietà sono state sostituite con una singola proprietà Check che fornisce molto più dati. Supponendo che $note fosse un oggetto restituito da Invoke-SqlAssessment, è possibile accedere all'ID del controllo come $note.Check.Id anziché $note. CheckId o controllare la descrizione come $note. Check.Description. È possibile usare il parametro -FlattenOutput per ottenere risultati nel formato precedente con CheckId e CheckName. Questo parametro consente anche di mantenere la compatibilità con alcuni cmdlet come Write-SqlTableData. Per altre informazioni, vedere esempi da 12 a 14.

L'output del cmdlet Invoke-SqlAssessment è un elenco di procedure consigliate violate per ogni oggetto SQL Server specificato. Usare la proprietà Description per informazioni sulla procedura consigliata e sulla proprietà Message per scoprire come può essere risolta. Inoltre, ogni risultato del controllo contiene un collegamento alla documentazione online, che ti aiuterà a capire meglio il problema.

SQL Server nel supporto di macchine virtuali di Azure

Con i cmdlet di valutazione SQL è possibile valutare un'istanza di SQL Server nella macchina virtuale di Azure non solo come SQL Server prem, ma anche con regole specifiche per SQL Server nella macchina virtuale di Azure (quelle che usano informazioni sulla configurazione della macchina virtuale). Ad esempio, la regola AzSqlVmSize verifica che la macchina virtuale che ospita un'istanza di SQL Server nella macchina virtuale di Azure sia di dimensioni consigliate.

Per usare queste regole, connettersi ad Azure con Azure PowerShell Modulo e assicurarsi che il modulo Az.ResourceGraph sia installato.

Accedere con Azure PowerShell prima di richiamare la valutazione SQL su un SQL Server nell'istanza di macchina virtuale di Azure. L'esempio 16 mostra il processo di accesso interattivo e la selezione della sottoscrizione.

NOTA: È possibile usare la connessione all'account di Azure persistente tra sessioni di PowerShell, ad esempio richiamare Connect-AzAccount in una sessione e omettere questo comando in un secondo momento. Tuttavia, la versione corrente dei cmdlet di valutazione SQL richiede che il modulo Az.ResourceGraph venga importato in modo esplicito in questo caso: Import-Module Az.ResourceGraph

Esempio

Esempio 1: Richiamare la valutazione per l'istanza predefinita locale

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.
...

In questo esempio viene illustrato come ottenere tutte le procedure consigliate per l'istanza predefinita di SQL Server in esecuzione nel computer corrente.

Esempio 2: Richiamare la valutazione con il cmdlet PSProvider

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.
...

In questo esempio viene illustrato come ottenere tutte le raccomandazioni consigliate per l'istanza predefinita di SQL Server.

Esempio 3: Richiamare la valutazione con il percorso del provider 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.
...

In questo esempio viene illustrato come ottenere tutte le raccomandazioni consigliate per l'istanza predefinita di SQL Server.

Esempio 4: Richiamare la valutazione con la configurazione personalizzata

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
...

In questo esempio viene illustrato come applicare la configurazione personalizzata per ottenere un set modificato di consigli sulle procedure consigliate. Le configurazioni personalizzate sono descritte nei file JSON. I set di regole personalizzati profileA.json e profileB.json hanno disabilitato alcuni controlli e sono stati introdotti alcuni nuovi. Uno dei nuovi controlli da profileA.json ha rilevato un problema con la configurazione corrente dell'istanza di SQL Server. Visitare la cartella esempi di valutazione SQL in Github per scoprire come eseguire la personalizzazione.

Esempio 5: Richiamare la valutazione per tutte le istanze

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.
...

Questo esempio mostra il cmdlet Invoke-SqlAssessment che accetta un set di istanze di SQL Server tramite pipeline.

Esempio 6: Eseguire la valutazione per un set filtrato o traget

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.
...

Questo esempio mostra il cmdlet Invoke-SqlAssessment che accetta un set di istanze di SQL Server tramite pipeline. Il set viene filtrato con il cmdlet di PowerShell Where-Object standard.

Esempio 7: Richiamare la valutazione per un database in base al nome

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

In questo esempio viene illustrato il cmdlet Invoke-SqlAssessment che accetta il nome di un database. In questo caso non è stato rilevato alcun problema.

Esempio 8: Richiamare la valutazione per un database in base al percorso

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

In questo esempio viene illustrato il cmdlet Invoke-SqlAssessment che accetta il percorso di un database SQL Server.

Esempio 9: Rilevare problemi elevati per un database

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

In questo esempio viene illustrato il cmdlet Invoke-SqlAssessment che valuta la posizione corrente. Vengono segnalati solo problemi elevati.

Esempio 10: Eseguire controlli selezionati per tag

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

In questo esempio viene illustrato il cmdlet Invoke-SqlAssessment che esegue tutti i controlli correlati al backup per ogni SQL Server istanza nel server locale.

Esempio 11: Eseguire controlli selezionati in modo interattivo

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.

La seconda riga di questo esempio mostra l'acquisizione di controlli per un $serverInstance e la selezione di alcuni di essi in modo interattivo. Gli elementi selezionati vengono archiviati in una variabile di matrice, che viene quindi usata come input per il cmdlet Invoke-SqlAssessment . Vengono eseguiti solo controlli selezionati durante il processo di valutazione.

Esempio 12: Effetto del parametro -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....

In questo esempio viene illustrata la differenza tra gli oggetti restituiti con o senza -FlattenOutput parametro. Il parametro sostituisce un enorme oggetto Check complesso con due proprietà di stringa CheckId e CheckName. Questo è utile per scopi di serializzazione (vedere l'esempio successivo).

Il primo comando mostra un oggetto semplice con tutte le proprietà della stringa di tipo.

Il secondo comando mostra un altro oggetto con due proprietà non stringa: Verifica e Gravità.

Il terzo comando mostra il set completo di dati accessibili con la proprietà Check.

Esempio 13: Eseguire di nuovo controlli non riusciti

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.

In questo esempio viene illustrato come è possibile riutilizzare un controllo restituito con i risultati della valutazione. È possibile eseguire nuovamente i controlli che hanno prodotto AssessmentNotes prima.

Esempio 14: Archiviare i risultati della valutazione in una tabella

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

La seconda riga di questo esempio mostra l'uso del parametro -FlattenOutput con Write-SqlTableData cmdlet per archiviare i risultati della valutazione in un database SQL.

Esempio 15: Specificare le credenziali in modo esplicito

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

In questo esempio viene illustrato come richiamare la valutazione SQL con credenziali specificate in modo esplicito.

Esempio 16: Richiamare la valutazione per un SQL Server nell'istanza di macchina virtuale di Azure

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

In questo esempio viene illustrato come richiamare la valutazione per un SQL Server nell'istanza di macchina virtuale di Azure.

Una connessione di sottoscrizione di Azure attiva consente di SQL Server nei controlli correlati alle macchine virtuali di Azure (AzSqlVmSize in questo esempio). La prima riga si connette a un account Azure per ottenere dati da Azure Resource Graph. La seconda riga è facoltativa.

Per eseguire questi controlli, la valutazione SQL richiede il modulo Az.ResourceGraph.

Parametri

-Check

Uno o più controlli, controllare gli ID o i tag.

Per ogni oggetto check, Invoke-SqlAssessment viene eseguito che controlla se supporta l'oggetto di input.

Per ogni ID controllo, Invoke-SqlAssessment esegue il controllo corrispondente se supporta l'oggetto di input.

Per i tag, Invoke-SqlAssessment esegue controlli con uno di questi tag.

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

-Configuration

Specifica i percorsi dei file contenenti la configurazione personalizzata. I file di personalizzazione verranno applicati alla configurazione predefinita nell'ordine specificato. L'ambito è limitato solo a questa chiamata al cmdlet.

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

-FlattenOutput

Indica che questo cmdlet produce oggetti semplici di tipo Microsoft.SqlServer.Management.Assessment.Cmdlets.AssessmentNoteFlat anziché Microsoft.SqlServer.Management.Assessment.Cmdlets.AssessmentNote.

Regular AssessmentNote restituito da Invoke-SqlAssessment contiene riferimenti ad altri oggetti complessi utili, ad esempio Check (vedere l'esempio 12). Con la proprietà Check è possibile ottenere la descrizione del controllo o riutilizzare il controllo (vedere l'esempio 13). Tuttavia, alcuni cmdlet non supportano proprietà complesse. Ad esempio, Write-SqlTableData genererà un errore durante il tentativo di scrivere AssessmentNote in un database. Per evitare questo problema, è possibile usare il parametro -FlattenOutput per sostituire la proprietà Check con due stringhe semplici: CheckId e CheckName (vedere l'esempio 14).

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

-InputObject

Specifica un oggetto SQL Server o il percorso di un oggetto di questo tipo. Il cmdlet esegue la valutazione per questo oggetto. Quando questo parametro viene omesso, la posizione corrente viene usata come oggetto di input. Se il percorso corrente non è un oggetto SQL Server supportato, il cmdlet segnala un errore.

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

-MinSeverity

Specifica il livello di gravità minimo per i controlli da trovare. Ad esempio, i controlli dei livelli Low, Medium o Information non verranno restituiti quando -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

Input

System.String[]

Microsoft.SqlServer.Management.Smo.SqlSmoObject[]

Output

Microsoft.SqlServer.Assessment.Cmdlets.AssessmentNote