Skip to content

Commit

Permalink
Changing Header message on Begin section
Browse files Browse the repository at this point in the history
  • Loading branch information
vreguibar committed Aug 7, 2024
1 parent 8a01044 commit b6fc392
Show file tree
Hide file tree
Showing 50 changed files with 644 additions and 412 deletions.
42 changes: 33 additions & 9 deletions Enums/Enum.Constants.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,39 @@
# Message header for new regions. Used on NewCentralItOu to easily identify regions on transcript
NewRegionMessage = @'
################################################################################
# #
# ╔══════════════════════════════════════════════════════════════════════╗ #
# ║ ║ #
# ║ New Region Start ║ #
# ║ ║ #
# ╚══════════════════════════════════════════════════════════════════════╝ #
# #
################################################################################
████████████████████████████████████████████████████████████████████████████████████████████████████
█ █
█ ╔══════════════════════════════════════════════════════════════════════╗ █
█ ║ ║ █
█ ║ New Region Start ║ █
█ ║ ║ █
█ ╚══════════════════════════════════════════════════════════════════════╝ █
█ █
████████████████████████████████████████████████████████████████████████████████████████████████████
REGION: {0}
'@

# Standard header used on each function on the Begin section
Header = @'
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ EguibarIT module ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Date: {0}
Starting: {1}
Parameters used by the function... {2}
'@

# Standard footer used on each function on the Begin section
Footer = @'
Function {0} finished {1}"
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
'@

Expand Down
15 changes: 11 additions & 4 deletions Private/Get-ADCSTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ Function Get-ADCSTemplate {
$Server
)
Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



##############################
# Variables Definition
Expand Down
14 changes: 9 additions & 5 deletions Private/Get-AdObjectType.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports

Import-MyModule -name 'ActiveDirectory' -Verbose:$false
Import-Module -Name 'ActiveDirectory' -SkipEditionCheck -Force -Verbose:$false | Out-Null


