Question
Sécurité répertoires
- PAYRAUDEAU
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 3
- Remerciements reçus 0
il y a 14 ans 6 mois #10223
par PAYRAUDEAU
Sécurité répertoires a été créé par PAYRAUDEAU
Bonjour à tous,
Je suis novice en PowerShell et j'aimerais un coup de main si possible sur un script que j’essaie de mettre en place.
Je voudrais lister les répertoires auxquels a accès un groupe d'utilisateurs AD.
J'ai donc testé diverses chose (gci, get -acl, etc ...). J'en suis arrivé à gci | get-acl | where {$_.group -contains $group} et j'initialise la variable $group avant. Mais ça ne donne rien.
En fait on m'a demandé sur quels répertoires a accès un groupe AD donné.
Je ne sais pas trop où ça coince ni comment avancer.
Merci pour votre aide.
Je suis novice en PowerShell et j'aimerais un coup de main si possible sur un script que j’essaie de mettre en place.
Je voudrais lister les répertoires auxquels a accès un groupe d'utilisateurs AD.
J'ai donc testé diverses chose (gci, get -acl, etc ...). J'en suis arrivé à gci | get-acl | where {$_.group -contains $group} et j'initialise la variable $group avant. Mais ça ne donne rien.
En fait on m'a demandé sur quels répertoires a accès un groupe AD donné.
Je ne sais pas trop où ça coince ni comment avancer.
Merci pour votre aide.
Connexion ou Créer un compte pour participer à la conversation.
- Richard Lazaro
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 530
- Remerciements reçus 0
il y a 14 ans 6 mois #10224
par Richard Lazaro
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Réponse de Richard Lazaro sur le sujet Re:Sécurité répertoires
Bonjour,
Voici 3(-4) commandes à connaître sous PowerShell pour se debrouiller la majorité du temps :
- Get-Command
- Get-Help
- Get-Member
(- Format-List *)
Dans ton cas, tu fais la recherche sur une propriété \"Group\", où as tu trouvé cette propriété ?
Si tu exécutes la commande suivante pour connaître les propriétés et méthodes que dispose le type d'objet retourné par la cmdlet Get-ACL, tu remarqueras qu'il n'existe pas de propriété Group :
[code:1]
Get-ChildItem | Get-Acl | Get-Member
[/code:1]
[code:1]
Name MemberType Definition
----
Access CodeProperty System.Security.AccessControl.AuthorizationRuleCollection Access{get=...
Group CodeProperty System.String Group{get=GetGroup;}
Owner CodeProperty System.String Owner{get=GetOwner;}
Path CodeProperty System.String Path{get=GetPath;}
Sddl CodeProperty System.String Sddl{get=GetSddl;}
AccessRuleFactory Method System.Security.AccessControl.AccessRule AccessRuleFactory(System.Sec...
AddAccessRule Method System.Void AddAccessRule(System.Security.AccessControl.FileSystemAcc...
AddAuditRule Method System.Void AddAuditRule(System.Security.AccessControl.FileSystemAudi...
AuditRuleFactory Method System.Security.AccessControl.AuditRule AuditRuleFactory(System.Secur...
Equals Method bool Equals(System.Object obj)
GetAccessRules Method System.Security.AccessControl.AuthorizationRuleCollection GetAccessRu...
GetAuditRules Method System.Security.AccessControl.AuthorizationRuleCollection GetAuditRul...
GetGroup Method System.Security.Principal.IdentityReference GetGroup(type targetType)
GetHashCode Method int GetHashCode()
GetOwner Method System.Security.Principal.IdentityReference GetOwner(type targetType)
GetSecurityDescriptorBinaryForm Method byte[] GetSecurityDescriptorBinaryForm()
GetSecurityDescriptorSddlForm Method string GetSecurityDescriptorSddlForm(System.Security.AccessControl.Ac...
GetType Method type GetType()
ModifyAccessRule Method bool ModifyAccessRule(System.Security.AccessControl.AccessControlModi...
ModifyAuditRule Method bool ModifyAuditRule(System.Security.AccessControl.AccessControlModif...
PurgeAccessRules Method System.Void PurgeAccessRules(System.Security.Principal.IdentityRefere...
PurgeAuditRules Method System.Void PurgeAuditRules(System.Security.Principal.IdentityReferen...
RemoveAccessRule Method bool RemoveAccessRule(System.Security.AccessControl.FileSystemAccessR...
RemoveAccessRuleAll Method System.Void RemoveAccessRuleAll(System.Security.AccessControl.FileSys...
RemoveAccessRuleSpecific Method System.Void RemoveAccessRuleSpecific(System.Security.AccessControl.Fi...
RemoveAuditRule Method bool RemoveAuditRule(System.Security.AccessControl.FileSystemAuditRul...
RemoveAuditRuleAll Method System.Void RemoveAuditRuleAll(System.Security.AccessControl.FileSyst...
RemoveAuditRuleSpecific Method System.Void RemoveAuditRuleSpecific(System.Security.AccessControl.Fil...
ResetAccessRule Method System.Void ResetAccessRule(System.Security.AccessControl.FileSystemA...
SetAccessRule Method System.Void SetAccessRule(System.Security.AccessControl.FileSystemAcc...
SetAccessRuleProtection Method System.Void SetAccessRuleProtection(bool isProtected, bool preserveIn...
SetAuditRule Method System.Void SetAuditRule(System.Security.AccessControl.FileSystemAudi...
SetAuditRuleProtection Method System.Void SetAuditRuleProtection(bool isProtected, bool preserveInh...
SetGroup Method System.Void SetGroup(System.Security.Principal.IdentityReference iden...
SetOwner Method System.Void SetOwner(System.Security.Principal.IdentityReference iden...
SetSecurityDescriptorBinaryForm Method System.Void SetSecurityDescriptorBinaryForm(byte[] binaryForm), Syste...
SetSecurityDescriptorSddlForm Method System.Void SetSecurityDescriptorSddlForm(string sddlForm), System.Vo...
ToString Method string ToString()
PSChildName NoteProperty System.String PSChildName=Contacts
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\U...
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\r...
PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerS...
AccessRightType Property System.Type AccessRightType {get;}
AccessRuleType Property System.Type AccessRuleType {get;}
AreAccessRulesCanonical Property System.Boolean AreAccessRulesCanonical {get;}
AreAccessRulesProtected Property System.Boolean AreAccessRulesProtected {get;}
AreAuditRulesCanonical Property System.Boolean AreAuditRulesCanonical {get;}
AreAuditRulesProtected Property System.Boolean AreAuditRulesProtected {get;}
AuditRuleType Property System.Type AuditRuleType {get;}
AccessToString ScriptProperty System.Object AccessToString {get=$toString = \"\";...
AuditToString ScriptProperty System.Object AuditToString {get=$toString = \"\";...
[/code:1]
Par contre, nous avons une propriété Access.
Je te laisse continuer la recherche pour que tu apprenes par toi même ;]
Voici 3(-4) commandes à connaître sous PowerShell pour se debrouiller la majorité du temps :
- Get-Command
- Get-Help
- Get-Member
(- Format-List *)
Dans ton cas, tu fais la recherche sur une propriété \"Group\", où as tu trouvé cette propriété ?
Si tu exécutes la commande suivante pour connaître les propriétés et méthodes que dispose le type d'objet retourné par la cmdlet Get-ACL, tu remarqueras qu'il n'existe pas de propriété Group :
[code:1]
Get-ChildItem | Get-Acl | Get-Member
[/code:1]
[code:1]
Name MemberType Definition
----
Access CodeProperty System.Security.AccessControl.AuthorizationRuleCollection Access{get=...
Group CodeProperty System.String Group{get=GetGroup;}
Owner CodeProperty System.String Owner{get=GetOwner;}
Path CodeProperty System.String Path{get=GetPath;}
Sddl CodeProperty System.String Sddl{get=GetSddl;}
AccessRuleFactory Method System.Security.AccessControl.AccessRule AccessRuleFactory(System.Sec...
AddAccessRule Method System.Void AddAccessRule(System.Security.AccessControl.FileSystemAcc...
AddAuditRule Method System.Void AddAuditRule(System.Security.AccessControl.FileSystemAudi...
AuditRuleFactory Method System.Security.AccessControl.AuditRule AuditRuleFactory(System.Secur...
Equals Method bool Equals(System.Object obj)
GetAccessRules Method System.Security.AccessControl.AuthorizationRuleCollection GetAccessRu...
GetAuditRules Method System.Security.AccessControl.AuthorizationRuleCollection GetAuditRul...
GetGroup Method System.Security.Principal.IdentityReference GetGroup(type targetType)
GetHashCode Method int GetHashCode()
GetOwner Method System.Security.Principal.IdentityReference GetOwner(type targetType)
GetSecurityDescriptorBinaryForm Method byte[] GetSecurityDescriptorBinaryForm()
GetSecurityDescriptorSddlForm Method string GetSecurityDescriptorSddlForm(System.Security.AccessControl.Ac...
GetType Method type GetType()
ModifyAccessRule Method bool ModifyAccessRule(System.Security.AccessControl.AccessControlModi...
ModifyAuditRule Method bool ModifyAuditRule(System.Security.AccessControl.AccessControlModif...
PurgeAccessRules Method System.Void PurgeAccessRules(System.Security.Principal.IdentityRefere...
PurgeAuditRules Method System.Void PurgeAuditRules(System.Security.Principal.IdentityReferen...
RemoveAccessRule Method bool RemoveAccessRule(System.Security.AccessControl.FileSystemAccessR...
RemoveAccessRuleAll Method System.Void RemoveAccessRuleAll(System.Security.AccessControl.FileSys...
RemoveAccessRuleSpecific Method System.Void RemoveAccessRuleSpecific(System.Security.AccessControl.Fi...
RemoveAuditRule Method bool RemoveAuditRule(System.Security.AccessControl.FileSystemAuditRul...
RemoveAuditRuleAll Method System.Void RemoveAuditRuleAll(System.Security.AccessControl.FileSyst...
RemoveAuditRuleSpecific Method System.Void RemoveAuditRuleSpecific(System.Security.AccessControl.Fil...
ResetAccessRule Method System.Void ResetAccessRule(System.Security.AccessControl.FileSystemA...
SetAccessRule Method System.Void SetAccessRule(System.Security.AccessControl.FileSystemAcc...
SetAccessRuleProtection Method System.Void SetAccessRuleProtection(bool isProtected, bool preserveIn...
SetAuditRule Method System.Void SetAuditRule(System.Security.AccessControl.FileSystemAudi...
SetAuditRuleProtection Method System.Void SetAuditRuleProtection(bool isProtected, bool preserveInh...
SetGroup Method System.Void SetGroup(System.Security.Principal.IdentityReference iden...
SetOwner Method System.Void SetOwner(System.Security.Principal.IdentityReference iden...
SetSecurityDescriptorBinaryForm Method System.Void SetSecurityDescriptorBinaryForm(byte[] binaryForm), Syste...
SetSecurityDescriptorSddlForm Method System.Void SetSecurityDescriptorSddlForm(string sddlForm), System.Vo...
ToString Method string ToString()
PSChildName NoteProperty System.String PSChildName=Contacts
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\U...
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\r...
PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerS...
AccessRightType Property System.Type AccessRightType {get;}
AccessRuleType Property System.Type AccessRuleType {get;}
AreAccessRulesCanonical Property System.Boolean AreAccessRulesCanonical {get;}
AreAccessRulesProtected Property System.Boolean AreAccessRulesProtected {get;}
AreAuditRulesCanonical Property System.Boolean AreAuditRulesCanonical {get;}
AreAuditRulesProtected Property System.Boolean AreAuditRulesProtected {get;}
AuditRuleType Property System.Type AuditRuleType {get;}
AccessToString ScriptProperty System.Object AccessToString {get=$toString = \"\";...
AuditToString ScriptProperty System.Object AuditToString {get=$toString = \"\";...
[/code:1]
Par contre, nous avons une propriété Access.
Je te laisse continuer la recherche pour que tu apprenes par toi même ;]
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Connexion ou Créer un compte pour participer à la conversation.
- PAYRAUDEAU
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 3
- Remerciements reçus 0
il y a 14 ans 6 mois #10233
par PAYRAUDEAU
Réponse de PAYRAUDEAU sur le sujet Re:Sécurité répertoires
Bonjour,
Je vais essayer de creuser ça.
Merci.
Je vais essayer de creuser ça.
Merci.
Connexion ou Créer un compte pour participer à la conversation.
- PAYRAUDEAU
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 3
- Remerciements reçus 0
il y a 14 ans 6 mois #10254
par PAYRAUDEAU
Réponse de PAYRAUDEAU sur le sujet Re:Sécurité répertoires
Bonjour,
Effectivement, j'ai trouvé la commande qui me fallait :
Get-ChildItem -Recurse | Get-Acl | Where-Object {$_.AccessToString -match \"groupname\"} | fl Path | Out-File c:\test.txt -Width 500
En revanche, j'ai un léger souci sur l'opérateur \"match\". En effet, la commande n'effectue pas la recherche seulement sur le nom du groupe mais également sur tout ce qui contient le nom du groupe. Exemple : si je recherche les répertoires sur lesquels le groupe \"Test\" a accès mais qu'il existe également un groupe nommé \"Test2\", la commande me retournera également les répertoires sur lesquels le groupe \"Test2\" a accès.
Je n'ai pas trouvé de réponse à ma question dans l'aide (man, about_, etc...).
Auriez-vous une réponse à m'apporter svp ?
Merci.
Effectivement, j'ai trouvé la commande qui me fallait :
Get-ChildItem -Recurse | Get-Acl | Where-Object {$_.AccessToString -match \"groupname\"} | fl Path | Out-File c:\test.txt -Width 500
En revanche, j'ai un léger souci sur l'opérateur \"match\". En effet, la commande n'effectue pas la recherche seulement sur le nom du groupe mais également sur tout ce qui contient le nom du groupe. Exemple : si je recherche les répertoires sur lesquels le groupe \"Test\" a accès mais qu'il existe également un groupe nommé \"Test2\", la commande me retournera également les répertoires sur lesquels le groupe \"Test2\" a accès.
Je n'ai pas trouvé de réponse à ma question dans l'aide (man, about_, etc...).
Auriez-vous une réponse à m'apporter svp ?
Merci.
Connexion ou Créer un compte pour participer à la conversation.
- Richard Lazaro
- Hors Ligne
- Membre platinium
-
Réduire
Plus d'informations
- Messages : 530
- Remerciements reçus 0
il y a 14 ans 6 mois #10255
par Richard Lazaro
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Réponse de Richard Lazaro sur le sujet Re:Sécurité répertoires
Bonjour,
Alors oui car l'opérande match utilise les regex.
Si tu as le nom complet du groupe (exemple : MYDOMAIN\GroupTest) Tu peux faire un truc du genre :
[code:1]
Get-ChildItem -Recurse `
| Get-Acl `
| Where-Object `
{ ($_.Access | ForEach-Object { Write-Output $_.IdentityReference }) -contains $groupName } `
| Format-List Path | Out-File c:\Temp\test.txt -Width 500
[/code:1]
Bien Cordialement,
Richard Lazaro.
Alors oui car l'opérande match utilise les regex.
Si tu as le nom complet du groupe (exemple : MYDOMAIN\GroupTest) Tu peux faire un truc du genre :
[code:1]
Get-ChildItem -Recurse `
| Get-Acl `
| Where-Object `
{ ($_.Access | ForEach-Object { Write-Output $_.IdentityReference }) -contains $groupName } `
| Format-List Path | Out-File c:\Temp\test.txt -Width 500
[/code:1]
Bien Cordialement,
Richard Lazaro.
Think-MS : (Get-Life).Days | %{ Learn-More }
\\"Problems cannot be solved by the same level of thinking that created them.\\" - Albert Einstein
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.040 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les débutants
- Sécurité répertoires