I’ve been working on our first Windows 11 deployments, and have noticed I’m getting the following error when the decrapifier script step runs from an MDT task sequence.<\/p>\n
As this is the first Windows 11 version I’ve deployed, I don’t know if this is specific to just<\/em> 24H2, or if there’s other W11 versions it’s also present with.<\/p>\n
When the script is run on the client outside of the task sequence (i.e. finish the deployment, then<\/em> run the script), it does so without error, getting and removing appxpackages as expected, it only seems to be failing as part of the task sequence and I feel like I’m pretty much at a dead end as to why. The error I’m getting is (the actual script path is the UNC path for the script within the deployment share):<\/p>\n Line 132 char 17 is the start of the Get-AppxPackage command Has anyone else seen something similar? Did you find a way to ‘fix’ it? I’ve been working on our first Windows 11 deployments, and have noticed I’m getting the following error when the decrapifier script step runs from an MDT task sequence.<\/p>\n As this is the first Windows 11 version I’ve deployed, I don’t know if this is specific to just<\/em> 24H2, or if there’s other W11 versions it’s also present with.<\/p>\n When the script is run on the client outside of the task sequence (i.e. finish the deployment, then<\/em> run the script), it does so without error, getting and removing appxpackages as expected, it only seems to be failing as part of the task sequence and I feel like I’m pretty much at a dead end as to why. The error I’m getting is (the actual script path is the UNC path for the script within the deployment share):<\/p>\n Line 132 char 17 is the start of the Get-AppxPackage command Has anyone else seen something similar? Did you find a way to ‘fix’ it? I’m fighting this exact same issue. I ran this script with windows 10 and 11 22h2 with no issues. Just went to do a new deployment with 24h2 and am having issues. Did you ever find the work around?<\/p>","upvoteCount":0,"datePublished":"2025-05-07T11:01:21.618Z","url":"https://community.spiceworks.com/t/windows-11-24h2-mdt-decrapifier-error/1177000/2","author":{"@type":"Person","name":"notwatchingyou","url":"https://community.spiceworks.com/u/notwatchingyou"}},{"@type":"Answer","text":" Same issue here. This is new with Windows 11 24H2 and was not happening with Windows 11 23H2. (or Windows 10)<\/p>\n It doesn’t seem to be possible to user Get-AppxPackage | Remove-AppxPackage from within a task sequence anymore. In my case I’m trying to remove “New Outlook”.<\/p>\n The best I could do is remove the provisioning package, which does work:<\/p>\n Removing the provisioning package prevents New Outlook from installing when new users log in, but does still leave a copy in the local administrator account that the deployment was running under since it already installed itself before the provisioning package was removed…<\/p>\n Removing the provisioning package before capturing doesn’t work either - Microsoft reinstalls it when the image first boots during the deployment - they really want you to have New Outlook!<\/p>","upvoteCount":0,"datePublished":"2025-05-16T09:40:48.869Z","url":"https://community.spiceworks.com/t/windows-11-24h2-mdt-decrapifier-error/1177000/3","author":{"@type":"Person","name":"simonbyrnand","url":"https://community.spiceworks.com/u/simonbyrnand"}},{"@type":"Answer","text":" I just updated MDT with Windows 11 24H2 and also seeing the same issue.
\nI found semi-related suggestions of ensuring features were enabled in Windows PE (.NET and PowerShell) which I added and regenerated boot images, although to my mind it’s a post-PE step anyway (I have the script executing between Restore User State and Restore Groups under State Restore). I also tried the suggestion of calling Import-Module Appx beforehand to see if the issue was the Get-AppxPackage cmdlet not being loaded for some reason, but this had no effect (and threw no additional error)<\/p>\n>The type initializer for '<Module>' threw an exception.\n> At \\\\path\\to\\script.ps1:132 char:17\n>+ $RemoveApps = Get-AppxPackage -allusers | where-object {$_.na...\n>+ ~~~~~~~~~~~~~~~\n>NotSpecified (:) [], TypeInitializationException\n<\/code><\/pre>\n
\nI have a modified version of the script, hence the different line number, but I’ve tested with the vanilla script dated Jan 6 2022 and get the same error, just a different line number (plus several more errors relating to registry keys etc. that I’ve taken out for W11 in my modified version - like the W10 start menu xml)<\/p>\n
\nI’ve confirmed I don’t get the error on W10 with all else the same (same order in task sequence, same parameters, all other MDT settings/option the same etc.)<\/p>","upvoteCount":6,"answerCount":5,"datePublished":"2025-02-19T14:48:05.229Z","author":{"@type":"Person","name":"jameseyre0722","url":"https://community.spiceworks.com/u/jameseyre0722"},"suggestedAnswer":[{"@type":"Answer","text":"
\nI found semi-related suggestions of ensuring features were enabled in Windows PE (.NET and PowerShell) which I added and regenerated boot images, although to my mind it’s a post-PE step anyway (I have the script executing between Restore User State and Restore Groups under State Restore). I also tried the suggestion of calling Import-Module Appx beforehand to see if the issue was the Get-AppxPackage cmdlet not being loaded for some reason, but this had no effect (and threw no additional error)<\/p>\n>The type initializer for '<Module>' threw an exception.\n> At \\\\path\\to\\script.ps1:132 char:17\n>+ $RemoveApps = Get-AppxPackage -allusers | where-object {$_.na...\n>+ ~~~~~~~~~~~~~~~\n>NotSpecified (:) [], TypeInitializationException\n<\/code><\/pre>\n
\nI have a modified version of the script, hence the different line number, but I’ve tested with the vanilla script dated Jan 6 2022 and get the same error, just a different line number (plus several more errors relating to registry keys etc. that I’ve taken out for W11 in my modified version - like the W10 start menu xml)<\/p>\n
\nI’ve confirmed I don’t get the error on W10 with all else the same (same order in task sequence, same parameters, all other MDT settings/option the same etc.)<\/p>","upvoteCount":6,"datePublished":"2025-02-19T14:48:05.344Z","url":"https://community.spiceworks.com/t/windows-11-24h2-mdt-decrapifier-error/1177000/1","author":{"@type":"Person","name":"jameseyre0722","url":"https://community.spiceworks.com/u/jameseyre0722"}},{"@type":"Answer","text":"Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq \"Microsoft.OutlookForWindows\" } | ForEach-Object {\n Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName\n}\n<\/code><\/pre>\n
\nCopying the script to the machine and running it works fine but doesnt run correctly via MDT.
\nDid anyone find a fix?<\/p>","upvoteCount":0,"datePublished":"2025-06-19T14:08:52.115Z","url":"https://community.spiceworks.com/t/windows-11-24h2-mdt-decrapifier-error/1177000/4","author":{"@type":"Person","name":"spiceuser-1va2s","url":"https://community.spiceworks.com/u/spiceuser-1va2s"}},{"@type":"Answer","text":"