PowerShell studio and argument completer

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
stephaneSchaumburgNRB
Posts: 2
Last visit: Wed Dec 19, 2018 7:07 am

PowerShell studio and argument completer

Post by stephaneSchaumburgNRB »

Hi

I came across a very strange behavior.

I've got a function with 5 parameters.
3 of those have an argument completer.
everything works fine.

everytime I add a parameter to the function, there is an error PsStudio doesn't recognize the content of the argument completer
if I remive the content and type it again, it's ok !
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell studio and argument completer

Post by jvierra »

What is an "argument completer"? I don't think PowerShell has any support for something like that.

Without an example there is no way to know what you are asking.
User avatar
stephaneSchaumburgNRB
Posts: 2
Last visit: Wed Dec 19, 2018 7:07 am

Re: PowerShell studio and argument completer

Post by stephaneSchaumburgNRB »

#region FUNCTIONS

<#-------------------------------------------------------------------------------------------------------------
'########:'##::::'##:'##::: ##::'######::'########:'####::'#######::'##::: ##::'######::
##.....:: ##:::: ##: ###:: ##:'##... ##:... ##..::. ##::'##.... ##: ###:: ##:'##... ##:
##::::::: ##:::: ##: ####: ##: ##:::..::::: ##::::: ##:: ##:::: ##: ####: ##: ##:::..::
######::: ##:::: ##: ## ## ##: ##:::::::::: ##::::: ##:: ##:::: ##: ## ## ##:. ######::
##...:::: ##:::: ##: ##. ####: ##:::::::::: ##::::: ##:: ##:::: ##: ##. ####::..... ##:
##::::::: ##:::: ##: ##:. ###: ##::: ##:::: ##::::: ##:: ##:::: ##: ##:. ###:'##::: ##:
##:::::::. #######:: ##::. ##:. ######::::: ##::::'####:. #######:: ##::. ##:. ######::
..:::::::::.......:::..::::..:::......::::::..:::::....:::.......:::..::::..:::......:::
--------------------------------------------------------------------------------------------------------------#>

<#
.SYNOPSIS
This function installs a ROOT CERTIFICATION AUTHORITY.

.DESCRIPTION
This function can be used in two way.
Either it uses a JSON file with all required parameters in it, or it can accept direct parameters.
If Direct parameters are used, most of them have an argument completer

.PARAMETER FilePath
The path to the JSON file that must contain all the settings for a new Root CA installation.

.PARAMETER RenewalKeyLength
The Length of the CA public and private Keys.
Only two values are supported : 4096 and 2048.
The authorized values for the RenewalValidityPeriodunit depends on this parameter.
A key of 4096 allows a CA with up to 16 years lifetime.
A key of 2048 allows a CA with 1 to 8 years lifetime.

.PARAMETER RenewalValidityPeriod
ATTENTION !!
This parameter defines the UNIT that will be used to define the CA lifetime.
Acceptable values are : Years, Months, Weeks and Days.

.PARAMETER RenewalValidityPeriodUnit
This is the number of unit of type RenewalValidityPeriod !!!
Pay attention to this because it's absolutly counter natural naming convention.
This parameter has an argument completer.
The maximum lifetime of a CA is 8 years for a 2048 key and 16 years for a 4096 key.
The RenewalValidityPeriodUnit proposed respect the above rule with convertion to the unit select in RenewalValidityPeriod.

.PARAMETER CRLPeriod
The unit for the CRLPeriod. this define the unit not the number of unit !
The CRLPeriod must be shorter or equal to the unit for the CA lifetime.
An argument completer is used to build the acceptable values.

.PARAMETER CRLPeriodUnits
The number of units for the CRL Period.
Because the root CA is offline, the crl lifetime is basically how often the CA must be powered on and the CRL re published.
A classic value is 6month or a year.
This function does not allow the CRL Period to be more tha, a third of the CA Lifetime rounded down.
This argument has a an argument completer that is used to build the acceptable values.

.EXAMPLE
PS C:\> New-CAROOT -FilePath 'Value1'

.OUTPUTS
pscustomobject, pscustomobject

