-
Notifications
You must be signed in to change notification settings - Fork 0
/
ActiveDirectoryForest.psm1
80 lines (73 loc) · 2.42 KB
/
ActiveDirectoryForest.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function Get-ForestDomainControllers
{
(Get-ADForest).Domains | ForEach-Object {
Get-ADDomainController -Discover -DomainName $_ -ForceDiscover
}
}
function Get-ForestComputers
{
param (
#[Parameter(Mandatory=$true)]
[string]$filter="*",
[string]$Properties="Name"
)
(Get-ADForest).Domains | ForEach-Object {
((Get-ADDomainController -Discover -DomainName $_ -ForceDiscover).HostName)[0] | ForEach-Object {
Get-ADComputer -Filter $filter -Server $_ -Properties $Properties
}
}
}
function Get-ForestGroups
{
param (
#[Parameter(Mandatory=$true)]
[string]$filter="*",
[string]$Properties="Name"
)
(Get-ADForest).Domains | ForEach-Object {
((Get-ADDomainController -Discover -DomainName $_ -ForceDiscover).HostName)[0] | ForEach-Object {
Get-ADGroup -Filter $filter -Server $_ -Properties $Properties
}
}
}
function Get-ForestUsers
{
param (
#[Parameter(Mandatory=$true)]
[string]$filter="*",
[string]$Properties="Name"
)
(Get-ADForest).Domains | ForEach-Object {
((Get-ADDomainController -Discover -DomainName $_ -ForceDiscover).HostName)[0] | ForEach-Object {
Get-ADUser -Filter $filter -Server $_ -Properties $Properties
}
}
}
function Get-ForestComputerObjects
{
param (
#[Parameter(Mandatory=$true)]
[string]$filter='ObjectClass -eq "computer"',
[string]$Properties="Name"
)
Get-ADObject -Filter $filter -SearchBase "$((Get-ADDomain (Get-ADForest).Name).DistinguishedName)" -server "$(((Get-ADForest).GlobalCatalogs)[0]):3268" -Properties $Properties
}
function Get-ForestUserObjects
{
param (
#[Parameter(Mandatory=$true)]
[string]$filter='ObjectClass -eq "user"',
[string]$Properties="Name"
)
Get-ADObject -Filter $filter -SearchBase "$((Get-ADDomain (Get-ADForest).Name).DistinguishedName)" -server "$(((Get-ADForest).GlobalCatalogs)[0]):3268" -Properties $Properties
}
function Get-ForestObjects
{
param (
#[Parameter(Mandatory=$true)]
[string]$filter="*",
[string]$Properties="Name"
)
Get-ADObject -Filter $filter -SearchBase "$((Get-ADDomain (Get-ADForest).Name).DistinguishedName)" -server "$(((Get-ADForest).GlobalCatalogs)[0]):3268" -Properties $Properties
}
Export-ModuleMember -Function * -Variable * -Cmdlet *