PowerShell: Export-WindowsDriver cmdlet fails on Windows 11 (22000) and later on 7.2.1

Prerequisites

Steps to reproduce

  1. Open PowerShell 7 as administrator
  2. Run command `export-windowsdriver -Online -Destination C:\drivers’

Expected behavior

PS> export-windowsdriver -Online -Destination C:\drivers
PS>

Drivers exported to C:\drivers

Actual behavior

PS> export-windowsdriver -Online -Destination C:\drivers

'Export-WindowsDriver: SafeHandle cannot be null. (Parameter 'pHandle')'

Error details

Exception             :
    Type       : System.ArgumentNullException
    Message    : SafeHandle cannot be null. (Parameter 'pHandle')
    ParamName  : pHandle
    TargetSite :
        Name          : ThrowArgumentNullException
        DeclaringType : System.ThrowHelper, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    Source     : System.Private.CoreLib
    HResult    : -2147467261
    StackTrace :
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
   at Microsoft.Dism.Commands.DismInterop._DismExportDriver(UInt32 Session, String Destination, SafeWaitHandle
CancelHandle, ProgressCallback Progress, IntPtr UserData)
   at Microsoft.Dism.Commands.ExportWindowsDriverCommand.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Export-WindowsDriver], ArgumentNullException
FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Dism.Commands.ExportWindowsDriverCommand
InvocationInfo        :
    MyCommand        : Export-WindowsDriver
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 3
    Line             : export-windowsdriver -Online -Destination C:\drivers
    PositionMessage  : At line:1 char:1
                       + export-windowsdriver -Online -Destination C:\drivers
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : export-windowsdriver
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.22538
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

https://user-images.githubusercontent.com/10560135/150562770-bf893b2e-1cf8-48cd-a412-6b76878562ca.mp4

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18

Most upvoted comments

@andrewbaker-uk The cmdlet and module are not in the repository. So Windows Feedback tool is right way to report.