PowerShell
PowerShell est un langage de programmation pour les systèmes Microsoft Windows.
Référence
- http://www.it-connect.fr/powershell-pour-les-debutants-1ere-partie/
- http://www.it-connect.fr/powershell-et-active-directory-modifier-le-domaine-des-adresses-mails/
- http://www.it-connect.fr/active-directory-supprimer-les-ordinateurs-dune-ou-en-powershell/
- http://www.it-connect.fr/creer-des-comptes-utilisateurs-par-lot-avec-powershell-v2-et-le-module-active-directory-server-2008-r2/
- http://www.it-connect.fr/chapitres/modifier-la-resolution-de-lecran/
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 :
- https://www.it-connect.fr/powershell-convertir-ps1-en-exe-executable/
- https://www.majorgeeks.com/files/details/ps1_to_exe.html
Interface graphique
- Exemple d'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
Script de mise à jour d'Active Directory
Lire les lignes d'un fichier
Avec le fichier suivant C:\tmp\source.csv
:
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
Premier script :
$fichier = Import-Csv "C:\tmp\source.csv" -Delimiter ";" Foreach ($ligne in $fichier) { Write-Host $ligne }
Le résultat du premier script est :
@{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}
Deuxième script :
Import-Csv "C:\tmp\source.csv" -Delimiter ";" | Foreach { Write-Host ("{0} {1} appartient au service {2}" -f $_.civilité, $_.nom, $_.service) }
Le résultat du deuxième script est :
M. Dupond appartient au service SI M. Martin appartient au service Commercial Mme De Fratte appartient au service Export
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