Partager via


Invoke-BpaModel

Invoke-BpaModel

The Invoke-BPAModel cmdlet allows you to start a Best Practices Analyzer (BPA) scan for a specific model that is installed on your computer.

Syntax

Invoke-BPAModel [-BestPracticesModelId] <string> [[-ArgumentTable] <hashtable>] [<CommonParameters>]

Detailed Description

The Invoke-BPAModel cmdlet allows you to start a Best Practices Analyzer (BPA) scan for a specific model that is installed on your Windows-based computer. The model is specified either by using the parameter BestPracticesModelId, or by piping the results of the Get-BPAModel cmdlet into an Invoke-BPAModel cmdlet. If a model is specified in the command, after the BPA scan has been performed, the results of the scan are available as an XML file.

Parameters

-ArgumentTable <hashtable>

Specifies model-specific instructions with which to start BPA scans. For example, the ArgumentTable parameter can allow an administrator to pass parameters to the model as expected by the model author. These arguments, passed as a set of name-value pairs, change how a BPA scan runs.

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

3

-BestPracticesModelId <string>

Specifies the command ID of the Best Practices Analyzer model on which you want to start a scan. You can also use the short form of the -BestPracticesModelId parameter, -Id.

Attributes

Name Value

Required?

true

Accept wildcard characters?

false

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Position?

2

-CommonParameter

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see About Common Parameter

Input and Return Types

The input type is the type of the objects that you can pipe to the cmdlet. The return type is the type of the objects that the cmdlet emits.

Input Type

.

Return Type

System.Collections.Generic.List<Microsoft.BestPractices.CoreInterface.InvokeBpaModelOutput>. The output object encapsulates the results of the cmdlet that you entered. It contains information such as the BPA model ID, the success or failure of the cmdlet, and other details.

Notes

  • The Invoke-BPAModel cmdlet cannot be canceled after it has been started.

    If the cmdlet is used to perform a single-model scan, and the cmdlet is canceled (by using CTRL+C) before the temporary results file is copied to its final location, the temporary file is discarded, and any previous scan results file for the role is preserved. The message "Processing of Invoke-BPAModel canceled by user" is displayed, if the command is canceled before existing scan results files are overwritten.

    If the cmdlet is used to perform a scan of multiple models by piping in results from the Get-BPAModel cmdlet, and the command is canceled, scans that were completed before the cancel command was entered cannot be canceled. A scan in progress behaves as described above in the single-model scan cancellation scenario. Subsequent scans in the pipeline are canceled.

Examples

EXAMPLE 1

C:\PS>Invoke-BPAModel -BestPracticesModelId <Specified Model Id>

Description

-----------

The preceding example starts a BPA scan on the model that is represented by <Specified Model Id>.

Alternatively, you can complete the same task by running either of the two following cmdlets:

Invoke-BPAModel -Id <Specified Model Id>

- OR -

Invoke-BPAModel <Specified Model Id>

EXAMPLE 2

C:\PS>Invoke-BPAModel <Specified Model Id> -ArgumentTable @{context=domain; name=redmond.microsoft.com;}

Description

-----------

This example starts a BPA scan on the specified model ID. The -ArgumentTable parameter helps the administrator start a BPA scan with additional model-specific instructions; for example, by using the -ArgumentTable parameter on a model which requires other model parameters (context and name, for examples) to be passed to it, the administrator can specify the values of these model parameters by using the ArgumentTable parameter.

EXAMPLE 3

C:\PS>Get-BPAModel | Invoke-BPAModel

Description

-----------

The preceding example gets all BPA models that are installed on the computer, and then pipes the results of the Get-BPAModel cmdlet to Invoke-BPAModel to start a BPA scan on all models.

EXAMPLE 4

C:\PS>$BPAObj = Invoke-BPAModel <Specified Model Id>
C:\PS>$BPAObj[0].Detail

ModelId : <Specified Model Id>
Success : True
ScanTime : 10/21/2008 3:08:47 PM
InformationMessages : 5
WarningMessages : 4
ErrorMessages : 0
Description :

Description

-----------

In the preceding example, the Invoke-BPAModel cmdlet starts a BPA scan on the model specified by Specified Model Id, and saves the results of the command as a variable, BPAObj.

The second line of the command allows the administrator to view results of any specific object in the first line of the cmdlet by calling the variable into which the entire first line's results were saved, and then specifying the following: which object's results the administrator wants (in this example, the 0, or first, object), and which field of the results of that object (in this example, the Detail field) the administrator wants to view. The example shown returns the Detail field results of the Invoke-PAModel cmdlet that is run in the first line.

See Also

Reference

Get-BpaModel
Get-BpaResult
Set-BpaResult