Um zu überprüfen, ob ein Modul vorhanden Ich habe folgendes versucht:Wie überprüfe ich, ob ein Powershell-Modul installiert ist?
try {
Import-Module SomeModule
Write-Host "Module exists"
} catch {
Write-Host "Module does not exist"
}
Die Ausgabe lautet:
Import-Module : The specified module 'SomeModule' was not loaded because no valid module file was found in any module directory.
At D:\keytalk\Software\Client\TestProjects\Export\test.ps1:2 char:5
+ Import-Module SomeModule
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (SomeModule:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Module exists
ich einen Fehler, aber keine Ausnahme ausgelöst wird, so dass wir sehen Module exists
in der Ende, obwohl SomeModule
nicht existiert.
Kennt jemand einen guten Weg (vorzugsweise ohne einen Fehler zu erzeugen), um festzustellen, ob ein Powershell-Modul auf dem System installiert ist?
Siehe [Tipp: Geladene und verfügbare Module in Windows PowerShell anzeigen] (https://technet.microsoft.com/en-us/library/ff642467.aspx) –