My objective is to remove all ‘old’ account names on Profile shares since the domain is going away. These shares reside on a clustered file share environment and I need to run through each profile to remove any account with the ‘mmsasp’ domain in it.
The language mode is constrained language mode and I can 't seem to find a way around it.
Code
$Profiles = Get-ChildItem D:\Profiles foreach ($Profile in $Profiles){$acl = get-acl $Profile.FullName
$rules = $acl.Access | Where-Object {$_.identityreference -like “mmsasp”}foreach ($rule in $rules ){
write-host $Profile.FullName -ForegroundColor Yellow
$rule
$acl.RemoveAccessRule($rule)set-acl -Path $Profile.FullName -AclObject $acl
}
Example OutPut
D:\Profiles\easystreet FileSystemRights : FullControl AccessControlType : Allow IdentityReference : MMSASP\Domain Admins IsInherited : True InheritanceFlags : ContainerInherit, ObjectInherit PropagationFlags : NoneCannot invoke method. Method invocation is supported only on core types in this language mode.
At line:11 char:9
- $acl.RemoveAccessRule($rule)
- CategoryInfo : InvalidOperation: (
, RuntimeException
- FullyQualifiedErrorId : MethodInvocationNotSupportedInConstrainedLanguage