Clear-ASMonitoringSqlDatabase

Clear-ASMonitoringSqlDatabase

Purges data from the monitoring database. Optionally, you can direct the purged data to a remote archive destination monitoring database.

Syntax

Parameter Set: DatabaseNameAndServerName
Clear-ASMonitoringSqlDatabase -Database <String> [-Archive] [-CutoffTime <DateTime> ] [-MaxAge <TimeSpan> ] [-PurgeMode {<EventAgeMode> | <None> | <WFInstanceCompletedMode>} ] [-Server <String> ] [ <CommonParameters>]

Parameters

-Archive

Events are archived to another monitoring database as they are being deleted.  This requires that you have previously used Set-ASMonitoringSqlDatabaseArchiveConfiguration.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

-ConnectionString<String>

SQL Server connection string.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

-CutoffTime<DateTime>

All events in the database that were emitted before the cutoff time will be purged.  If not specified its value is calculated by taking the current time and subtracting the MaxAge parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

-Database<String>

Name of the SQL Server database to be cleared.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

-MaxAge<TimeSpan>

All events older than this TimeSpan will be deleted.  You may use this instead of –CutoffTime.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

-PurgeMode<PurgeModeType>

Determines how purging will be done using these options:

The acceptable values for this parameter are:

EventAgeMode

None

WFInstanceCompletedMode

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

-Server<String>

SQL instance name (e.g. MachineA or MachineA\SQLEXPRESS).

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

<CommonParameters>

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

Inputs

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

  • None

Outputs

The output type is the type of the objects that the cmdlet emits.

  • DatabaseInfo

Examples

Example 1

This cmdlet example purges from the MyServiceStore database completed instance records and corresponding activity events that have been in the database more than five days. It will exclude WF instance and activity events that are related to active instances.

PS C:\Windows\system32> Clear-ASMonitoringSqlDatabase -Database "MyServiceStore" -MaxAge 5 -PurgeMode WFInstanceCompletedModeConfirmAre you sure you want to perform this action?Performing operation "Clear-ASMonitoringSqlDatabase" on Target "MICROSO-XNMDH06\ MyServiceStore".[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): yDatabase : MyServiceStoreServer : MICROSO-XNMDH06ConnectionString : Data Source=MICROSO-XNMDH06;Initial Catalog= MyServiceStore;Integrated Security=True

Example 2

This cmdlet example purges from the MyServiceStore database all WCF and WF events, as well as WF instance records that may not be complete or that have been in the database more than 120 days. Because EventAgeMode is the default value for -PurgeMode, it did not need to be specified.

PS C:\Windows\system32> Clear-ASMonitoringSqlDatabase -Database "MyServiceStore" -MaxAge 120 -PurgeMode EventAgeModeDatabase : MyServiceStoreServer : MICROSO-XNMDH06ConnectionString : Data Source=MICROSO-XNMDH06;Initial Catalog= MyServiceStore;Integrated Security=True