.NOTES
Additional information about the function.
#>
function New-CAROOT
{
[CmdletBinding(DefaultParameterSetName = 'JSONFile',
SupportsShouldProcess = $false)]
[OutputType([pscustomobject], ParameterSetName = 'JSONFile')]
[OutputType([pscustomobject], ParameterSetName = 'CADetails')]
param
(
[Parameter(ParameterSetName = 'JSONFile',
Mandatory = $true,
Position = 0,
HelpMessage = 'Full file path to the Settings JSON file')]
[ValidateScript({ test-path -path $psitem })]
[Alias('FP')]
[string]$FilePath,
[Parameter(ParameterSetName = 'CADetails',
Mandatory = $false,
Position = 0,
HelpMessage = 'CA Key Length')]
[ValidateSet('4096', '2048')]
[Alias('RKL')]
[int16]$RenewalKeyLength = 4096,
[Parameter(ParameterSetName = 'CADetails',
Position = 1,
HelpMessage = 'Units for the CA validity period')]
[ValidateSet('Years', 'Months', 'Weeks', 'Days')]
[Alias('RVP')]
[string]$RenewalValidityPeriod = 'Years',
[Parameter(ParameterSetName = 'CADetails',
Position = 2)]
[ArgumentCompleter({
param
(
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameter
)

$SelectedUnits = $fakeboundparameter.RenewalValidityPeriod
$SelectedKeyLength = $fakeboundparameter.RenewalKeyLength
if ($selectedUnits -eq "Years" -and $selectedKeyLength -eq 4096)
{
1 .. 16 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }
}
elseif ($selectedUnits -eq "Years" -and $selectedKeyLength -eq 2048)
{
1 .. 8 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }
}
elseif ($selectedUnits -eq "Months" -and $selectedKeyLength -eq 4096)
{
1 .. 192 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }
}
elseif ($selectedUnits -eq "Months" -and $selectedKeyLength -eq 2048)
{
1 .. 96 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }

}
elseif ($selectedUnits -eq "Weeks" -and $selectedKeyLength -eq 4096)
{
1 .. 832 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }
}
elseif ($selectedUnits -eq "Weeks" -and $selectedKeyLength -eq 2048)
{
1 .. 416 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }

}
elseif ($selectedUnits -eq "Days" -and $selectedKeyLength -eq 4096)
{

1 .. 5844 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }

}
else
{
1 .. 2922 | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, "$_ $selectedUnits", 'ParameterValue', $_) }

}

})]
[Alias('RVPU')]
[int]$RenewalValidityPeriodUnit,
[Parameter(ParameterSetName = 'CADetails',
Position = 3)]
[ArgumentCompleter({
param
(
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameter
)

$SelectedUnits = $fakeboundparameter.RenewalValidityPeriod
$SelectedKeyLength = $fakeboundparameter.RenewalKeyLength
$SelectedNumberOfUnits = $fakeboundparameter.RenewalValidityPeriodUnit

if ($SelectedUnits -eq "Years" -and $SelectedNumberOfUnits -eq 1)
{
$AllowedUnits = "Months", "Weeks", "Days"
}
elseif ($SelectedUnits -eq "Years")
{
$AllowedUnits = "Years", "Months", "Weeks", "Days"
}
elseif ($SelectedUnits -eq "Months" -and $SelectedNumberOfUnits -eq 1)
{
$AllowedUnits = "Weeks", "Days"
}
elseif ($SelectedUnits -eq "Months")
{
$AllowedUnits = "Months", "Weeks", "Days"
}
elseif ($SelectedUnits -eq "Weeks" -and $SelectedNumberOfUnits -eq 1)
{
$AllowedUnits = "Days"
}
elseif ($Selectedunits -eq "Weeks")
{
$AllowedUnits = "Weeks", "Days"
}
else
{
$AllowedUnits = "Days"
}

$allowedunits | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }

})]
[Alias('CRLP')]
[string]$CRLPeriod,
[Parameter(ParameterSetName = 'CADetails',
Position = 4,
HelpMessage = 'The number of CRLPeriods')]
[ArgumentCompleter({
param
(
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameter
)
$SelectedUnits = $fakeboundparameter.RenewalValidityPeriod # this is either "Years","Months","Weeks" or "Days"
$SelectedNumberOfUnits = $fakeboundparameter.RenewalValidityPeriodUnit # This is a number
$SelectedCRLValidity = $fakeboundparameter.CRLPeriod # This is either "Years","Months","Weeks" or "Days"

if ($SelectedUnits -eq "Years" -and $SelectedCRLValidity -eq "Years" -and $SelectedNumberOfUnits -ge 3)
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal]($SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Years" -and $SelectedCRLValidity -eq "Years")
{
$MaxCrlPeriodUnit = 1
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Years" -and $SelectedCRLValidity -eq "Months")
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal](12 * $SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Years" -and $SelectedCRLValidity -eq "Weeks")
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal](52 * $SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Years" -and $SelectedCRLValidity -eq "Days")
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal](365 * $SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Months" -and $SelectedCRLValidity -eq "Months" -and $SelectedNumberOfUnits -ge 3)
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal]($SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Months" -and $SelectedCRLValidity -eq "Months")
{
$MaxCrlPeriodUnit = 1
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Months" -and $SelectedCRLValidity -eq "Weeks")
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal](4 * $SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Months" -and $SelectedCRLValidity -eq "Days")
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal](30 * $SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Weeks" -and $SelectedCRLValidity -eq "Weeks" -and $SelectedNumberOfUnits -ge 3)
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal]($SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Weeks" -and $SelectedCRLValidity -eq "Weeks")
{
$MaxCrlPeriodUnit = 1
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Weeks" -and $SelectedCRLValidity -eq "Days")
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal]($SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

elseif ($SelectedUnits -eq "Days" -and $SelectedCRLValidity -eq "Days" -and $SelectedNumberOfUnits -ge 3)
{
$MaxCrlPeriodUnit = [Math]::Floor([decimal]($SelectedNumberOfUnits/3))
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }
}

else
{
$MaxCrlPeriodUnit = 1
1 .. $MaxCrlPeriodUnit | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) }

}

})]
[Alias('CRLPU')]
[int]$CRLPeriodUnits
)

