Clear-SRMetadata

Removes unreferenced Storage Replica metadata.

Syntax

Clear-SRMetadata
     [[-ComputerName] <String>]
     [-NoRestart]
     [-Force]
     [-Name] <String>
     [-Logs]
     [-Partition]
     [-CimSession <CimSession[]>]
     [-ThrottleLimit <Int32>]
     [-AsJob]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]
Clear-SRMetadata
     [[-ComputerName] <String>]
     [-AllConfiguration]
     [-AllLogs]
     [-AllPartitions]
     [-NoRestart]
     [-Force]
     [-CimSession <CimSession[]>]
     [-ThrottleLimit <Int32>]
     [-AsJob]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]

Description

The Clear-SRMetadata cmdlet removes unreferenced Storage Replica metadata from the registry, partition, and System Volume Information folder. This orphaned metadata may exist after a failed partnership or replication group removal.

Do not run this cmdlet unless you have already tried to clean up by using the Remove-SRPartnership and Remove-SRGroup cmdlets.

Examples

Example 1: Delete all unreferenced log files

PS C:\>Clear-SRMetadata -AllLogs 
Confirm
Are you sure you want to perform this action? 
Clearing orphaned log files from Storage Replica log container. Are you sure you want to continue? 
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y

This command deletes all unreferenced log files from all log volumes on the computer.

Example 2: Delete unreferenced log files partition database entries

PS C:\>Clear-SRMetadata -AllLogs -AllPartitions -Verbose
Confirm
Are you sure you want to perform this action? 
Clearing orphaned log files from Storage Replica log container. Are you sure you want to continue? 
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
VERBOSE: Looking for orphaned Storage Replica logs on volume \\?\Volume{c9406624-d9e8-489d-9f29-e95c02bc13f9}\...
VERBOSE: 1 orphaned log directories were deleted. 
VERBOSE: 4 orphaned log files were deleted. 
VERBOSE: Looking for orphaned records in Storage Replica partition database. 
VERBOSE: No orphan records found in Storage Replica partition database.

This command deletes all unreferenced log files from all log volumes and unreferenced partition database entries from all data volumes on the computer. In this example you see that several log files were deleted.

Example 3: Clear logs for a replication group

This command gets the name of all the replication groups on the current computer by using the Format-List cmdlet. There is only one replication group on this computer. 
PS C:\>Get-SRGroup | Format-List -Property "name"
Name               : ReplicationGroup01

This command clears all logs for a replication group found in the first command. The command reports verbose output.
PS C:\>Clear-SRMetadata -Name "ReplicationGroup01" -Logs -Verbose
Confirm
Are you sure you want to perform this action? 
Clearing orphaned log files from Storage Replica log container. Are you sure you want to continue? 
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): y
VERBOSE: Looking for orphaned Storage Replica logs on volume e:\... 
VERBOSE: 1 orphaned log directories were deleted. 
VERBOSE: 16 orphaned log files were deleted.

This example clears all logs for a specific replication group and reports verbose output.

Parameters

-AllConfiguration

Indicates that this cmdlet removes all unreferenced Storage Replica registry and cluster resource entries. This parameter does not affect unclustered hosts.

Type:SwitchParameter
Aliases:AC
Position:1
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AllLogs

Indicates that this cmdlet removes all unreferenced Storage Replica logs from the hidden System Volume Information folders on all log drives.

Type:SwitchParameter
Aliases:AL
Position:2
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AllPartitions

Indicates that this cmdlet removes all unreferenced Storage Replica partition databases from all data drives.

Type:SwitchParameter
Aliases:AP
Position:3
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-AsJob

Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.

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

-CimSession

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

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

-ComputerName

Specifies a single replica host computer NetBIOS name or fully qualified domain name (FQDN). The default value is the local computer.

Type:String
Aliases:CN
Position:0
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Aliases:F
Position:100
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Logs

Indicates that this cmdlet removes the unreferenced Storage Replica logs from the hidden System Volume Information folders on the log drive for the replication group specified by the Name parameter.

Type:SwitchParameter
Aliases:LO
Position:3
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Specifies the name of the replication group for which this cmdlet clears data.

Type:String
Aliases:N
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NoRestart

Indicates that the computer does not restart after the cmdlet removes the entries. By default, the computer restarts. We do not support continuing to operate the computer and its storage after metadata cleanup. Restart as soon as possible.

Type:SwitchParameter
Aliases:NR
Position:98
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Partition

Indicates that this cmdlet removes all unreferenced Storage Replica partition databases from the data drives associated with the replication group specified by Name.

Type:SwitchParameter
Aliases:PA
Position:4
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ThrottleLimit

Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

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