On one of about 15 computers the command Import-Module freezes without reaching the if-clause:
Import-Module PSWindowsUpdate
if ($?) {
"--- Import-Module PSWindowsUpdate erfolgreich"
} else {
"+++ Fehler bei Import-Module PSWindowsUpdate - Prozedur wird beendet"
exit 1
}
I checked
PSModulePath=C:\Program Files\WindowsPowerShell\Modules; ...
and assured that the module PSWindowsUpdate is within C:\Program Files\WindowsPowerShell\Modules. It also freezes if I include a direct path to the module:
Import-Module <path>\PSWindowsUpdate
What is the best way to debug the problem?
Should I use try/catch instead of if ($?) ?
Many thanks - Michael