switch ($PsCmdlet.ParameterSetName)
{
'JSONFile' {
#TODO: Place script here



$ISJSON = test-JsonFileValidity -InitialLogLevel 2 -PathToFileToTest c:\SOURCES\CADEF.json


break
}
'CADetails' {
#TODO: Place script here
break
}
}
}

function Add-LogEntry
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true,
Position = 0,
HelpMessage = 'Current Entry Level')]
[ValidateRange(1, 20)]
[Alias('LL')]
[int32]$LogLevel,
[Parameter(Mandatory = $true,
Position = 1,
HelpMessage = 'Name of the file for TXT Logging')]
[ValidateScript({ test-path -path $psitem })]
[Alias('TLFN')]
[string]$TxtLogFileName,
[Parameter(Mandatory = $true,
Position = 3,
HelpMessage = 'Message text')]
[Alias('LM')]
[string]$LogMessage,
[Parameter(Position = 4,
HelpMessage = 'Define if the message being log reports an error.')]
[boolean]$IsError,
[Parameter(Mandatory = $true,
Position = 2,
HelpMessage = 'Html log filename')]
[ValidateScript({ test-path -path $psitem })]
[Alias('HLFN')]
[string]$HtmlLogFileName
)

<# ---------------------------------------------------------------------------------------------------------

The first thing that must be done is to check if a SCRIPT SCOPED VARIABLE NAMED $Script:LogLevels exists.
If that variable exists,
- it means that this function has already been run and that the initial contents of :
* The raw log file specified as the $LogFileName Parameter,
* The $LogContent variable,
has already been created.
If the variable doesn't exists, the following task must be performed :
- Creation of the $Script:LogContent that will contains the Html content
- Creation of the $script:LogIndexes variable that will contain the indexes of logging level
- Creation of 20 entries in that variable with value of 0 (zero).
- Gathering of the current environment
- script name.
- Current username.
- Addition of these informations in the Log File AND the LogContent

-----------------------------------------------------------------------------------------------------------#>

