jantari / LSUClient

Orchestrate driver, BIOS/UEFI and firmware updates for Lenovo computers 👨‍💻
https://jantari.github.io/LSUClient-docs/
MIT License
201 stars 21 forks source link

The term 'Get-PnpDevice' is not recognized as the name of a cmdlet, function, script file, or operable #40

Closed Sri-Boddupalli closed 2 years ago

Sri-Boddupalli commented 2 years ago

I am getting this error while implementing this in SCCM Imaging process.

The term 'Get-PnpDevice' is not recognized as the name of a cmdlet, function, script file, or operable

tried to troubleshoot various things but couldn't find an apt solution, any ideas?

Total implementation is in here https://www.imab.dk/install-lenovo-drivers-and-bios-directly-from-lenovos-driver-catalog-during-osd-using-configuration-manager/?unapproved=12370&moderation-hash=5edf7e560aecd2c80bfd5c796ffa2ea5#comment-12370 Thanks,

jantari commented 2 years ago

Could it be that you're trying to run it on Windows 7 or another old version of Windows and/or PowerShell?

Sri-Boddupalli commented 2 years ago

Trying to Image OS with Windows 10 21H1. When I ran the same cmdlet it was working fine but during the imaging its failing like that

jantari commented 2 years ago

Maybe you're trying to run it in the WinPE environment, too early during the imaging process, rather than in the "online" FullOS?

Make sure your LSUClient step is towards the end of the task sequence, in the "State Restore" section.

jantari commented 2 years ago

Have you been able to solve your problem?

Sri-Boddupalli commented 2 years ago

Running in Full OS and made sure doing everything correctly, Still this is a problem, I checked by just running Get-PnpDevice upfront and it did not recognize the command saying this

Error Begin: CategoryInfo : ObjectNotFound: (Get-PnpDevice:String) [], CommandNotFoundException VERBOSE: Script is running. VERBOSE: Lenovo device is detected. Continuing. VERBOSE: Lenovo modelnumber: 20L6 - Lenovo model: ThinkPad T480 VERBOSESUClient module not loaded. Continuing. VERBOSE: LSUClient module found available. Try importing and loading it. Error End:

jantari commented 2 years ago
  1. Does Get-Module PnpDevice -ListAvailable -All | Format-List show anything?
  2. Does Get-CimInstance -ClassName Win32_PnPEntity -Namespace 'root/CIMV2' work?
  3. Is Get-PnpDevice recognized as a command and working after the deployment has finished and you log into the computer?
Sri-Boddupalli commented 2 years ago
  1. I cannot Open the cmd prompt during the imaging after exiting the WinPE environment where I am running this LSUClient child Task Sequence so I could not test it at that moment. But based on the logging I enables its a NO
  2. Yes
  3. Yes
jantari commented 2 years ago

I'm not sure honestly, it seems there's either something off with the image you're deploying or by the time you attempt to run LSUClient some policies have already kicked in that remove or restrict things.

The PnpDevice module is a standard component of Windows 8, 10 and 11 and is always available by default.

When I run the following script as part of my task sequence, right before LSUClient:

Write-Output "--- PnpDevice Module diagnosis"
Write-Output "PSModulePath ENV Variable:"
$env:PSModulePath -split ";"
Write-Output ""
Get-Module -Name PnpDevice -ListAvailable -All | Format-List
Write-Output "---"

this is the output I get, and this is what it should be:

--- PnpDevice Module diagnosis
PSModulePath ENV Variable:
C:\Users\Administrator\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\windows\system32\WindowsPowerShell\v1.0\Modules

Name              : PnpDevice
Path              : C:\windows\system32\WindowsPowerShell\v1.0\Modules\PnpDevice\PnpDevice.cdxml
Description       :
ModuleType        : Cim
Version           : 1.0
NestedModules     : {}
ExportedFunctions : {Get-PnpDevice, Enable-PnpDevice, Disable-PnpDevice, Get-PnpDeviceProperty}
ExportedCmdlets   :
ExportedVariables :
ExportedAliases   :

Name              : PnpDevice
Path              : C:\windows\system32\WindowsPowerShell\v1.0\Modules\PnpDevice\PnpDevice.psd1
Description       :
ModuleType        : Manifest
Version           : 1.0.0.0
NestedModules     : {PnpDevice}
ExportedFunctions : {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}
ExportedCmdlets   :
ExportedVariables :
ExportedAliases   :

---

If you're running in FullOS but the PnpDevice module isn't available then I think that's something you'll have to diagnose on your end, I'm afraid I can't help much with that.

jantari commented 2 years ago

Closing because it's not an issue with LSUClient