Comment nettoyer la base Usage and Health

Dernièrement j’ai dû installer un nouveau serveur de développement SharePoint 2013. [AutoSpInstaller][1] facilite grandement la vie. Mais au bout d’un moment, le disque de données est plein. Souvenez vous de la notification Windows Low disk space warning, tellement plein qu’aucun 0 ou 1 ne pouvait s’y inscrire.

[][2]
Votre disque est plein

Un utilitaire d’analyse de disque m’indique de la base Usage And Health prend plus de 20Go. Vous en conviendrez c’est exagérer pour un environnement de développement.

1 – Réduire la durée de rétention des informations d’usage

Get-SPUsageDefinition | ForEach-Object {Set-SPUsageDefinition -Identity $_.name -DaysRetained 1}</pre>

## 2 – Exécuter le timer job qui va purger la table {#2--exécuter-le-timer-job-qui-va-purger-la-table}

<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-powershell" data-lang="powershell">Get-SPTimerJob | Where-Object { $_.title <span style="color:#f92672">-like</span> <span style="color:#e6db74">&#34;*usage data*&#34;</span> } | Start-SPTimerJob&lt;/pre&gt;

<span style="color:#75715e">## 3 – Effectuer un shrink de la base Usage And Health dans SQL Management Studio {#3--effectuer-un-shrink-de-la-base-usage-and-health-dans-sql-management-studio}</span>

[&lt;img class=<span style="color:#e6db74">&#34;wp-image-634 size-full&#34;</span> title=<span style="color:#e6db74">&#34;Skrink de la base Usage And Health&#34;</span> src=<span style="color:#e6db74">&#34;/wp-content/uploads/2015/03/UsageAndHealth.png?fit=705%2C632&#34;</span> alt=<span style="color:#e6db74">&#34;UsageAndHealth&#34;</span> srcset=<span style="color:#e6db74">&#34;/wp-content/uploads/2015/03/UsageAndHealth.png?resize=300%2C269 300w, /wp-content/uploads/2015/03/UsageAndHealth.png?w=705 705w&#34;</span> sizes=<span style="color:#e6db74">&#34;(max-width: 705px) 100vw, 705px&#34;</span> data-recalc-dims=<span style="color:#e6db74">&#34;1&#34;</span> /&gt;][3]  
_Espace libre disponible sur la base Usage And Health_

Voilà une petite astuce qui peut sauver votre environnement.

<span style="color:#75715e">## Mise à jour du 27/03/2015 {#mise-à-jour-du-27032015}</span>

La commande **Set-SPUsageService -UsageLogMaxSpaceGB X** qui permettait de limiter la taille maximale ne fonctionne pas pour SharePoint 2013.

Si vous voulez vous débarrasser complètement de ces informations.

&lt;div class=<span style="color:#e6db74">&#34;highlight&#34;</span>&gt;&lt;pre style=<span style="color:#e6db74">&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;</span>&gt;&lt;code class=<span style="color:#e6db74">&#34;language-powershell&#34;</span> data-lang=<span style="color:#e6db74">&#34;powershell&#34;</span>&gt;Set-SPUsageService -LoggingEnabled $False

Get-SPUsageDefinition | &lt;span style=<span style="color:#e6db74">&#34;color:#66d9ef&#34;</span>&gt;<span style="color:#66d9ef">ForEach</span>&lt;/span&gt;-Object {Set-SPUsageDefinition -Identity $_.name -Enable&lt;span style=<span style="color:#e6db74">&#34;color:#960050;background-color:#1e0010&#34;</span>&gt;<span style="color:#960050;background-color:#1e0010">:</span>&lt;/span&gt;$False}&amp;lt;/pre&amp;gt;

 [1]&lt;span style=<span style="color:#e6db74">&#34;color:#960050;background-color:#1e0010&#34;</span>&gt;<span style="color:#960050;background-color:#1e0010">:</span>&lt;/span&gt; &lt;span style=<span style="color:#e6db74">&#34;color:#66d9ef&#34;</span>&gt;%&lt;/span&gt;20http&lt;span style=<span style="color:#e6db74">&#34;color:#960050;background-color:#1e0010&#34;</span>&gt;<span style="color:#960050;background-color:#1e0010">:</span>&lt;/span&gt;//autospinstaller.codeplex.com/
 [2]&lt;span style=<span style="color:#e6db74">&#34;color:#960050;background-color:#1e0010&#34;</span>&gt;<span style="color:#960050;background-color:#1e0010">:</span>&lt;/span&gt; /wp-content/uploads/2015/03/YourDriveIsFull.png
 [3]&lt;span style=<span style="color:#e6db74">&#34;color:#960050;background-color:#1e0010&#34;</span>&gt;<span style="color:#960050;background-color:#1e0010">:</span>&lt;/span&gt; /wp-content/uploads/2015/03/UsageAndHealth.png&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</code></pre></div>