# Check if the variable $Script:LogLevels is not null
if ($script:LogIndexes -ne $Null)
{
# This function has already been run, adding entries


# Increases the Level of index passed as $LogLevel parameter
$script:LogIndexes[$LogLevel - 1] += 1
#write-host $script:LogIndexes

# Reset all levels with higher level to zero
$i = $LogLevel
# write-host $i
while ($i -lt 20) # This is a loop that starts at the level after the log level till the end of the array #>
{
$script:LogIndexes[$i] = 0
$i++
} # END while ($i -lt 20)
# write-host $script:LogIndexes


# Generates the message by adding the current log levels till the one passed as $LogLevel parameter
$FullMessage = ""
for ($i = 0; $i -lt $Loglevel; $i++)
{
$FullMessage += "$($script:LogIndexes[$i])" + "."
} # END for ($i = 0; $i -le $LogLevel; $i++) This loops start at the beginning of the array ang goes to the $LogLevel value

# Add the Text passed as parameter
$FullMessage += $LogMessage

# Display the message if verbosed and Add it to the TXT File
Write-Verbose "$FullMessage"
$FullMessage | Out-File -FilePath $TxtLogFileName -Append

<# Generate the HTML entry
Generate the html paragraph reference.
This reference is created using two parameters : the loglevel and if it is an error entry or not
#>

if ($IsError -eq $false)
{
$BaliseHtml = "L" + "$($script:LogIndexes[$LogLevel - 1])" + "OK"
} # END if ($IsError -eq $false)
else
{
$BaliseHtml = "L" + "$($script:LogIndexes[$LogLevel - 1])" + "Error"
} # END ELSE ($IsError -eq $false)

# Generate html line
$HtmlLine = "<p class=" + '"' + "$BaliseHtml" + '"' + ">" + "$FullMessage<br></p>"

# retrieve the current content of the html file
[System.Collections.ArrayList]$script:LogContent = Get-Content -Path $HtmlLogFileName

# find the position of the CURSORPOSITION string
$InsertionPosition = $script:LogContent.indexof("ENDOFTHISHTMLLOGFILE")

# Insert the computed balise to the content
$script:LogContent.insert($InsertionPosition, $HtmlLine)
Set-Content -Path $HtmlLogFileName -Value $script:LogContent

} # ENDIF ($script:LogIndexes -ne $Null)
else
{
# This function is ran for the first time, Creation of script variables.
$script:LogContent = New-Object -TypeName System.Collections.ArrayList
$Script:LogIndexes = New-Object -TypeName System.Collections.ArrayList

# Initialization of LogIndexes.
for ($i = 0; $i -lt 20; $i++)
{
$script:LogIndexes.add(0)
} # END for ($i = 0; $i -lt 20; $i++)

# Initialize the content of the HTML File
Initialize-HtmlFileContent -HtmlFileName $HtmlLogFileName

# Add the script filename to the TXT log.
$CurrentScript = "Script Name : $PSCommandPath"
$CurrentScript | Out-File -FilePath $TxtLogFileName

# Add the current username to the TXT log.
$CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
"Current user is : $CurrentUser" | out-file -FilePath $TxtLogFileName

# Replace the default title in html file with script name and username
$CurrentHtmlFile = Get-Content -Path $HtmlLogFileName
$NewContent = $CurrentHtmlFile.replace("TITRE", "$CurrentScript was run by $CurrentUser")
Set-Content -Path $HtmlLogFileName -Value $NewContent

# Recursive call to the function to add the required entry to the log if it is the first call
Add-LogEntry -LogLevel $LogLevel -TxtLogFileName $TxtLogFileName -LogMessage $LogMessage -HtmlLogFileName $HtmlLogFileName

} # END ELSE ($script:LogIndexes -ne $Null)
} # END Add-LogEntry

<#
.SYNOPSIS
Creates the initial content of the HTML report file.

.DESCRIPTION
This function will fill an empty file with the html instructions to create a basis content.
In this Content a ENDOFTHISHTMLLOGFILE line will be inserted. This line will be used by other functions to add content to the file.
The other functions must search for the line 'ENDOFTHISHTMLLOGFILE' and replace it by the new content + ENDOFTHISHTMLLOGFILE

.PARAMETER HtmlFileName
The name of the File that must be initialized

.EXAMPLE
PS C:\> Initialize-HtmlFileContent

.NOTES
Additional information about the function.
#>
function Initialize-HtmlFileContent
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true,
Position = 1)]
[ValidateScript({ test-path -path $psitem })]
[Alias('HFN')]
[string]$HtmlFileName
)

