Skip to content

Commit

Permalink
Replace tabs by spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lazywinadmin committed Oct 7, 2018
1 parent 53ffb10 commit 5469c9c
Show file tree
Hide file tree
Showing 64 changed files with 4,090 additions and 4,090 deletions.
98 changes: 49 additions & 49 deletions AdsiPS/Public/Get-ADSIComputer.ps1
Expand Up @@ -2,75 +2,75 @@ function Get-ADSIComputer
{
<#
.SYNOPSIS
Function to retrieve a Computer in Active Directory
Function to retrieve a Computer in Active Directory
.DESCRIPTION
Function to retrieve a Computer in Active Directory
Function to retrieve a Computer in Active Directory
.PARAMETER Identity
Specifies the Identity of the computer
Specifies the Identity of the computer
You can provide one of the following:
DistinguishedName
Guid
Name
SamAccountName
Sid
You can provide one of the following:
DistinguishedName
Guid
Name
SamAccountName
Sid
System.DirectoryService.AccountManagement.IdentityType
https://msdn.microsoft.com/en-us/library/bb356425(v=vs.110).aspx
System.DirectoryService.AccountManagement.IdentityType
https://msdn.microsoft.com/en-us/library/bb356425(v=vs.110).aspx
.PARAMETER Credential
Specifies alternative credential
By default it will use the current user windows credentials.
Specifies alternative credential
By default it will use the current user windows credentials.
.PARAMETER DomainName
Specifies the alternative Domain.
By default it will use the current domain.
Specifies the alternative Domain.
By default it will use the current domain.
.EXAMPLE
Get-ADSIComputer -Identity 'SERVER01'
Get-ADSIComputer -Identity 'SERVER01'
This command will retrieve the computer account SERVER01
This command will retrieve the computer account SERVER01
.EXAMPLE
Get-ADSIComputer -Identity 'SERVER01' -Credential (Get-Credential)
Get-ADSIComputer -Identity 'SERVER01' -Credential (Get-Credential)
This command will retrieve the computer account SERVER01 with the specified credential
This command will retrieve the computer account SERVER01 with the specified credential
.EXAMPLE
Get-ADSIComputer TESTSERVER01 -credential (Get-Credential) -domain LazyWinAdmin.local
Get-ADSIComputer TESTSERVER01 -credential (Get-Credential) -domain LazyWinAdmin.local
This command will retrieve the account TESTSERVER01 using the alternative credential specified in the domain lazywinadmin.local
This command will retrieve the account TESTSERVER01 using the alternative credential specified in the domain lazywinadmin.local
.EXAMPLE
$Comp = Get-ADSIComputer -Identity 'SERVER01'
$Comp.GetUnderlyingObject()| select-object *
$Comp = Get-ADSIComputer -Identity 'SERVER01'
$Comp.GetUnderlyingObject()| select-object *
Help you find all the extra properties
Help you find all the extra properties
.NOTES
Francois-Xavier Cat
lazywinadmin.com
@lazywinadm
github.com/lazywinadmin/ADSIPS
Francois-Xavier Cat
lazywinadmin.com
@lazywinadm
github.com/lazywinadmin/ADSIPS
.LINK
https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.computerprincipal(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.computerprincipal(v=vs.110).aspx
#>
[CmdletBinding(DefaultParameterSetName="All")]
param ([Parameter(Mandatory=$true,ParameterSetName="Identity")]
[string]$Identity,

[Alias("RunAs")]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty,

[String]$DomainName
)
BEGIN
{
[CmdletBinding(DefaultParameterSetName="All")]
param ([Parameter(Mandatory=$true,ParameterSetName="Identity")]
[string]$Identity,

[Alias("RunAs")]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty,

[String]$DomainName
)
BEGIN
{
Add-Type -AssemblyName System.DirectoryServices.AccountManagement

# Create Context splatting
Expand All @@ -81,25 +81,25 @@ function Get-ADSIComputer

$Context = New-ADSIPrincipalContext @ContextSplatting

}
PROCESS
{
}
PROCESS
{
TRY{
IF($Identity)
{
[System.DirectoryServices.AccountManagement.ComputerPrincipal]::FindByIdentity($Context, $Identity)
}
ELSE{
$ComputerPrincipal = New-object -TypeName System.DirectoryServices.AccountManagement.ComputerPrincipal -ArgumentList $Context
$Searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher
$Searcher.QueryFilter = $ComputerPrincipal
$Searcher = new-object System.DirectoryServices.AccountManagement.PrincipalSearcher
$Searcher.QueryFilter = $ComputerPrincipal

$Searcher.FindAll()
}
}
CATCH
{
$pscmdlet.ThrowTerminatingError($_)
$pscmdlet.ThrowTerminatingError($_)
}
}
}
}
96 changes: 48 additions & 48 deletions AdsiPS/Public/Get-ADSIDefaultDomainAccountLockout.ps1
@@ -1,28 +1,28 @@
Function Get-ADSIDefaultDomainAccountLockout {
<#
.SYNOPSIS
Function to retrieve default Domain Account Lockout Policy
Function to retrieve default Domain Account Lockout Policy
.DESCRIPTION
Function to retrieve default Domain Account Lockout Policy
Function to retrieve default Domain Account Lockout Policy
.PARAMETER Credential
Specifies alternative credential
Specifies alternative credential
.PARAMETER DomainName
Specifies the Domain Name where the function should look
Specifies the Domain Name where the function should look
.PARAMETER DomainDistinguishedName
Specifies the DistinguishedName of the Domain to query
.EXAMPLE
Get-ADSIDefaultDomainAccountLockout
Get-ADSIDefaultDomainAccountLockout
.EXAMPLE
Get-ADSIDefaultDomainAccountLockout -Credential (Get-Credential)
Get-ADSIDefaultDomainAccountLockout -Credential (Get-Credential)
.EXAMPLE
Get-ADSIDefaultDomainAccountLockout -DomainName "CONTOSO.local"
Get-ADSIDefaultDomainAccountLockout -DomainName "CONTOSO.local"
.EXAMPLE
Get-ADSIDefaultDomainAccountLockout -DomainDistinguishedName 'DC=CONTOSO,DC=local'
Expand All @@ -49,66 +49,66 @@ Function Get-ADSIDefaultDomainAccountLockout {
lockoutThreshold : 7
.NOTES
Christophe Kumor
https://christophekumor.github.io
Christophe Kumor
https://christophekumor.github.io
github.com/lazywinadmin/ADSIPS
github.com/lazywinadmin/ADSIPS
#>

[CmdletBinding()]
param
(
[Alias("RunAs")]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty,
[CmdletBinding()]
param
(
[Alias("RunAs")]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential = [System.Management.Automation.PSCredential]::Empty,

[Alias("Domain")]
[ValidateScript({ if ($_ -match "^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$") {$true} else {throw "DomainName must be FQDN. Ex: contoso.locale - Hostname like '$_' is not working"} })]
[String]$DomainName,
[Alias("Domain")]
[ValidateScript({ if ($_ -match "^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$") {$true} else {throw "DomainName must be FQDN. Ex: contoso.locale - Hostname like '$_' is not working"} })]
[String]$DomainName,

[Alias("DomainDN")]
[String]$DomainDistinguishedName = $(([adsisearcher]"").Searchroot.path)
)
[Alias("DomainDN")]
[String]$DomainDistinguishedName = $(([adsisearcher]"").Searchroot.path)
)

BEGIN { }
PROCESS
{
BEGIN { }
PROCESS
{

IF ($PSBoundParameters['DomainName'])
{
$DomainDistinguishedName = "LDAP://DC=$($DomainName.replace(".", ",DC="))"
IF ($PSBoundParameters['DomainName'])
{
$DomainDistinguishedName = "LDAP://DC=$($DomainName.replace(".", ",DC="))"

Write-Verbose -Message "Current Domain: $DomainDistinguishedName"

}
ELSEIF ($PSBoundParameters['DomainDistinguishedName'])
{
IF ($DomainDistinguishedName -notlike "LDAP://*")
{
$DomainDistinguishedName = "LDAP://$DomainDistinguishedName"
}
Write-Verbose -Message "Different Domain specified: $DomainDistinguishedName"
}
ELSEIF ($PSBoundParameters['DomainDistinguishedName'])
{
IF ($DomainDistinguishedName -notlike "LDAP://*")
{
$DomainDistinguishedName = "LDAP://$DomainDistinguishedName"
}
Write-Verbose -Message "Different Domain specified: $DomainDistinguishedName"

}
}

IF ($PSBoundParameters['Credential'])
{
$DomainAccount = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList $DomainDistinguishedName, $($Credential.UserName), $($Credential.GetNetworkCredential().password)
IF ($PSBoundParameters['Credential'])
{
$DomainAccount = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList $DomainDistinguishedName, $($Credential.UserName), $($Credential.GetNetworkCredential().password)

}
}
ELSE {

$DomainAccount = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList $DomainDistinguishedName
}


$Properties = @{
$Properties = @{
"lockoutDuration" = ($DomainAccount.ConvertLargeIntegerToInt64($DomainAccount.'lockoutDuration'[0]) / -600000000) -as [int]
"lockoutObservationWindow" = ($DomainAccount.ConvertLargeIntegerToInt64($DomainAccount.'lockoutObservationWindow'[0]) / -600000000) -as [int]
"lockoutThreshold" = $DomainAccount.lockoutThreshold -as [int]
}
New-Object -TypeName psobject -Property $Properties
}
"lockoutObservationWindow" = ($DomainAccount.ConvertLargeIntegerToInt64($DomainAccount.'lockoutObservationWindow'[0]) / -600000000) -as [int]
"lockoutThreshold" = $DomainAccount.lockoutThreshold -as [int]
}
New-Object -TypeName psobject -Property $Properties
}

}

0 comments on commit 5469c9c

Please sign in to comment.