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:35] – [Exporter les utilisateurs d'un AD] yahikoinformatique:windows:powershell [2025/05/12 15:05] (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 110: Line 110:
 Get-ADUser -Filter * -Proerties * -SearchBase "OU=NOMDELOU,DC=DOMAINE,DC=TLD" | 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> </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>
 +
 +===== Groupes AD =====
 +==== Lister les groupes d'une OU ====
 +<code powershell>
 +Get-AdGroup -filter * -searchbase "OU=Groupes,OU=CLIENT,DC=DOMAINE,DC=LOCAL" | sort name | select name
 +</code>
 +
 +==== Lister les utilisateurs d'un groupe ====
 +<code powershell>
 +Get-ADGroupMember -Identity "Communication" | Format-Table Name, DistinguishedName
 +</code>
 +
 +===== Vérifier les droits NTFS d'un dossier =====
 +
 +Non récursif.
 +
 +<code powershell>
 +Get-NTFSAccess 'D:\DATA\partages\dossier'
 +
 +    Path: D:\DATA\partages\dossier (Inheritance enabled)
 +
 +
 +Account                             Access Rights  Applies to                Type           IsInherited   InheritedFrom
 +-------                             -------------  ----------                ----           -----------   -------------
 +BUILTIN\Administrateurs             FullControl    ThisFolderOnly            Allow          False
 +BUILTIN\Administrateurs             FullControl    ThisFolderSubfoldersAn... Allow          True          D:
 +AUTORITE NT\Système                 FullControl    ThisFolderSubfoldersAn... Allow          True          D:
 +CREATEUR PROPRIETAIRE               GenericAll     SubfoldersAndFilesOnly    Allow          True          D:
 +BUILTIN\Utilisateurs                ReadAndExec... ThisFolderSubfoldersAn... Allow          True          D:
 +BUILTIN\Utilisateurs                CreateDirec... ThisFolderAndSubfolders   Allow          True          D:
 +BUILTIN\Utilisateurs                CreateFiles    ThisFolderAndSubfolders   Allow          True          D:
 +</code>
 +
  
informatique/windows/powershell.1730730911.txt.gz · Last modified: 2024/11/04 14:35 by yahiko