Site Tools


informatique:windows:powershell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
informatique:windows:powershell [2023/09/14 08:45] yahikoinformatique:windows:powershell [2025/01/23 14:58] (current) yahiko
Line 8: Line 8:
  
 ===== Lancer un script Powershell à partir d'un Batch ===== ===== Lancer un script Powershell à partir d'un Batch =====
-<codedoc code:batch>+<code code:batch>
 Powershell.exe -executionpolicy remotesigned -File NOMDUSCRIPT.ps1 Powershell.exe -executionpolicy remotesigned -File NOMDUSCRIPT.ps1
 </code> </code>
Line 106: Line 106:
 </code> </code>
  
 +===== Exporter les utilisateurs d'un AD =====
 +<code powershell>
 +Get-ADUser -Filter * -Proerties * -SearchBase "OU=NOMDELOU,DC=DOMAINE,DC=TLD" | select displayname,UserPrincipalName | export-csv -path C:\informatique\users.csv
 +</code>
 +
 +===== Changer la casse d'une variable =====
 +
 +<code powershell>
 +# En majuscule
 +CHAINE.ToUpper()
 +
 +# En minuscule
 +CHAINE.ToLower()
 +</code>
 +
 +===== Remplacer un caractère ou un espace =====
 +
 +C'est pas beau.
 +
 +<code powershell>
 +# Un espace
 +$string = $string -replace " ",""
 +
 +# Un apostrophe
 +$string = $string -replace "'",""
 +</code>
 +
 +===== Lister les membres d'un groupe AD =====
 +<code powershell>
 +Get-ADGroupMember -Identity "Communication" | Format-Table Name, DistinguishedName
 +</code>
  
informatique/windows/powershell.1694681122.txt.gz · Last modified: 2023/09/14 08:45 by yahiko