none
Capture Image - Powershell Script Error "Object reference not set to an instance of an object" RRS feed

  • Question

  • I am using MDT to capture a Windows 10 image.

    As part of the task sequence, I have a step that runs a Powershell script to remove several Windows Apps.

    This is the error that I received when capturing the image.

    "Cannot process argument transformation on parameter 'Package'. Object reference not set to an instance of an object"

    How do I correct the error?
    Is this an error with my script?

    The powershell script resides in MDTBuild$\Scripts

    This is the content of the Powershell script.

    Remove-AppxPackage -package (Get-AppxPackage Microsoft.MicrosoftOfficeHub).PackageFullName
    Remove-AppxPackage -package (Get-AppxPackage Microsoft.ConnectivityStore).PackageFullName

    Wednesday, January 11, 2017 8:27 PM

Answers

  • The packages don't exist, that's why the script is failing.

    Reworked:

    "Microsoft.MicrosoftOfficeHub","Microsoft.ConnectivityStore" | 
        %{ Get-AppxPackage -name $_ } | 
        Remove-AppxPackage
    IN this example, if the packages don't exist, they won't pass through the pipeline to the remove  step.


    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com


    Wednesday, January 18, 2017 5:57 AM
    Moderator

All replies

  • Have you tried using the Run Powershell TS step instead of Run Command Line?

    Although if you can run your Powershell Script outside of MDT and it doesn't work then 100% it is an error with your script.


    Many questions such as where do I find logs and what logs are interesting are found in: MDT TechNet Forum - FAQ & Getting Started Guide Please take the time to read it. Also if you don't post logs your problem won't be easily solved.


    Wednesday, January 11, 2017 8:50 PM
    Moderator
  • Tried that just now and same result.
    Thursday, January 12, 2017 4:06 PM
  • The packages don't exist, that's why the script is failing.

    Reworked:

    "Microsoft.MicrosoftOfficeHub","Microsoft.ConnectivityStore" | 
        %{ Get-AppxPackage -name $_ } | 
        Remove-AppxPackage
    IN this example, if the packages don't exist, they won't pass through the pipeline to the remove  step.


    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com


    Wednesday, January 18, 2017 5:57 AM
    Moderator