« PowerShell » : différence entre les versions

Aller à la navigation Aller à la recherche
Ligne 45 : Ligne 45 :
* <source inline>Set-Service -Name wuauserv -StartupType Manual</source>
* <source inline>Set-Service -Name wuauserv -StartupType Manual</source>
* <source inline>Set-Service -Name wuauserv -StartupType Disabled</source>
* <source inline>Set-Service -Name wuauserv -StartupType Disabled</source>
== Script de mise à jour d'Active Directory ==
=== Lire les lignes d'un fichier ===
Avec le fichier suivant <code>C:\tmp\source.csv</code> :
<pre>
compte;civilité;nom;prénom;société;service
dupondp;M.;Dupond;Pierre;MaSociété;SI
martinj;M.;Martin;Jean;MaSociété;Commercial
defrattec;Mme;De Fratte;Catherine;MaSociété;Export
</pre>
Premier script :
<source>
$fichier = Import-Csv "C:\tmp\source.csv" -Delimiter ";"
Foreach ($ligne in $fichier) {
    Write-Host $ligne
    }
</source>
Le résultat du premier script est :
<pre>
@{compte=dupondp; nom=Dupond; prénom=Pierre; société=MaSociété; service=SI}
@{compte=martinj; nom=Martin; prénom=Jean; société=MaSociété; service=Commercial}
@{compte=defrattec; nom=De Fratte; prénom=Catherine; société=MaSociété; service=Export}
</pre>
Deuxième script :
<source>
Import-Csv "C:\tmp\source.csv" -Delimiter ";" | Foreach { Write-Host ("{0} {1} appartient au service {2}" -f $_.civilité, $_.nom, $_.service) }
</source>
Le résultat du deuxième script est :
<pre>
M. Dupond appartient au service SI
M. Martin appartient au service Commercial
Mme De Fratte appartient au service Export
</pre>


== Impression ==  
== Impression ==  

Version du 21 décembre 2022 à 14:30

PowerShell est un langage de programmation pour les systèmes Microsoft Windows.

Référence


Site de Marie Pascal Delamare, BTS SIO / STS SIO

Document

Gestion des path sous PowerShell, PDF, 31 pages :

Source de script

Gérer les autorisations NTFS avec PowerShell :

Copie de fichiers avec BITS (Background Intelligent Transfer Service) :

PowerShell : convertir PS1 en EXE ; création d'un exécutable :

Interface graphique

Windows10Debloater

Script si problème mise à jour Windows

Le service "Windows Update" s'appelle wuauserv :

  • Stop-Service -Name wuauserv
  • Start-Service -Name wuauserv
  • Set-Service -Name wuauserv -StartupType Automatic
  • Set-Service -Name wuauserv -StartupType Manual
  • Set-Service -Name wuauserv -StartupType Disabled

Impression

Supprimer toutes les fichiers des files d'attente d'impression :

Stop-Service Spooler 
Remove-Item "C:\Windows\System32\spool\PRINTERS\*.*" -Force 
Start-Service Spooler