Quelques astuces utiles pour PowerShell
A force de travailler sur SharePoint et plus généralement sur les environnements Windows, on dipose de quelques astuces Powershell qui peuvent faire gagner du temps. J’aimerai en partager quelques unes avec vous.
Astuce 1 – Obtenir la version de Powershell
$PsVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1
$PSVersionTable.PSVersion.Major
3
</pre>
Utile pour vérifier la version de powershell avant l’exécution du script.
<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"><span style="color:#66d9ef">If</span>($PSVersionTable.PSVersion.Major <span style="color:#f92672">-lt</span> 3)
{
Write-host <span style="color:#e6db74">"Ce script nécessite PowerShell 3.0 minimum pour s'exécuter"</span> -foregroundcolor red
Exit 1
}</pre>
<span style="color:#75715e">## Astuce 2 – Compter les caractères, mots, lignes dans un fichier {#astuce-2--compter-les-caractères-mots-lignes-dans-un-fichier}</span>
<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>><span style=<span style="color:#e6db74">"color:#75715e"</span>><span style="color:#75715e"># nombre de lignes</span></span>
Get-Content C:dossierfichier.txt | Measure-Object <span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">–</span></span>Line
<span style=<span style="color:#e6db74">"color:#75715e"</span>><span style="color:#75715e"># nombre de caractères</span></span>
Get-Content C:dossierfichier.txt | Measure-Object -Character
<span style=<span style="color:#e6db74">"color:#75715e"</span>><span style="color:#75715e"># nombre de mots</span></span>
Get-Content C:dossierfichier.txt | Measure-Object <span style=<span style="color:#e6db74">"color:#960050;background-color:#1e0010"</span>><span style="color:#960050;background-color:#1e0010">–</span></span>Word&lt;/pre&gt;
<span style=<span style="color:#e6db74">"color:#75715e"</span>><span style="color:#75715e">## Astuce 3 – Rechercher dans une chaine de caractères {#astuce-3-rechercher-dans-une-chaine-de-caractères}</span></span>
<span style=<span style="color:#e6db74">"color:#f92672"</span>><span style="color:#f92672">-like</span></span> recherche une concordance dans une chaine et supporte les wildcards (métacaractères en français)
<span style=<span style="color:#e6db74">"color:#f92672"</span>><span style="color:#f92672">-match</span></span> recherche une concordance dans une chaine et supporte les expressions régulières
&lt;div class=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#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;&lt;span style=<span style="color:#e6db74">&#34;color:#75715e&#34;</span>&gt;<span style="color:#75715e"># utilisation de -like&lt;/span&gt;</span></span>
&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;bloc1.bloc2.zip&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-like&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;.zip&amp;#39;&lt;/span&gt;</span></span>
&amp;amp;gt; False
&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;bloc1.bloc2.zip&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-like&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;*.zip&amp;#39;&lt;/span&gt;</span></span>
&amp;amp;gt; True
&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#75715e&#34;</span>&gt;<span style="color:#75715e"># utilisation de -match&lt;/span&gt;</span></span>
&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;bloc1.bloc2.zip&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-match&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;(w+.){3}(zip)&amp;#39;&lt;/span&gt;</span></span>
&amp;amp;gt; False
&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;bloc1.bloc2.bloc3.zip&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-match&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;(w+.){3}(zip)&amp;#39;&lt;/span&gt;</span></span>
&amp;amp;gt; True
&amp;lt;/pre&amp;gt;
&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#f92672&#34;</span>&gt;<span style="color:#f92672">-contains</span>&lt;/span&gt; est un faux ami. Cela fonctionne uniquement avec les tableaux et permet de savoir si une valeur en fait partie.</span>
&amp;lt;div class=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;highlight&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;pre style=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;code class=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;language-powershell&amp;#34;&lt;/span&gt; data-lang=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;powershell&amp;#34;&lt;/span&gt;&amp;gt;$coll = @(&amp;lt;span style=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#39;one&amp;amp;#39;&amp;lt;/span&amp;gt;,&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#39;two&amp;amp;#39;&amp;lt;/span&amp;gt;,&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#39;three&amp;amp;#39;&amp;lt;/span&amp;gt;,&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#39;four&amp;amp;#39;&amp;lt;/span&amp;gt;)&lt;/span&gt;</span></span>
$coll &amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#f92672&amp;#34;&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#f92672&#34;&gt;-contains&lt;/span&gt;&amp;lt;/span&amp;gt; &amp;lt;span style=&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#39;one&amp;amp;#39;&amp;lt;/span&amp;gt;&amp;amp;lt;/pre&amp;amp;gt;&lt;/span&gt;</span></span>
&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#75715e&amp;#34;&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#75715e&#34;&gt;## Astuce 4 – Découper une chaine de caractères {#astuce-4--découper-une-chaine-de-caractères}&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;lt;div class=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;highlight&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;lt;pre style=&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;lt;code class=&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#34;language-powershell&amp;amp;#34;&amp;lt;/span&amp;gt; data-lang=&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#34;powershell&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;$returnCode = Select-String &amp;amp;lt;span style=&amp;lt;span style=&amp;#34;color:#e6db74&amp;#34;&amp;gt;&amp;amp;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#39;Retour=&amp;amp;amp;#39;&amp;amp;lt;/span&amp;amp;gt; $LogSuperVision &amp;amp;lt;span style=&amp;amp;#34;color:#f92672&amp;amp;#34;&amp;amp;gt;-CaseSensitive&amp;amp;lt;/span&amp;amp;gt; | Select -exp line | %{ $_.split(&amp;amp;lt;span style=&amp;amp;#34;color:#e6db74&amp;amp;#34;&amp;amp;gt;&amp;amp;amp;#39; &amp;amp;amp;#39;&amp;amp;lt;/span&amp;amp;gt;)[7] }&amp;amp;amp;lt;/pre&amp;amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#75715e&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;## Astuce 5 – Concatener des variables {#astuce-5--concatener-des-variables}&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;lt;div class=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;highlight&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;lt;pre style=&amp;amp;lt;span style=&amp;amp;#34;color:#e6db74&amp;amp;#34;&amp;amp;gt;&amp;amp;amp;#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;lt;code class=&amp;amp;lt;span style=&amp;amp;#34;color:#e6db74&amp;amp;#34;&amp;amp;gt;&amp;amp;amp;#34;language-powershell&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt; data-lang=&amp;amp;lt;span style=&amp;amp;#34;color:#e6db74&amp;amp;#34;&amp;amp;gt;&amp;amp;amp;#34;powershell&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;$rep_test = &amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;amp;#34;color:#e6db74&amp;amp;#34;&amp;amp;gt;&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#39;e:test&amp;amp;amp;amp;#39;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
$nom_index = &amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#39;myIndex&amp;amp;amp;amp;#39;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
$idx = 5
&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;# mauvaise méthode&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;$rep_test$nom_index_$idx&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;amp;gt; e:text5
&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;# bonne méthode&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;$rep_test$nom_index`_$idx&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;amp;gt; e:textmyIndex_5
&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;longueur : &amp;amp;amp;lt;/span&amp;amp;amp;gt;$($coll.length)&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;amp;gt; longueur &amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;lt;span style=&amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;#34;&amp;amp;gt;:&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt; 4&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;gt;
&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;## Astuce 6 – Travailler avec les taches planifiées {#astuce-6--travailler-avec-les-taches-planifiées}&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
A partir de Windows 8.1 et Windows Server 2012 R2 (PowerShell 4.0), vous pouvez utiliser de nouvelles commandlets ***-ScheduledTask** (**New-ScheduledTask, Get-ScheduledTask, Stop-ScheduledTask**, &amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;lt;span style=&amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;#34;&amp;amp;gt;…&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;)&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
[&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;text-decoration: underline;&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;color: #800080;&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;https&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;amp;gt;:&amp;amp;amp;lt;/span&amp;amp;amp;gt;//technet.microsoft.com/en-us/library/jj649816.aspx&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;][1]&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
Mais sur les OS antérieur il faut passer par la commande **schtasks**.
&amp;amp;amp;amp;lt;div class=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;highlight&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;pre style=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;code class=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;language-powershell&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt; data-lang=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;powershell&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;# créer une tache planifiée&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
Schtasks /Create /TN myTask /TR notepad.exe /sc DAILY /ST 08&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;amp;gt;:&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;00 /RU administrateur /RP Pa$$w0rd&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;# exécuter une tache planifiée&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
schtasks /Run /TN myTask
&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;# supprimer une tache planifiée&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
schtasks /Delete /TN myTask/F&amp;amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;amp;gt;
&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;## Astuce 7 – Trouver les fichiers ou dossiers antérieurs à une date {#astuce-7--trouver-les-fichiers-ou-dossiers-antérieurs-à-une-date}&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
La commande Get-ChildItem permet de lister le contenu d&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;amp;gt;’&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;une arborescence et dispose d&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;amp;gt;’&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;option très pratique. Le _piping_ permet de combiner d&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;amp;gt;&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;#34;&amp;amp;amp;gt;’&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;autres sélecteur de manière facile et efficace.&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;amp;lt;div class=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;highlight&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;pre style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;code class=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;language-powershell&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt; data-lang=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;powershell&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;color:#75715e&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;# Fichiers et dossiers qui ont plus de 30j d&amp;amp;amp;amp;amp;amp;#39;existence&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
Get-ChildItem &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;–&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;Path $folderPath | Where-Object LastWriteTime &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;–&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;lt (Get-Date).AddDays(-30)&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;color:#75715e&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;# Fichiers qui ont plus de 30j d&amp;amp;amp;amp;amp;amp;#39;existence et dont le nom correspond au modèle de l&amp;amp;amp;amp;amp;amp;#39;expression régulière $regexPattern&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
Get-ChildItem -Path &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;#34;$folderPath*&amp;amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt; -Include $regexPattern &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;amp;#34;color:#f92672&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;amp;gt;-File&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt; | Where-Object LastWriteTime &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;amp;gt;–&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;lt (Get-Date).AddDays(-30)&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
&amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;color:#75715e&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#75715e&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;# Dossier qui ont plus de 30j d&amp;amp;amp;amp;amp;amp;#39;existence&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
Get-ChildItem -Directory &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;–&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;Path $folderPath | Where-Object LastWriteTime &amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;–&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;lt (Get-Date).AddDays($nbDays)&amp;amp;amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;</span></span>
Si comme moi vous utilisez PowerShell, vous avez probablement noté vos propres astuces.
[1]&amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;lt;span style=&amp;amp;lt;span style=&amp;lt;span style=&lt;span style=<span style=<span style="color:#e6db74">"color:#e6db74"</span>>&<span style="color:#75715e">#34;color:#e6db74&#34;</span>&gt;&amp;<span style="color:#75715e">#34;color:#e6db74&amp;#34;&lt;/span&gt;&amp;gt;&amp;amp;&lt;span style=&#34;color:#75715e&#34;&gt;#34;color:#e6db74&amp;amp;#34;&amp;lt;/span&amp;gt;&amp;amp;gt;&amp;amp;amp;&amp;lt;span style=&amp;#34;color:#75715e&amp;#34;&amp;gt;#34;color:#e6db74&amp;amp;amp;#34;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;amp;gt;&amp;amp;amp;amp;&amp;amp;lt;span style=&amp;amp;#34;color:#75715e&amp;amp;#34;&amp;amp;gt;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;&amp;amp;amp;lt;span style=&amp;amp;amp;#34;color:#75715e&amp;amp;amp;#34;&amp;amp;amp;gt;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;:&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt; https&amp;amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#e6db74&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;amp;#34;&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;span style=&amp;amp;amp;amp;#34;color:#960050;background-color:#1e0010&amp;amp;amp;amp;#34;&amp;amp;amp;amp;gt;:&amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;gt;//technet.microsoft.com/en-us/library/jj649816.aspx&amp;amp;amp;amp;amp;lt;/code&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;lt;/div&amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/code&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/pre&amp;amp;amp;amp;gt;&amp;amp;amp;amp;lt;/div&amp;amp;amp;amp;gt;&amp;amp;amp;lt;/span&amp;amp;amp;gt;&amp;amp;amp;lt;/code&amp;amp;amp;gt;&amp;amp;amp;lt;/pre&amp;amp;amp;gt;&amp;amp;amp;lt;/div&amp;amp;amp;gt;&amp;amp;lt;/span&amp;amp;gt;&amp;amp;lt;/code&amp;amp;gt;&amp;amp;lt;/pre&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</span></code></pre></div></span></code></pre></div>