diff --git a/Functions/Add-GroupMember.ps1 b/Functions/Add-GroupMember.ps1 new file mode 100644 index 0000000..c82990f Binary files /dev/null and b/Functions/Add-GroupMember.ps1 differ diff --git a/Functions/Disable-Account.ps1 b/Functions/Disable-Account.ps1 new file mode 100644 index 0000000..b72410c Binary files /dev/null and b/Functions/Disable-Account.ps1 differ diff --git a/Functions/Enable-Account.ps1 b/Functions/Enable-Account.ps1 new file mode 100644 index 0000000..718a3ec Binary files /dev/null and b/Functions/Enable-Account.ps1 differ diff --git a/Functions/Get-ADACL.ps1 b/Functions/Get-ADACL.ps1 new file mode 100644 index 0000000..59000f8 Binary files /dev/null and b/Functions/Get-ADACL.ps1 differ diff --git a/Functions/Get-Computer.ps1 b/Functions/Get-Computer.ps1 new file mode 100644 index 0000000..65841c3 --- /dev/null +++ b/Functions/Get-Computer.ps1 @@ -0,0 +1,165 @@ +#Requires -Version 2.0 +Function Get-Computer +{ + <# + .Synopsis + Retrieves all computer objects in a domain or container. + + .Description + Retrieves all computer objects in a domain or container. + + .Notes + Author : Oliver Lipkau + Blog : http://oliver.lipkau.net/blog/ + Version : v1.3 + Date : 2013-05-16 17:35:26 + + .Inputs + System.String + + .Parameter Name + Value to search for in: sAMAccountName, cn, displayName, dNSHostName and name + + .Parameter SearchRoot + A search base (the distinguished name of the search base object) defines the location in the directory from which the LDAP search begins + + .Parameter SizeLimit + Maximum of results shown for a query + + .Parameter SearchScope + A search scope defines how deep to search within the search base. + Base , or zero level, indicates a search of the base object only. + One level indicates a search of objects immediately subordinate to the base object, but does not include the base object itself. + Subtree indicates a search of the base object and the entire subtree of which the base object distinguished name is the topmost object. + + .Outputs + System.DirectoryServices.DirectoryEntry + + .Example + Get-Computer -Name WRK* -Enabled + ----------- + Description + Gets all domain enabled computers which names start with WRK + + .Example + Get-Computer -SearchRoot 'CN=Computers,DC=Domain,DC=com' -Disabled + ----------- + Description + Gets all disabled computers from the Computers container + + .Example + Get-Computer -Name "mpcc1d2c" -SearchRoot "domain.com" + ----------- + Description + Gets specific computer in a different domain + + .Example + "mpcc1d2c" | Get-Computer -SearchRoot "domain.com" + ----------- + Description + Gets computer from Pipe + + .Link + http://oliver.lipkau.net/blog/category/powershell/admanagement/ + #> + + [CmdletBinding(DefaultParametersetName="cn")] + param( + [ValidateNotNullOrEmpty()] + [Parameter(ValueFromPipeline = $true,Mandatory=$true,ParameterSetName='cn',Position=0)] + [Alias("CN")] + [string[]]$Name = "*", + + [Parameter(ValueFromPipeline = $true,Mandatory=$true,ParameterSetName='managed',Position=0)] + [ADSI[]]$ManagedBy, + + [string]$SearchRoot, + + [ValidateNotNullOrEmpty()] + [int]$PageSize = 1000, + + [ValidateNotNullOrEmpty()] + [int]$SizeLimit = 0, + + [ValidateNotNullOrEmpty()] + [ValidateSet("Base","OneLevel","Subtree")] + [string]$SearchScope = "SubTree", + + [switch]$Enabled, + + [switch]$Disabled + ) + + Begin + { + Write-Verbose "$($MyInvocation.MyCommand.Name):: Function started" + $c = 0 + + $disableStr = "userAccountControl:1.2.840.113556.1.4.803:=2" + $Enabledf = "(!$disableStr)" + $Disabledf = "($disableStr)" + + $root= New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") + $searcher = New-Object System.DirectoryServices.DirectorySearcher + } + + Process + { + switch ($PsCmdlet.ParameterSetName) { + "managed" { $SearchObjects = $ManagedBy.distinguishedName; break} + Default {$SearchObjects = $name; break} + } + foreach ($n in $SearchObjects) + { + Write-Verbose "$($MyInvocation.MyCommand.Name):: Searching for $n" + + if(($Enabled) -and (!($Disabled))) + {$EnabledDisabledf = $Enabledf} + elseif(($Disabled) -and (!($Enabled))) + {$EnabledDisabledf = $Disabledf} + else + {$EnabledDisabledf = ""} + + switch ($PsCmdlet.ParameterSetName) { + "managed" { $resolve = "(managedBy=$n)"; break} + Default {$resolve = "(|(sAMAccountName=$n)(cn=$n)(displayName=$n)(dNSHostName=$n)(name=$n))"; break} + } + + + $filter = "(&(objectCategory=Computer)(objectClass=User)$EnabledDisabledf$resolve)" + + if (!($SearchRoot)) + {$SearchRoot=$root.defaultNamingContext} + elseif (!($SearchRoot) -or ![ADSI]::Exists("LDAP://$SearchRoot")) + {Write-Error "$($MyInvocation.MyCommand.Name):: '$SearchRoot' does not exist";return} + $searcher.SearchRoot = "LDAP://$SearchRoot" + Write-Verbose "$($MyInvocation.MyCommand.Name):: Searching in: $($searcher.SearchRoot)" + + $searcher.SearchScope = $SearchScope + $searcher.SizeLimit = $SizeLimit + $searcher.PageSize = $PageSize + $searcher.filter = $filter + Write-Verbose "$($MyInvocation.MyCommand.Name):: Searching for: $($searcher.filter)" + try + { + $searcher.FindAll() | ` + Foreach-Object ` + { + $c++ + Write-Verbose "$($MyInvocation.MyCommand.Name):: Found: $($_.Properties.cn)" + $_.GetDirectoryEntry() + } + } + catch + { + {return $false} + } + } + } + + End + { + Write-Verbose "$($MyInvocation.MyCommand.Name):: Results found: $c" + Write-Verbose "$($MyInvocation.MyCommand.Name):: Function ended" + } +} \ No newline at end of file diff --git a/Functions/Get-Domain.ps1 b/Functions/Get-Domain.ps1 new file mode 100644 index 0000000..e6dce1f Binary files /dev/null and b/Functions/Get-Domain.ps1 differ diff --git a/Functions/Get-DomainControllerInfo.ps1 b/Functions/Get-DomainControllerInfo.ps1 new file mode 100644 index 0000000..9f6d7ca Binary files /dev/null and b/Functions/Get-DomainControllerInfo.ps1 differ diff --git a/Functions/Get-DomainControllers.ps1 b/Functions/Get-DomainControllers.ps1 new file mode 100644 index 0000000..f4a665f Binary files /dev/null and b/Functions/Get-DomainControllers.ps1 differ diff --git a/Functions/Get-DomainPasswordPolicy.ps1 b/Functions/Get-DomainPasswordPolicy.ps1 new file mode 100644 index 0000000..07b0690 Binary files /dev/null and b/Functions/Get-DomainPasswordPolicy.ps1 differ diff --git a/Functions/Get-DomainRoot.ps1 b/Functions/Get-DomainRoot.ps1 new file mode 100644 index 0000000..41381cd Binary files /dev/null and b/Functions/Get-DomainRoot.ps1 differ diff --git a/Functions/Get-EmptyGroup.ps1 b/Functions/Get-EmptyGroup.ps1 new file mode 100644 index 0000000..2e158c4 Binary files /dev/null and b/Functions/Get-EmptyGroup.ps1 differ diff --git a/Functions/Get-FSMORoleHolder.ps1 b/Functions/Get-FSMORoleHolder.ps1 new file mode 100644 index 0000000..f0f81b8 Binary files /dev/null and b/Functions/Get-FSMORoleHolder.ps1 differ diff --git a/Functions/Get-Forest.ps1 b/Functions/Get-Forest.ps1 new file mode 100644 index 0000000..744571b Binary files /dev/null and b/Functions/Get-Forest.ps1 differ diff --git a/Functions/Get-Group.ps1 b/Functions/Get-Group.ps1 new file mode 100644 index 0000000..cedc495 Binary files /dev/null and b/Functions/Get-Group.ps1 differ diff --git a/Functions/Get-GroupMember.ps1 b/Functions/Get-GroupMember.ps1 new file mode 100644 index 0000000..b7eb807 Binary files /dev/null and b/Functions/Get-GroupMember.ps1 differ diff --git a/Functions/Get-GroupMembership.ps1 b/Functions/Get-GroupMembership.ps1 new file mode 100644 index 0000000..bc8e003 Binary files /dev/null and b/Functions/Get-GroupMembership.ps1 differ diff --git a/Functions/Get-IPSite.ps1 b/Functions/Get-IPSite.ps1 new file mode 100644 index 0000000..61c28c7 Binary files /dev/null and b/Functions/Get-IPSite.ps1 differ diff --git a/Functions/Get-NearestDC.ps1 b/Functions/Get-NearestDC.ps1 new file mode 100644 index 0000000..ae0434b Binary files /dev/null and b/Functions/Get-NearestDC.ps1 differ diff --git a/Functions/Get-Object.ps1 b/Functions/Get-Object.ps1 new file mode 100644 index 0000000..066e624 Binary files /dev/null and b/Functions/Get-Object.ps1 differ diff --git a/Functions/Get-ObjectBySID.ps1 b/Functions/Get-ObjectBySID.ps1 new file mode 100644 index 0000000..cf8d19f Binary files /dev/null and b/Functions/Get-ObjectBySID.ps1 differ diff --git a/Functions/Get-ObjectSID.ps1 b/Functions/Get-ObjectSID.ps1 new file mode 100644 index 0000000..5ff77e4 Binary files /dev/null and b/Functions/Get-ObjectSID.ps1 differ diff --git a/Functions/Get-RODC.ps1 b/Functions/Get-RODC.ps1 new file mode 100644 index 0000000..b936f02 Binary files /dev/null and b/Functions/Get-RODC.ps1 differ diff --git a/Functions/Get-StaleComputer.ps1 b/Functions/Get-StaleComputer.ps1 new file mode 100644 index 0000000..6dd5485 Binary files /dev/null and b/Functions/Get-StaleComputer.ps1 differ diff --git a/Functions/Get-User.ps1 b/Functions/Get-User.ps1 new file mode 100644 index 0000000..7eed00a Binary files /dev/null and b/Functions/Get-User.ps1 differ diff --git a/Functions/Impersonation.ps1 b/Functions/Impersonation.ps1 new file mode 100644 index 0000000..f85118e Binary files /dev/null and b/Functions/Impersonation.ps1 differ diff --git a/Functions/Move-Object.ps1 b/Functions/Move-Object.ps1 new file mode 100644 index 0000000..e9ddb2e Binary files /dev/null and b/Functions/Move-Object.ps1 differ diff --git a/Functions/New-Computer.ps1 b/Functions/New-Computer.ps1 new file mode 100644 index 0000000..ac1dcf0 Binary files /dev/null and b/Functions/New-Computer.ps1 differ diff --git a/Functions/New-Group.ps1 b/Functions/New-Group.ps1 new file mode 100644 index 0000000..295dbef Binary files /dev/null and b/Functions/New-Group.ps1 differ diff --git a/Functions/New-OU.ps1 b/Functions/New-OU.ps1 new file mode 100644 index 0000000..8d12e73 Binary files /dev/null and b/Functions/New-OU.ps1 differ diff --git a/Functions/New-Password.ps1 b/Functions/New-Password.ps1 new file mode 100644 index 0000000..3a9a316 Binary files /dev/null and b/Functions/New-Password.ps1 differ diff --git a/Functions/New-User.ps1 b/Functions/New-User.ps1 new file mode 100644 index 0000000..4ee4fa4 Binary files /dev/null and b/Functions/New-User.ps1 differ diff --git a/Functions/Remove-GroupMember.ps1 b/Functions/Remove-GroupMember.ps1 new file mode 100644 index 0000000..3d50c48 Binary files /dev/null and b/Functions/Remove-GroupMember.ps1 differ diff --git a/Functions/Remove-Object.ps1 b/Functions/Remove-Object.ps1 new file mode 100644 index 0000000..b4cf23b Binary files /dev/null and b/Functions/Remove-Object.ps1 differ diff --git a/Functions/Rename-Object.ps1 b/Functions/Rename-Object.ps1 new file mode 100644 index 0000000..2ec11ca Binary files /dev/null and b/Functions/Rename-Object.ps1 differ diff --git a/Functions/Set-ADACL.ps1 b/Functions/Set-ADACL.ps1 new file mode 100644 index 0000000..fdff2e7 Binary files /dev/null and b/Functions/Set-ADACL.ps1 differ diff --git a/Functions/Set-Computer.ps1 b/Functions/Set-Computer.ps1 new file mode 100644 index 0000000..2cc9abb Binary files /dev/null and b/Functions/Set-Computer.ps1 differ diff --git a/Functions/Set-DomainMode.ps1 b/Functions/Set-DomainMode.ps1 new file mode 100644 index 0000000..dd6b01f Binary files /dev/null and b/Functions/Set-DomainMode.ps1 differ diff --git a/Functions/Set-ForestMode.ps1 b/Functions/Set-ForestMode.ps1 new file mode 100644 index 0000000..48701de Binary files /dev/null and b/Functions/Set-ForestMode.ps1 differ diff --git a/Functions/Set-OU.ps1 b/Functions/Set-OU.ps1 new file mode 100644 index 0000000..55dba22 Binary files /dev/null and b/Functions/Set-OU.ps1 differ diff --git a/Functions/Set-User.ps1 b/Functions/Set-User.ps1 new file mode 100644 index 0000000..95c350f Binary files /dev/null and b/Functions/Set-User.ps1 differ diff --git a/Functions/Test-IsRODC.ps1 b/Functions/Test-IsRODC.ps1 new file mode 100644 index 0000000..b3f759a Binary files /dev/null and b/Functions/Test-IsRODC.ps1 differ diff --git a/Functions/Test-SameSubnet.ps1 b/Functions/Test-SameSubnet.ps1 new file mode 100644 index 0000000..b29b34d Binary files /dev/null and b/Functions/Test-SameSubnet.ps1 differ diff --git a/PsADManagement.psd1 b/PsADManagement.psd1 new file mode 100644 index 0000000..2cc0b4f Binary files /dev/null and b/PsADManagement.psd1 differ diff --git a/PsADManagement.psm1 b/PsADManagement.psm1 new file mode 100644 index 0000000..da5bd24 Binary files /dev/null and b/PsADManagement.psm1 differ