This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| informatique:windows:powershell [2024/11/04 14:35] – [Exporter les utilisateurs d'un AD] yahiko | informatique:windows:powershell [2025/08/12 13:20] (current) – yahiko | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| ===== Lancer un script Powershell à partir d'un Batch ===== | ===== Lancer un script Powershell à partir d'un Batch ===== | ||
| - | <codedoc | + | <code code: |
| Powershell.exe -executionpolicy remotesigned -File NOMDUSCRIPT.ps1 | Powershell.exe -executionpolicy remotesigned -File NOMDUSCRIPT.ps1 | ||
| </ | </ | ||
| Line 111: | Line 111: | ||
| </ | </ | ||
| + | ===== Changer la casse d'une variable ===== | ||
| + | |||
| + | <code powershell> | ||
| + | # En majuscule | ||
| + | CHAINE.ToUpper() | ||
| + | |||
| + | # En minuscule | ||
| + | CHAINE.ToLower() | ||
| + | </ | ||
| + | |||
| + | ===== Remplacer un caractère ou un espace ===== | ||
| + | |||
| + | C'est pas beau. | ||
| + | |||
| + | <code powershell> | ||
| + | # Un espace | ||
| + | $string = $string -replace " ","" | ||
| + | |||
| + | # Un apostrophe | ||
| + | $string = $string -replace "'","" | ||
| + | </ | ||
| + | |||
| + | ===== Groupes AD ===== | ||
| + | ==== Lister les groupes d'une OU ==== | ||
| + | <code powershell> | ||
| + | Get-AdGroup -filter * -searchbase " | ||
| + | </ | ||
| + | |||
| + | ==== Lister les utilisateurs d'un groupe ==== | ||
| + | <code powershell> | ||
| + | Get-ADGroupMember -Identity " | ||
| + | </ | ||
| + | |||
| + | ===== Vérifier les droits NTFS d'un dossier ===== | ||
| + | |||
| + | Non récursif. | ||
| + | |||
| + | <code powershell> | ||
| + | Get-NTFSAccess ' | ||
| + | |||
| + | Path: D: | ||
| + | |||
| + | |||
| + | Account | ||
| + | ------- | ||
| + | BUILTIN\Administrateurs | ||
| + | BUILTIN\Administrateurs | ||
| + | AUTORITE NT\Système | ||
| + | CREATEUR PROPRIETAIRE | ||
| + | BUILTIN\Utilisateurs | ||
| + | BUILTIN\Utilisateurs | ||
| + | BUILTIN\Utilisateurs | ||
| + | </ | ||
| + | |||
| + | ===== Lister les utilisateurs connectés en RDP ===== | ||
| + | |||
| + | <code powershell> | ||
| + | Get-CimInstance -ClassName Win32_UserProfile | where {-not $_.Special} | select LocalPath, LastUseTime, | ||
| + | </ | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | |||
| + | ===== Uptime ===== | ||
| + | |||
| + | <code powershell> | ||
| + | (get-date) – (gcim Win32_OperatingSystem).LastBootUpTime | ||
| + | </ | ||