'<!DOCTYPE html>' | out-file -filepath $HtmlFileName -append
'<html>' | out-file -filepath $HtmlFileName -append
'<head>' | out-file -filepath $HtmlFileName -append
'<style>' | out-file -filepath $HtmlFileName -append
'p.L1OK {' | out-file -filepath $HtmlFileName -append
' font-family: "Arial Black", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:200%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.5;' | out-file -filepath $HtmlFileName -append
' text-decoration: underline;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L1Error {' | out-file -filepath $HtmlFileName -append
' font-family: "Arial Black", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:200%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.5;' | out-file -filepath $HtmlFileName -append
' text-decoration: underline;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L2OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial Black", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:190%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.3;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L2Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial Black", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:190%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.3;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L3OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:180%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.2;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L3Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:180%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.2;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L4OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:170%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.1;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L4Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:170%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.1;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L5OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:160%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L5Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:160%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L6OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:150%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L6Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:150%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L7OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:140%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L7Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:140%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L8OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:130%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L8Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:130%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L9OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:120%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L9Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:120%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L10OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:110%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L10Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:110%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L11OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:100%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L11Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:100%;' | out-file -filepath $HtmlFileName -append
' line-height: 1.0;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L12OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:95%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.95;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L12Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:95%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.95;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L13OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:90%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.90;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L13Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:90%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.90;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L14OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:85%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.85;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L14Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:85%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.85;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L15OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:80%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.80;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L15Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:80%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.80;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L16OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:75%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.75;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L16Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:75%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.75;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L17OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:70%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.70;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L17Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:70%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.70;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L18OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:65%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.65;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L18Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:65%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.65;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L19OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:60%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.60;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L19Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:60%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.60;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L20OK{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:55%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.55;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'p.L20Error{' | out-file -filepath $HtmlFileName -append
' font-family: "Arial", Times, serif;' | out-file -filepath $HtmlFileName -append
' Font-size:55%;' | out-file -filepath $HtmlFileName -append
' line-height: 0.55;' | out-file -filepath $HtmlFileName -append
' color:#FF0000;' | out-file -filepath $HtmlFileName -append
'}' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'</style>' | out-file -filepath $HtmlFileName -append
'</head>' | out-file -filepath $HtmlFileName -append
'<body>' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'<h1>TITRE</h1>' | out-file -filepath $HtmlFileName -append
'ENDOFTHISHTMLLOGFILE' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'' | out-file -filepath $HtmlFileName -append
'</body>' | out-file -filepath $HtmlFileName -append
'</html>' | out-file -filepath $HtmlFileName -append

} # END Initialize-HtmlFileContent

<#
.SYNOPSIS
Create the two logfiles used by the Add-LogEntry Function.

.DESCRIPTION
This function create two empty files.

This function tries to create the files in the specified folder.
If the logs cannot be created in the specified folder, the files are created in the document folder of the user running the script.

The log names are either based on the LogNamePatern parameter or the name of the current script.

.PARAMETER LogNamePatern
The name that will be used to generate the log files.

.PARAMETER LogFolder
A description of the LogFolder parameter.

.EXAMPLE
PS C:\> Initialize-LogFiles

.NOTES
Additional information about the function.
#>
function Initialize-LogFiles
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $false,
Position = 1)]
[string]$LogNamePatern,
[Parameter(Mandatory = $true,
Position = 0)]
[string]$LogFolder
)

# Generate the Log name
$TxtName = (Get-NameWithCurrentTime ($LogNamePatern)) + ".log"
$HtmlName = (Get-NameWithCurrentTime ($LogNamePatern)) + ".html"
Write-Verbose "Generated log File names : "
Write-Verbose "$TxtName"
Write-Verbose "$HtmlName"

# Define the log file path to the folder defined in parameter. This will be changed if acces rights are not set.
$LogFilePath = $LogFolder

try
{
# Creates the files
New-Item -Name $TxtName -ItemType file -Path $Logfilepath -ErrorAction Stop
New-Item -Name $HtmlName -ItemType file -Path $Logfilepath -ErrorAction Stop

# Define the script variables to hold the log file names.
$script:TxtLogFile = $LogFilePath + "\" + $TxtName
$script:HtmlLogFile = $LogFilePath + "\" + $HtmlName

Write-Verbose "The Raw logging will be in $script:TxtLogFile"
Write-Verbose "The html formatted logging will be in $script:HtmlLogFile"
} # END TRY (INITIAL TRY OF THE LOG FILE CREATION)

