Appeler une fonction dans Powershell
Bonjour,
J'essaye de créer une fonction dans PowerShell. Je veux l'appeler dans mon script. C'est quoi l'erreur que je fais car ça ne fonctionne pas.
Voici l'erreur que je recois:
Start-Process : Lecteur introuvable. Il n'existe aucun lecteur nommé «*
$Msiexec = 'Msiexec.exe'
......
Voici mon script:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| $Test = "C:\Temp\Test"
$FolderTestExists = Test-Path $Test
function TestInstall {
$Msiexec = 'Msiexec.exe'
$MsiSources = 'Test.msi'
$InstallMode = '/i'
$ArgumentMSI = 'Test.mst'
$SilentMode = '/qb+'
$MsiArgument = "/l*v C:\Temp\TestMSI.log"
$MsiCommandLine = $InstallMode + ' ' + '"' + $MsiSources + '"' + ' ' + 'TRANFORMS=' + '"' + $ArgumentMSI + '"' + ' ' + 'Reboot=ReallySuppress' + ' ' + $SilentMode + ' ' + $MsiArgument
$MsiCommandLine
$WorkingDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent -ErrorAction Stop
$Action = Start-Process $Msiexec -WorkingDirectory $WorkingDirectory -ArgumentList $MsiCommandLine -Wait -PassThru
$Action.WaitForExit()
}
If ($FolderTestExists -eq $true)
{
# Calling the function
TestInstall
}
else
{
Write-Host "Test MSI already installed"
} |
Merci d'avance pour toute réponse.