-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
387 additions
and
418 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
Active Directory/AD Groups/Get Foreign Security Principals in Groups.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# List all foreign security principals in Active Directory that are a member of any group | ||
$FSPContainer = $Domain.ForeignSecurityPrincipalsContainer | ||
Get-ADObject -Filter 'ObjectClass -eq "foreignSecurityPrincipal"' -Properties 'msds-principalname','memberof' -SearchBase $FSPContainer -Server $GlobalCatalog | | ||
Get-ADObject -Filter 'ObjectClass -eq "foreignSecurityPrincipal"' -Properties 'msds-principalname', 'memberof' -SearchBase $FSPContainer -Server $GlobalCatalog | | ||
Where-Object { $_.memberof -ne $null } | ForEach-Object { | ||
$AllForeignSecurityPrincipalMembers.Add($_) | ||
} |
10 changes: 5 additions & 5 deletions
10
... Directory/AD Groups/Remove Disabled Computer from All Groups Except Domain Computers.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
Active Directory/AD Users/Remove-DisabledUsersFromAllGroups.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 43 additions & 44 deletions
87
Active Directory/Domain Services/AD Permissions Class Types.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,60 @@ | ||
# Create a hash table of all permission class and sub-class types from the AD schema. | ||
$ObjectTypeGUID = @{} | ||
(Get-ADObject -SearchBase (Get-ADRootDSE).SchemaNamingContext -LDAPFilter '(SchemaIDGUID=*)' -Properties Name, SchemaIDGUID). | ||
ForEach({$ObjectTypeGUID.Add([GUID]$_.SchemaIDGUID,$_.Name)}) | ||
ForEach({ $ObjectTypeGUID.Add([GUID]$_.SchemaIDGUID, $_.Name) }) | ||
|
||
(Get-ADObject -SearchBase "CN=Extended-Rights,$((Get-ADRootDSE).ConfigurationNamingContext)" -LDAPFilter '(ObjectClass=ControlAccessRight)' -Properties Name, RightsGUID).ForEach({$ObjectTypeGUID.Add([GUID]$_.RightsGUID,$_.Name)}) | ||
(Get-ADObject -SearchBase "CN=Extended-Rights,$((Get-ADRootDSE).ConfigurationNamingContext)" -LDAPFilter '(ObjectClass=ControlAccessRight)' -Properties Name, RightsGUID).ForEach({ $ObjectTypeGUID.Add([GUID]$_.RightsGUID, $_.Name) }) | ||
$ObjectTypeGUID | Format-Table -AutoSize | ||
|
||
# Example: | ||
$ObjectTypeGUID[[GUID]'00299570-246d-11d0-a768-00aa006e0529'] | ||
|
||
|
||
function Get-NameForGUID{ | ||
function Get-NameForGUID { | ||
# Portions from http://blog.wobl.it/2016/04/active-directory-guid-to-friendly-name-using-just-powershell/ | ||
[CmdletBinding()] | ||
[OutputType([System.String])] | ||
Param( | ||
[guid]$guid, | ||
[string]$ForestDNSName | ||
) | ||
Begin{ | ||
IF (!$ForestDNSName) | ||
{ $ForestDNSName = (Get-ADForest $ForestDNSName).Name } | ||
|
||
IF ($ForestDNSName -notlike "*=*") | ||
{ $ForestDNSNameDN = "DC=$($ForestDNSName.replace('.', ',DC='))" } | ||
|
||
$ExtendedRightGUIDs = "LDAP://cn=Extended-Rights,cn=configuration,$ForestDNSNameDN" | ||
$PropertyGUIDs = "LDAP://cn=schema,cn=configuration,$ForestDNSNameDN" | ||
} | ||
Process{ | ||
If($guid -eq "00000000-0000-0000-0000-000000000000"){ | ||
Return "All" | ||
}Else{ | ||
$rightsGuid = $guid | ||
$property = "cn" | ||
$SearchAdsi = ([ADSISEARCHER]"(rightsGuid=$rightsGuid)") | ||
$SearchAdsi.SearchRoot = $ExtendedRightGUIDs | ||
$SearchAdsi.SearchScope = "OneLevel" | ||
[CmdletBinding()] | ||
[OutputType([System.String])] | ||
Param( | ||
[guid]$guid, | ||
[string]$ForestDNSName | ||
) | ||
Begin { | ||
IF (!$ForestDNSName) | ||
{ $ForestDNSName = (Get-ADForest $ForestDNSName).Name } | ||
|
||
IF ($ForestDNSName -notlike '*=*') | ||
{ $ForestDNSNameDN = "DC=$($ForestDNSName.replace('.', ',DC='))" } | ||
|
||
$ExtendedRightGUIDs = "LDAP://cn=Extended-Rights,cn=configuration,$ForestDNSNameDN" | ||
$PropertyGUIDs = "LDAP://cn=schema,cn=configuration,$ForestDNSNameDN" | ||
} | ||
Process { | ||
If ($guid -eq '00000000-0000-0000-0000-000000000000') { | ||
Return 'All' | ||
} Else { | ||
$rightsGuid = $guid | ||
$property = 'cn' | ||
$SearchAdsi = ([ADSISEARCHER]"(rightsGuid=$rightsGuid)") | ||
$SearchAdsi.SearchRoot = $ExtendedRightGUIDs | ||
$SearchAdsi.SearchScope = 'OneLevel' | ||
$SearchAdsiRes = $SearchAdsi.FindOne() | ||
If ($SearchAdsiRes) { | ||
Return $SearchAdsiRes.Properties[$property] | ||
} Else { | ||
$SchemaGuid = $guid | ||
$SchemaByteString = '\' + ((([guid]$SchemaGuid).ToByteArray() | ForEach-Object { $_.ToString('x2') }) -Join '\') | ||
$property = 'ldapDisplayName' | ||
$SearchAdsi = ([ADSISEARCHER]"(schemaIDGUID=$SchemaByteString)") | ||
$SearchAdsi.SearchRoot = $PropertyGUIDs | ||
$SearchAdsi.SearchScope = 'OneLevel' | ||
$SearchAdsiRes = $SearchAdsi.FindOne() | ||
If($SearchAdsiRes){ | ||
If ($SearchAdsiRes) { | ||
Return $SearchAdsiRes.Properties[$property] | ||
}Else{ | ||
$SchemaGuid = $guid | ||
$SchemaByteString = "\" + ((([guid]$SchemaGuid).ToByteArray() | %{$_.ToString("x2")}) -Join "\") | ||
$property = "ldapDisplayName" | ||
$SearchAdsi = ([ADSISEARCHER]"(schemaIDGUID=$SchemaByteString)") | ||
$SearchAdsi.SearchRoot = $PropertyGUIDs | ||
$SearchAdsi.SearchScope = "OneLevel" | ||
$SearchAdsiRes = $SearchAdsi.FindOne() | ||
If($SearchAdsiRes){ | ||
Return $SearchAdsiRes.Properties[$property] | ||
}Else{ | ||
Write-Host -f Yellow $guid | ||
Return $guid.ToString() | ||
} | ||
} Else { | ||
Write-Host -f Yellow $guid | ||
Return $guid.ToString() | ||
} | ||
} | ||
} | ||
} | ||
} |
9 changes: 4 additions & 5 deletions
9
Active Directory/Domain Services/Get-TrustedDomainNetBIOSNames.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.