Skip to content

Commit

Permalink
Remove parameter var type. This is handled by Get-AdObjectType. Add m…
Browse files Browse the repository at this point in the history
…isssing params. Fix typos.
  • Loading branch information
vreguibar committed Jun 4, 2024
1 parent 3ba608e commit 600e33e
Show file tree
Hide file tree
Showing 30 changed files with 310 additions and 238 deletions.
14 changes: 8 additions & 6 deletions Private/Get-ADCSTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ Function Get-ADCSTemplate {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
Position = 0)]
[string]$DisplayName,
Position = 0)]
[string]
$DisplayName,

[Parameter(Mandatory = $false,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
Position = 1)]
[string]$Server
Position = 1)]
[string]
$Server
)
Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Expand All @@ -50,7 +52,7 @@ Function Get-ADCSTemplate {
##############################
# Variables Definition

if(-not $Server) {
if (-not $Server) {
$Server = (Get-ADDomainController -Discover -ForceDiscover -Writable).HostName[0]
}

Expand All @@ -61,7 +63,7 @@ Function Get-ADCSTemplate {
} #end If
} #end Begin
Process {
$ConfigNC = $((Get-ADRootDSE -Server $Server).configurationNamingContext)
$ConfigNC = $((Get-ADRootDSE -Server $Server).configurationNamingContext)

$TemplatePath = ('CN=Certificate Templates,CN=Public Key Services,CN=Services,{0}' -f $ConfigNC)

Expand Down
5 changes: 3 additions & 2 deletions Private/Get-FunctionDisplay.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
[Parameter(Mandatory = $false, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true,
HelpMessage = 'Amount of Tabs to be used on the formatting.',
Position = 1)]
[ValidateNotNullOrEmpty()][PSDefaultValue(Help = 'Default Value is "4"')]
[ValidateNotNullOrEmpty()]
[PSDefaultValue(Help = 'Default Value is "4"')]
[int]
$TabCount = 4
$TabCount = 2
)

Begin {
Expand Down
13 changes: 9 additions & 4 deletions Private/New-Template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ Function New-Template {
#>
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Low')]
Param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Display Name of the new template.',
Position = 0)]
[ValidateNotNullOrEmpty()]
[System.String]
$DisplayName,

[Parameter(Mandatory = $True, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $True,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Other attributes in form of HashTable of the new template.',
Position = 1)]
[System.Collections.Hashtable]
Expand Down Expand Up @@ -108,8 +114,7 @@ Function New-Template {
New-ADObject @Splat
}

}
catch {
} catch {
# Handle errors here
###Get-CurrentErrorToDisplay -CurrentError $error[0]
throw
Expand Down
12 changes: 9 additions & 3 deletions Private/New-TemplateOID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ Function New-TemplateOID {
[OutputType([System.Collections.Hashtable])]

Param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'FQDN of a Domain Controller.',
Position = 0)]
[ValidateNotNullOrEmpty()]
[System.String]
$Server,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
HelpMessage = 'Configuration Namin Context of the domain.',
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Configuration Naming Context of the domain.',
Position = 1)]
[ValidateNotNullOrEmpty()]
[System.String]
Expand Down
20 changes: 16 additions & 4 deletions Private/Test-IsUniqueOID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,37 @@ Function Test-IsUniqueOID {
[OutputType([System.Boolean])]

param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Specifies the Common Name (CN) of the Certificate Template',
Position = 0)]
[string]
$cn,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Specifies the OID (Object Identifier) of the Certificate Template',
Position = 1)]
[string]
$TemplateOID,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Specifies the Active Directory server to query',
Position = 2)]
[string]
$Server,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $False,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $False,
HelpMessage = 'Specifies the Configuration Naming Context (ConfigNC) to search for the Certificate Template.',
Position = 3)]
[string]
Expand Down
1 change: 1 addition & 0 deletions Private/Test-IsValidDN.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Test-IsValidDN {
HelpMessage = 'String to ve validated as DistinguishedName',
Position = 0)]
[ValidateNotNullOrEmpty()]
[ValidateScript({ Test-IsValidDN -ObjectDN $_ })]
[Alias('DN', 'DistinguishedName', 'LDAPpath')]
[string]
$ObjectDN
Expand Down
8 changes: 5 additions & 3 deletions Private/Test-IsValidGUID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
[CmdletBinding(ConfirmImpact = 'Low', SupportsShouldProcess = $false)]
[OutputType([bool])]

