84 lines
No EOL
1.7 KiB
PowerShell
84 lines
No EOL
1.7 KiB
PowerShell
Write-Output "chargement du module"
|
|
|
|
function Get-LogTimeStamp {
|
|
return (Get-Date).toString("yyyy.MM.dd HH:mm:ss")
|
|
}
|
|
|
|
function ConvertTo-CmdlineOptions {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$True)]
|
|
[object]
|
|
$options,
|
|
|
|
[Parameter(Mandatory=$False)]
|
|
[string]
|
|
$sep=" "
|
|
)
|
|
|
|
Write-Debug "Call parse_options with $options, separator: `"$sep`""
|
|
$opt = ""
|
|
if ($options -eq $false) {
|
|
return ""
|
|
}
|
|
$options.Keys | foreach {
|
|
if ( -not $($options.item($_)) -eq "" ) {
|
|
$opt = -join($opt, " $($_)", $sep, "$($options.item($_))")
|
|
}
|
|
else {
|
|
$opt = -join($opt, " $($_)")
|
|
}
|
|
}
|
|
return $opt
|
|
}
|
|
|
|
function Set-Error {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$True)]
|
|
[string]
|
|
$message
|
|
)
|
|
|
|
if ( $global:logfile ) {
|
|
Add-Content $global:logfile -Value "$(Get-LogTimeStamp)`tERROR`t$message"
|
|
}
|
|
else {
|
|
Write-Host -ForegroundColor Red $message
|
|
}
|
|
|
|
}
|
|
|
|
function Set-Warning {
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$True)]
|
|
[string]
|
|
$message
|
|
)
|
|
if ( $global:logfile ) {
|
|
Add-Content $global:logfile -Value "$(Get-LogTimeStamp)`tWARN`t$message"
|
|
}
|
|
else {
|
|
Write-Host -ForegroundColor Yellow $message
|
|
}
|
|
}
|
|
|
|
function Set-Message {
|
|
|
|
[CmdletBinding()]
|
|
Param(
|
|
[Parameter(Mandatory=$True)]
|
|
[string]
|
|
$message
|
|
)
|
|
|
|
if ( $global:logfile ) {
|
|
Add-Content $global:logfile -Value "$(Get-LogTimeStamp)`tINFO`t$message"
|
|
}
|
|
else {
|
|
Write-Host "$message"
|
|
}
|
|
}
|
|
|
|
Export-ModuleMember -Function ConvertTo-CmdlineOptions, Set-Message, Set-Warning, Set-Error |