-
Notifications
You must be signed in to change notification settings - Fork 0
PowerShell
Mathieu Lavigne edited this page Dec 17, 2025
·
4 revisions
[string[]]$scripts = If ($dropSchema) {
@("drop_schema.sql", "init.sql")
} Else {
@("init.sql")
}
$fileParameters = $scripts | ForEach-Object { "--file=$_" }Paramètre :
param(
## Mot-de-passe
[Parameter(mandatory = $true, HelpMessage = "Mot-de-passe")]
[SecureString]
$password
)Déchiffrement pour obtenir le mot-de-passe en clair :
$password_clear = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($password))Modifier le fichier renvoyer par la commande :
(Get-PSReadlineOption).HistorySavePathif (!$?) { exit } # Sort si la dernière commande a échoué (TODO : code d'erreur > 0 ?)
if (!$?) { throw "Erreur" } # Idem mais avec exceptioncmd | Select-String "ma chaîne recherchée"