param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $false,
param (
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
HelpMessage = 'String to be validated as Global Unique Identifier (GUID)',
Position = 0)]
[ValidateNotNullOrEmpty()]
Expand Down
7 changes: 5 additions & 2 deletions Private/Test-IsValidSID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ function Test-IsValidSID {
[OutputType([bool])]
param
(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ValueFromRemainingArguments = $false,
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
HelpMessage = 'String to be validated as SID',
Position = 0)]
[ValidateNotNullOrEmpty()]
Expand All @@ -37,7 +40,7 @@ function Test-IsValidSID {
)
Begin {
# Define DN Regex
$SidRegex = [RegEx]::new("^S-1-[0-59]-\d{2}-\d{8,10}-\d{8,10}-\d{8,10}-[1-9]\d{3}")
$SidRegex = [RegEx]::new('^S-1-[0-59]-\d{2}-\d{8,10}-\d{8,10}-\d{8,10}-[1-9]\d{3}')
} #end Begin
Process {
Try {
Expand Down
13 changes: 7 additions & 6 deletions Public/ConvertTo-IPv4Integer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ function ConvertTo-IPv4Integer {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
Position = 0)]
[String] $Ipv4Address
Position = 0)]
[String]
$Ipv4Address
)

Begin {
Expand All @@ -41,18 +42,18 @@ function ConvertTo-IPv4Integer {
}

Process {
Try{
Try {
$ipAddress = [IPAddress]::Parse($IPv4Address)

$bytes = $ipAddress.GetAddressBytes()

[Array]::Reverse($bytes)

[System.BitConverter]::ToUInt32($bytes,0)
[System.BitConverter]::ToUInt32($bytes, 0)

}Catch{
} Catch {
Write-Error -Exception $_.Exception -Category $_.CategoryInfo.Category
}
}
}

End {
Expand Down
7 changes: 4 additions & 3 deletions Public/ConvertTo-IPv4MaskBit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ function ConvertTo-IPv4MaskBit {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
Position = 0)]
[ValidateScript({Test-IPv4MaskString $_})]
[String] $MaskString
Position = 0)]
[ValidateScript({ Test-IPv4MaskString $_ })]
[String]
$MaskString
)
Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Expand Down
9 changes: 5 additions & 4 deletions Public/ConvertTo-IPv4MaskString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ function ConvertTo-IPv4MaskString {
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
Position =0)]
[ValidateRange(0,32)]
[System.Int32] $MaskBits
Position = 0)]
[ValidateRange(0, 32)]
[System.Int32]
$MaskBits
)
Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Expand All @@ -42,7 +43,7 @@ function ConvertTo-IPv4MaskString {
Process {
$mask = ([Math]::Pow(2, $MaskBits) - 1) * [Math]::Pow(2, (32 - $MaskBits))
$bytes = [BitConverter]::GetBytes([UInt32] $mask)
(($bytes.Count - 1)..0 | ForEach-Object { [String] $bytes[$_] }) -join "."
(($bytes.Count - 1)..0 | ForEach-Object { [String] $bytes[$_] }) -join '.'
}
End {
Write-Verbose -Message "Function $($MyInvocation.InvocationName) finished."
Expand Down
34 changes: 19 additions & 15 deletions Public/ConvertTo-IPv4NetworkAddress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,38 @@ Function ConvertTo-IPv4NetworkAddress {
#>
[CmdletBinding(ConfirmImpact = 'Low')]
[OutputType([System.Net.IpAddress])]
Param
(

Param (
[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
HelpMessage = "Specifies the IPv4 Address as string (e.g., 192.168.1.200)",
Position = 0)]
[String] $IPv4Address,
HelpMessage = 'Specifies the IPv4 Address as string (e.g., 192.168.1.200)',
Position = 0)]
[String]
$IPv4Address,

[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
HelpMessage = "Specifies the IPv4 network mask as string (e.g., 255.255.255.0)",
ParameterSetName='SubnetMask',
Position = 1)]
[String] $SubnetMask,
HelpMessage = 'Specifies the IPv4 network mask as string (e.g., 255.255.255.0)',
ParameterSetName = 'SubnetMask',
Position = 1)]
[String]
$SubnetMask,

