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 [2024/11/04 14:34] 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 108: Line 108:
 ===== Exporter les utilisateurs d'un AD ===== ===== Exporter les utilisateurs d'un AD =====
 <code powershell> <code powershell>
-Get-ADUser -Filter * -Proerties * -SearchBase "OU=ETABLISSEMENT,DC=MAIRIE,DC=LOCAL" | select displayname,UserPrincipalName | export-csv -path C:\informatique\users.csv+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> </code>
  
informatique/windows/powershell.1730730873.txt.gz · Last modified: 2024/11/04 14:34 by yahiko