catch
{
Write-Verbose "Could not create the log files in $LogFilePath ."
Write-Verbose "Trying to switch to current user DOCUMENT FOLDER"

# Define the user document Folder
$LogFilePath = $HOME + "\Documents"

# SECOND TRY CREATION OF THE LOG FILE
try
{
# Creation of the file.
New-Item -Name $TxtName -ItemType file -Path $Logfilepath -ErrorAction Stop
New-Item -Name $HtmlName -ItemType file -Path $Logfilepath -ErrorAction Stop

# Define the script variables to hold the log file names.
$script:TxtLogFile = $LogFilePath + "\" + $TxtName
$script:HtmlLogFile = $LogFilePath + "\" + $HtmlName

Write-Verbose "The Raw logging will be in $script:TxtLogFile"
Write-Verbose "The html formatted logging will be in $script:HtmlLogFile"
} # END TRY (SECOND TRY OF THE LOG FILE CREATION)
catch
{
Write-Host "The Log Files could not be created." -ForegroundColor Red -BackgroundColor white
Write-Host "ABORTING" -ForegroundColor Red -BackgroundColor white
exit
} # END CATCH SECOND TRY OF LOG FILE CREATION
} # END CATCH INITIAL LOG FILE CREATION

} # END Initialize-LogFiles

<#
.SYNOPSIS
Add current Date and Time to a name.

.DESCRIPTION
Add a the current date (DD-MM-YYYY) and current time (HH-MM-SS) to a string.

.PARAMETER Message
The test to xhich the Date and Time must ne added

.EXAMPLE
PS C:\> Get-NameWithCurrentTime -Message 'Value1'

.NOTES
Additional information about the function.
#>
function Get-NameWithCurrentTime
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true,
Position = 0,
HelpMessage = 'Text to which add Date and Time')]
[Alias('Mess')]
[string]$Message
)

# Get the current Date
$Now = Get-Date

# get the DAY in string format
$NowDay = $Now.day.ToString()
if ($NowDay.length -ne 2)
{
# There is less than two characters. Adding a 0
$NowDay = "0" + $NowDay
} # ENDIF if ($NowDay.length -ne 2)

# Get the MONTH in string format
$NowMonth = $Now.month.ToString()
if ($NowMonth.length -ne 2)
{
# There is less than two characters. Adding a 0
$NowMonth = "0" + $NowMonth
} # ENDIF if ($NowMonth.length -ne 2)

# Get the YEAR in string format
$nowYear = $Now.Year.ToString()

# Get the HOUR in string format
$NowHour = $Now.Hour.ToString()
if ($NowHour.length -ne 2)
{
# There is less than two characters. Adding a 0
$nowHour = "0" + $NowHour
} # ENDIF ($NowHour.length -ne 2)

# Get the MINUTES in string format
$NowMinutes = $Now.Minute.ToString()
if ($NowMinutes.length -ne 2)
{
# There is less than two characters. Adding a 0
$nowMinutes = "0" + $NowMinutes
} # ENDIF ($NowMinutes.length -ne 2)

# Get the second in string format
$NowSeconds = $Now.Second.ToString()
if ($NowSeconds.length -ne 2)
{
# There is less than two characters. Adding a 0
$nowSeconds = "0" + $NowSeconds
} # ENDIF if ($NowMinutes.length -ne 2)

$Result = $Message + " $NowDay˰$NowMonth˰$nowYear - $Nowhour˰$NowMinutes˰$NowSeconds"

return $Result

} # END function Get-NameWithCurrentTime

<#
.SYNOPSIS
This function test if a file is a correct JSON File.

.DESCRIPTION
This function uses a try {} catch construct to define if a file is a correclty formatted JSON file.


.PARAMETER InitialLogLevel
This is the first level of logging that this function will create using the add-logentry function.


.PARAMETER PathToFileToTest
The Path to the file that must be tested to check if it is a correctly formatted JSON File

.EXAMPLE
PS C:\> Test-JsonFileValidity -InitialLogLevel $value1 -PathToFileToTest 'Value2'