[Parameter(Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
HelpMessage = "Specifies the network prefix length, also known as CIDR (e.g., 24)",
ParameterSetName='PrefixLength',
Position = 1)]
[String] $PrefixLength
HelpMessage = 'Specifies the network prefix length, also known as CIDR (e.g., 24)',
ParameterSetName = 'PrefixLength',
Position = 1)]
[String]
$PrefixLength
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Expand All @@ -75,7 +79,7 @@ Function ConvertTo-IPv4NetworkAddress {

#####
# Variables
$IntegerIPv4Address = 0
$IntegerIPv4Address = 0
$IntegerIPv4SubnetMask = 0
$IntegerNetworkAddress = 0
[IpAddress]$NetworkAddress
Expand All @@ -86,7 +90,7 @@ Function ConvertTo-IPv4NetworkAddress {
Write-Verbose -Message ('IP Address {0} to Integer: {1}' -f $IPv4Address, $IntegerIPv4Address)

# Get IPv4 subnet mask as an Integer
If($PSCmdlet.ParameterSetName -eq 'PrefixLength') {
If ($PSCmdlet.ParameterSetName -eq 'PrefixLength') {
$SubnetMask = (ConvertTo-IPv4MaskString -MaskBits $PrefixLength).ToString()
Write-Verbose -Message ('PrefixLength of {0} to Integer: {1}' -f $SubnetMask, $IntegerIPv4SubnetMask)
}
Expand Down
3 changes: 2 additions & 1 deletion Public/ConvertTo-IntegerIPv4.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ function ConvertTo-IntegerIPv4 {
ValueFromPipelineByPropertyName = $true,
ValueFromRemainingArguments = $false,
Position = 0)]
[uint32] $Integer
[uint32]
$Integer
)

Begin {
Expand Down
5 changes: 4 additions & 1 deletion Public/New-AGPMobject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
Param(
# PARAM1 full path to the configuration.xml file
[Parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, ValueFromRemainingArguments = $false,
[Parameter(Mandatory = $true,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True,
ValueFromRemainingArguments = $false,
HelpMessage = 'Full path to the configuration.xml file',
Position = 0)]
[string]
Expand Down
1 change: 1 addition & 0 deletions Public/New-AdDelegatedGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#>
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
[OutputType([Microsoft.ActiveDirectory.Management.AdGroup])]

Param (
# Param1 Group which membership is to be changed
[Parameter(Mandatory = $true,
Expand Down
1 change: 0 additions & 1 deletion Public/New-DelegateAdGpo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function New-DelegateAdGpo {
HelpMessage = 'Domain Local Group with GPO Rights to be assigned',
Position = 3)]
[ValidateNotNullOrEmpty()]
[string]
$GpoAdmin,

# Param5 Restore GPO settings from backup using the BackupID GUID
Expand Down
1 change: 0 additions & 1 deletion Public/New-DelegateAdOU.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function New-DelegateAdOU {
ValueFromRemainingArguments = $false,
HelpMessage = 'Name of the OU',
Position = 0)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[ValidateLength(2, 50)]
[string]
Expand Down
5 changes: 4 additions & 1 deletion Public/New-DhcpObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
Param
(
# PARAM1 full path to the configuration.xml file
[Parameter(Mandatory = $true, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, ValueFromRemainingArguments = $false,
[Parameter(Mandatory = $true,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True,
ValueFromRemainingArguments = $false,
HelpMessage = 'Full path to the configuration.xml file',
Position = 0)]
[string]
Expand Down
Loading

0 comments on commit 600e33e

Please sign in to comment.