nognog
Goto Top

SCCM - Skript wird nicht richtig ausgeführt

Guten Tag Zusammen

Ich habe Heute ein kleines Powershell Skript mit SCCM verteilt. Das Skript sieht so aus:
"
Start-Transcript -Path "C:\Windows\ccmcache\dummy.txt" -Append

Install-WindowsFeature -Name System-Insights -IncludeManagementTools

Stop-Transcript
"
Das Skript wird wir ohne Probleme von SCCM ausgeführt, jedoch steht im Logfile:
"
Transcript started, output file is C:\Windows\ccmcache\dummy.txt
Install-WindowsFeature : The term 'Install-WindowsFeature' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\WINDOWS\ccmcache\q\dummy_script.ps1:5 char:1

back-to-topInstall-WindowsFeature -Name System-Insights -IncludeManagementTools

back-to-top~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Install-WindowsFeature:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Install-WindowsFeature : The term 'Install-WindowsFeature' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\WINDOWS\ccmcache\q\dummy_script.ps1:5 char:1

back-to-topInstall-WindowsFeature -Name System-Insights -IncludeManagementTools

back-to-top~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (Install-WindowsFeature:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException


Windows PowerShell transcript end
End time: 20200703083228

"

Kann mir jemand weiterhelfen wieso der Befehl "Install WindowsFeature" nicht funktioniert? Wenn ich den Befehl selber ausführe, funktioniert es ohne Probleme.

Danke für die Hilfe

LG, NogNog

Content-Key: 584492

Url: https://administrator.de/contentid/584492

Printed on: April 19, 2024 at 20:04 o'clock

Member: Th0mKa
Th0mKa Jul 03, 2020 at 06:59:30 (UTC)
Goto Top
Moin,

Du versuchst nicht zufällig das auf einem Client OS auszuführen? Was passiert denn wenn man das Skript manuell auf dem Zielsystem ausführt?

/Thomas
Member: NogNog
NogNog Jul 03, 2020 at 07:17:25 (UTC)
Goto Top
Nein ich führe das auf einem Windows Server 2019 aus. Wenn ich es auf dem Zielsystem ausführe funktioniert das Skript ohne Probleme.
Mitglied: 144705
144705 Jul 03, 2020 updated at 12:37:51 (UTC)
Goto Top
Dann hat entweder der ausführende Account unter dem das Skript ausgeführt wird zu wenig Rechte auf dem Zielsystem oder der "Constrained Language Mode" ist aktiviert worden.
Lade das Modul auch mal explizit bevor du es benutzt.
Import-Module Servermanager
Member: NogNog
NogNog Jul 06, 2020 at 06:44:40 (UTC)
Goto Top
Ich habe es mit einem Arbeitskollegen angeschaut. Wir haben das Skript im Kontext ausgeführt, wie es auch SCCM machen würde. Ich habe auch die 64-Bit Powershell Version benutzt. Habe auch mal das Servermanager Modul geladen und dort habe ich die Rückmeldung bekommen: "Import-Module : The specified module 'servermanager' was not loaded because no valid module file was found in any
module directory.".

Aber danke für die Tipps..
Mitglied: 144705
144705 Jul 06, 2020 updated at 06:53:35 (UTC)
Goto Top
Dann habt ihr den jeweiligen Server zermatscht oder die SCCM Berechtigungen nicht korrekt eingerichtet, geht hier nämlich einwandfrei.
S.o. auch den Hinweis zum constrained language mode!
Member: NogNog
NogNog Jul 06, 2020 at 08:31:56 (UTC)
Goto Top
Okay. Hast du denn ein Software Package gemacht oder wie hast du das Script deployed?
Mitglied: 144705
144705 Jul 06, 2020 updated at 08:42:23 (UTC)
Goto Top