##############################
Expand Down
15 changes: 11 additions & 4 deletions Private/Get-CurrentErrorToDisplay.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ function Get-CurrentErrorToDisplay {
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



##############################
# Variables Definition
Expand Down
86 changes: 41 additions & 45 deletions Private/Get-IniContent.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Get-IniContent
{
function Get-IniContent {
<#
.Synopsis
Gets the content of an INI file
Expand Down Expand Up @@ -54,15 +53,17 @@ function Get-IniContent
[OutputType([System.Collections.Hashtable])]
Param(
[ValidateNotNullOrEmpty()]
[Parameter(ValueFromPipeline = $true,HelpMessage = 'Path and Filename to the ini file to be read',Mandatory = $true)]
[Parameter(ValueFromPipeline = $true, HelpMessage = 'Path and Filename to the ini file to be read', Mandatory = $true)]
[string]$FilePath
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Variables Definition
Expand All @@ -72,50 +73,45 @@ function Get-IniContent
Write-Verbose -Message "$($myInvocation.MyCommand.Name):: Processing file: $PSBoundParameters['FilePath']"

Try {
$ini = @{}
switch -regex -file $PSBoundParameters['FilePath'] {
'^\[(.+)\]$' # Section
{
$section = $matches[1]
$ini[$section] = @{}
$CommentCount = 0
}
'^(;.*)$' # Comment
{
if (!($section))
{
$section = 'No-Section'
$ini = @{}
switch -regex -file $PSBoundParameters['FilePath'] {
'^\[(.+)\]$' { # Section
$section = $matches[1]
$ini[$section] = @{}
$CommentCount = 0
}
$value = $matches[1]
$CommentCount = $CommentCount + 1
$name = 'Comment' + $CommentCount
$ini[$section][$name] = $value
}
'(.+?)\s*=\s*(.*)' # Key
{
if (!($section))
{
$section = 'No-Section'
$ini[$section] = @{}
'^(;.*)$' { # Comment
if (!($section)) {
$section = 'No-Section'
$ini[$section] = @{}
}
$value = $matches[1]
$CommentCount = $CommentCount + 1
$name = 'Comment' + $CommentCount
$ini[$section][$name] = $value
}
'(.+?)\s*=\s*(.*)' { # Key
if (!($section)) {
$section = 'No-Section'
$ini[$section] = @{}
}
$name, $value = $matches[1..2]
$ini[$section][$name] = $value
}
$name, $value = $matches[1..2]
$ini[$section][$name] = $value
}
} #end Switch
} catch{
Write-Error -Message "An error occurred while processing the file: $_"
throw
} #end Switch
} catch {
Write-Error -Message "An error occurred while processing the file: $_"
throw
} #end Try-Catch
Write-Verbose -Message "$($myInvocation.MyCommand.Name):: Finished Processing file: $PSBoundParameters['FilePath']"

} # End Process

End {
Write-Verbose -Message "Function $($MyInvocation.InvocationName) finished reading content from $PSBoundParameters['FilePath'] file."
Write-Verbose -Message ''
Write-Verbose -Message '-------------------------------------------------------------------------------'
Write-Verbose -Message ''
Return $ini
} #end End
End {
Write-Verbose -Message "Function $($MyInvocation.InvocationName) finished reading content from $PSBoundParameters['FilePath'] file."
Write-Verbose -Message ''
Write-Verbose -Message '-------------------------------------------------------------------------------'
Write-Verbose -Message ''
Return $ini
} #end End
}
17 changes: 11 additions & 6 deletions Private/Initialize-ModuleVariable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@
Param ()

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message 'This function does not uses any Parameter.'
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Variables Definition
# Module imports

Import-Module ActiveDirectory -SkipEditionCheck -Force -Verbose:$false | Out-Null

Import-Module ActiveDirectory -Verbose:$false
##############################
# Variables Definition

} #end Begin

Expand Down
15 changes: 11 additions & 4 deletions Private/New-Template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ Function New-Template {
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



##############################
# Variables Definition
Expand Down
15 changes: 11 additions & 4 deletions Private/New-TemplateOID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ Function New-TemplateOID {
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



##############################
# Variables Definition
Expand Down
14 changes: 11 additions & 3 deletions Private/Publish-CertificateTemplate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ Function Publish-CertificateTemplate {
Eguibar Information Technology S.L.
http://www.eguibarit.com
#>
[CmdletBinding(SupportsShouldProcess=$true)]
[CmdletBinding(SupportsShouldProcess = $true)]
Param (
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[string]$CertDisplayName
)

begin {
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

######################
# Initialize variables
$Server = (Get-ADDomainController -Discover -ForceDiscover -Writable).HostName[0]
$ConfigNC = (Get-ADRootDSE -Server $Server).configurationNamingContext
Expand All @@ -41,7 +49,7 @@ Function Publish-CertificateTemplate {

if ($PSCmdlet.ShouldProcess("Certificate Template: $TemplateToAdd", "Publish to CA: $CAIdentity")) {
try {
Set-ADObject -Identity $CAIdentity -Add @{certificateTemplates=$TemplateToAdd} -Server $Server -ErrorAction Stop
Set-ADObject -Identity $CAIdentity -Add @{certificateTemplates = $TemplateToAdd } -Server $Server -ErrorAction Stop
Write-Verbose "Certificate template '$TemplateToAdd' published to CA: $CAIdentity"
} catch {
Write-Error "Failed to publish certificate template to CA: $CAIdentity. $_"
Expand Down
15 changes: 11 additions & 4 deletions Private/Test-IsUniqueOID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ Function Test-IsUniqueOID {
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



##############################
# Variables Definition
Expand Down
15 changes: 11 additions & 4 deletions Private/Test-IsValidDN.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ function Test-IsValidDN {
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



# Initialize a boolean variable to store validation result
[bool]$isValid = $false
Expand Down
15 changes: 11 additions & 4 deletions Private/Test-IsValidGUID.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@
)

Begin {
Write-Verbose -Message '|=> ************************************************************************ <=|'
Write-Verbose -Message (Get-Date).ToShortDateString()
Write-Verbose -Message (' Starting: {0}' -f $MyInvocation.Mycommand)
Write-Verbose -Message ('Parameters used by the function... {0}' -f (Get-FunctionDisplay $PsBoundParameters -Verbose:$False))
$txt = ($constants.Header -f
(Get-Date).ToShortDateString(),
$MyInvocation.Mycommand,
(Get-FunctionDisplay $PsBoundParameters -Verbose:$False)
)
Write-Verbose -Message $txt

##############################
# Module imports



$isValid = $false

Expand Down
Loading

0 comments on commit b6fc392

Please sign in to comment.