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">"*usage data*"</span> } | Start-SPTimerJob</pre>
<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>
[<img class=<span style="color:#e6db74">"wp-image-634 size-full"</span> title=<span style="color:#e6db74">"Skrink de la base Usage And Health"</span> src=<span style="color:#e6db74">"/wp-content/uploads/2015/03/UsageAndHealth.png?fit=705%2C632"</span> alt=<span style="color:#e6db74">"UsageAndHealth"</span> srcset=<span style="color:#e6db74">"/wp-content/uploads/2015/03/UsageAndHealth.png?resize=300%2C269 300w, /wp-content/uploads/2015/03/UsageAndHealth.png?w=705 705w"</span> sizes=<span style="color:#e6db74">"(max-width: 705px) 100vw, 705px"</span> data-recalc-dims=<span style="color:#e6db74">"1"</span> />][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.
<div class=<span style="color:#e6db74">"highlight"</span>><pre style=<span style="color:#e6db74">"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"</span>><code class=<span style="color:#e6db74">"language-powershell"</span> data-lang=<span style="color:#e6db74">"powershell"</span>>Set-SPUsageService -LoggingEnabled $False
Get-SPUsageDefinition | <span style=<span style="color:#e6db74">"color:#66d9ef"</span>><span style="color:#66d9ef">ForEach</span></span>-Object {Set-SPUsageDefinition -Identity $_.name -Enable<span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">:</span></span>$False}&lt;/pre&gt;
[1]<span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">:</span></span> <span style=<span style="color:#e6db74">"color:#66d9ef"</span>>%</span>20http<span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">:</span></span>//autospinstaller.codeplex.com/
[2]<span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">:</span></span> /wp-content/uploads/2015/03/YourDriveIsFull.png
[3]<span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">:</span></span> /wp-content/uploads/2015/03/UsageAndHealth.png</code></pre></div></code></pre></div>