IT Knowledge Base

Technical Repository

HowTo: Powershell – Enable Active Directory Inheritance on all objects

Import-Module ActiveDirectory $users = Get-ADUser -ldapfilter “(objectclass=user)” -searchbase “ou=Domain Users,dc=DOMAIN,dc=CORP” ForEach($user in $users) { # Binding the users to DS $ou = [ADSI](“LDAP://” + $user) $sec = $ou.psbase.objectSecurity if ($sec.get_AreAccessRulesProtected()) { $isProtected = $false ## allows inheritance $preserveInheritance = $true ## preserver inhreited rules $sec.SetAccessRuleProtection($isProtected, $preserveInheritance) $ou.psbase.commitchanges() Write-Host “$user is now inheriting permissions”; } else […]

Read More


HowTo: Linux Shell Scripting – Concatenate two variables with an underscore.

Wrap each variable in a curly brackets. #!/bin/bash _Directory=$/backups/ _FileName=$myfiles.bak echo ${_Direcotry}_${_FileName}) Output is: /backups/myfiles.bak

Read More


HowTo: Powershell – Check to see if the previous command completed successfully

The completion status of the previous command can be accessed via the special variable $?. This works best with non-terminating errors, terminating errors are the result of a direct throw or an exception getting thrown in .NET and they alter the flow of your code. Best to use a trap or try/catch statement to observe […]

Read More