Search Wiki:

Windows Server AppFabric DB Reset Powershell Script


When developing a solution with Windows Server AppFabric from time to time you may want to clear the persistence and monitoring databases. This script makes it easy to do just that. It uses the default database names and assumes that you are using SQLExpress on your local machine as the server.

Change the database and/or server names as appropriate

import-module applicationserver
$ConfirmPreference = "None"  
 
# Warning - this will clear both the persistence and monitoring stores for AppFabric
# Useful when testing or developing solutions with AppFabric
 
# Remove the persistence db
Remove-ASPersistenceSqlDatabase -Force -Server ".\SQLExpress" -Database "AppFabricPersistenceDB"  
 
# Create the persistence DB
Initialize-ASPersistenceSqlDatabase -Admins $env:computername\AS_Administrators -Readers $env:computername\AS_Observers -Users "BUILTIN\IIS_IUSRS" -Database "AppFabricPersistenceDB" -Server ".\SQLExpress"  
 
# Clear the monitoring DB
Clear-ASMonitoringSqlDatabase -Database "AppFabricMonitoringDB" -Server ".\SQLExpress"

To run the script
C:\>PowerShell -file AppFabricDBReset.ps1
 
Database         : AppFabricPersistenceDB
Server           : .\SQLExpress
ConnectionString : Data Source=.\SQLExpress;Initial Catalog=AppFabricPersisteneDB
 
Database         : AppFabricPersistenceDB
Server           : .\SQLExpress
ConnectionString : Data Source=.\SQLExpress;Initial Catalog=AppFabricPersisteneDB
 
Database         : AppFabricMonitoringDB
Server           : .\SQLExpress
ConnectionString : Data Source=.\SQLExpress;Initial Catalog=AppFabricMonitorinDB;Integrated Security=True
 
Last edited Nov 11 2010 at 1:06 AM  by RonJacobs, version 4
Updating...
Page view tracker