.NOTES
Additional information about the function.
#>
function Test-JsonFileValidity
{
[CmdletBinding()]
[OutputType([boolean])]
param
(
[Parameter(Mandatory = $true,
Position = 0)]
[ValidateRange(1, 16)]
[Alias('ILL')]
[int]$InitialLogLevel,
[Parameter(Mandatory = $true,
Position = 1,
HelpMessage = 'File to test')]
[ValidateScript({ test-path $psitem })]
[Alias('PTFTT')]
[string]$PathToFileToTest
)

Add-LogEntry -LogLevel $InitialLogLevel -TxtLogFileName $script:TxtLogFile -HtmlLogFileName $script:HtmlLogFile -LogMessage "ENTERED FUNCTION Test-JsonFileValidity."

Add-LogEntry -LogLevel ($InitialLogLevel + 1) -TxtLogFileName $script:TxtLogFile -HtmlLogFileName $script:HtmlLogFile -LogMessage "Getting Content of the file."
$FileContent = Get-Content -Path $PathToFileToTest -raw

Add-LogEntry -LogLevel ($InitialLogLevel + 1) -TxtLogFileName $script:TxtLogFile -HtmlLogFileName $script:HtmlLogFile -LogMessage "Trying to convert to JSON and check if there is an error."
try
{
$powershellRepresentation = $FileContent | ConvertFrom-Json -ErrorAction Stop
$validJson = $true
Add-LogEntry -LogLevel ($InitialLogLevel + 2) -TxtLogFileName $script:TxtLogFile -HtmlLogFileName $script:HtmlLogFile -LogMessage "The file is a correctly formatted JSON file."

}
catch
{
$validJson = $false
Add-LogEntry -LogLevel ($InitialLogLevel + 2) -TxtLogFileName $script:TxtLogFile -HtmlLogFileName $script:HtmlLogFile -LogMessage "The file is NOT a correctly formatted JSON file." -IsError $true

}
return $validJson
}




#endregion FUNCTIONS


#region MAIN

MMMMMMMM MMMMMMMM AAA IIIIIIIIIINNNNNNNN NNNNNNNN
M:::::::M M:::::::M A:::A I::::::::IN:::::::N N::::::N
M::::::::M M::::::::M A:::::A I::::::::IN::::::::N N::::::N
M:::::::::M M:::::::::M A:::::::A II::::::IIN:::::::::N N::::::N
M::::::::::M M::::::::::M A:::::::::A I::::I N::::::::::N N::::::N
M:::::::::::M M:::::::::::M A:::::A:::::A I::::I N:::::::::::N N::::::N
M:::::::M::::M M::::M:::::::M A:::::A A:::::A I::::I N:::::::N::::N N::::::N
M::::::M M::::M M::::M M::::::M A:::::A A:::::A I::::I N::::::N N::::N N::::::N
M::::::M M::::M::::M M::::::M A:::::A A:::::A I::::I N::::::N N::::N:::::::N
M::::::M M:::::::M M::::::M A:::::AAAAAAAAA:::::A I::::I N::::::N N:::::::::::N
M::::::M M:::::M M::::::M A:::::::::::::::::::::A I::::I N::::::N N::::::::::N
M::::::M MMMMM M::::::M A:::::AAAAAAAAAAAAA:::::A I::::I N::::::N N:::::::::N
M::::::M M::::::M A:::::A A:::::A II::::::IIN::::::N N::::::::N
M::::::M M::::::M A:::::A A:::::A I::::::::IN::::::N N:::::::N
M::::::M M::::::M A:::::A A:::::A I::::::::IN::::::N N::::::N
MMMMMMMM MMMMMMMMAAAAAAA AAAAAAAIIIIIIIIIINNNNNNNN NNNNNNN



#region CleanVariablesFromPreviousRun

cd variable:
del dataLogFile
del HtmlLogFile
del OriginalOwnershipLogfile
del TxtLogFile
del logcontent
del logindexes
del test

#endregion CleanVariablesFromPreviousRun

#region LogFileCreation

Initialize-LogFiles -LogFolder c:\temp -LogNamePatern "STEF PKI MODULE"

#endregion LogFileCreation

Add-LogEntry -LogLevel 1 -TxtLogFileName $Script:TxtLogFile -HtmlLogFileName $Script:HtmlLogFile -LogMessage 'STARTING'

Add-LogEntry -LogLevel 2 -TxtLogFileName $Script:TxtLogFile -HtmlLogFileName $Script:HtmlLogFile -LogMessage 'CALLING NEW-CAROOT'

New-CAROOT -FilePath C:\SOURCES\CADEF.json





#endregion MAIN
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell studio and argument completer

Post by jvierra »

If you have a large script to attach please attach it as a file. Code posted in as text cannot be successfully copied for testing. Please edit your post and attach the file.

You have also not explained what it is that you mean by "argument completer".
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: PowerShell studio and argument completer

Post by jvierra »

OK. I see what you area asking about [ArgumentCompleter()]. Unfortunately this is not documented in any of the standard documentation and the references I can find are wither incomplete or incorrect.

Please attach you code correctly as a file as it is unreadable and cannot be copied as posted.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked