Win11 Post-Setup run PS command Remove-AppPackage (Cortana)

ubunonymount

New Member
Hello,

I want to run the following command on first user logon:
Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage
This command will remove Cortana App from Startmenu.
Unfortunately I could not figure out how to do so.
I tried several Post-Setup settings:

  • Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage
  • powershell "Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage"
  • powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass "Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage"
None of them work.
The app is still visible in Startmenu.
What am I doing wrong in Post-Setup settings?
Thank you!


1677370149632.png
 
Hello,

I want to run the following command on first user logon:

This command will remove Cortana App from Startmenu.
Unfortunately I could not figure out how to do so.
I tried several Post-Setup settings:

  • Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage
  • powershell "Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage"
  • powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass "Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage"
None of them work.
The app is still visible in Startmenu.
What am I doing wrong in Post-Setup settings?
Thank you!


View attachment 9363

try that
 
Hello Taosd, thank you for your fast reply!
Unfortunately that is not what I'm trying to do, because I need some Cortana Components to keep the search engine in Windows settings menu.

I want to install Cortana in the first place, and then remove the app from start menu.
I want to do that by running a powershell command on first logon.
I tried out this powershell command, it's working when I run that command directly from powershell with Admin rights:
Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage

Unfortunately I couldn't figure out how to make ntlite build this command into the iso image, so that it will be executed automatically after the first user logon.
Please help me figuring out, how to run this Post-Setup command!
Thank you!
 
Cortana is a different entity to search as i have personally disabled cortana and had search working independantly to it. ( read post 2 of that link. as stated there, search works fine even without cortana being present, yet alone installed then uninstalled )

I don't personally have any knowledge of powershell as i don't use it, but some of the other members here can help with that bit.

I can only advise on what i know.
 
If you remove Cortana in W11 it breaks search inside Settings. There aren't really "sub components" to remove as MS re-organized Cortana since the early W10 builds and it's down to one removable package. Actually it's not obtrusive any more.
 
If you remove Cortana in W11 it breaks search inside Settings. There aren't really "sub components" to remove as MS re-organized Cortana since the early W10 builds and it's down to one removable package. Actually it's not obtrusive any more.
Hello garlin, thank you for your fast respond!
Unfortunately that is NOT true. Windows settings search works perfectly fine after removing Cortana.
The only thing to keep in mind: You must NOT remove Cortana from NTLite.
1677448130057.png
Instead you have to keep the Cortana component checked✔️ in NTLite/Components/Windows Apps/Apps/Cortana.
After installing the custom ISO Image with Cortana beeing installed, you have to manually uninstall Cortana by running following command in powershell (Administrator):
Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppPackage

Powershell_Remove_Cortana.JPG

In both scenarios Cortana has been removed. But in the left the settings-search still works.
In the right machine the settings-search doesn't work!

Settings.JPG
The left picture shows Cortana beeing first installed using the ntlite ISO image and then afterwards beeing removed using powershell.
The right picture shows Cortana beeing removed in the first place by unchecking the component in ntlite.
remove_cortana_in_ntlite.JPG

As you see, the only option to remove Cortana and keep the settings-search is the left option (first install Cortana and then remove it manually after installation).

Post-Setup.JPG

So my question is still (like the title of the thread):
How can I do that automatically?

How
can I run a "Remove-AppPackage" powershell-command in Windows 11 Post-Setup using NTLite?

I'm doing something wrong, but I could not figure out what it is.
Because manually running the powershell command works.
Only running it automatically in Post-Setup unfortunately is still NOT working. (Cortana is still there).

So, please do only reply to my question if you have any idea regarding Post-Setup Command Execution as Administrator!
Thank you very much!
 

Attachments

  • 1677454104873.png
    1677454104873.png
    100.7 KB
Last edited:
Hello garlin, thank you for your fast respond!
Unfortunately that is not true. Windows settings search works perfectly fine after removing Cortana.
The only thing to keep in mind: You must NOT remove Cortana from ntlite.
View attachment 9369
Instead you have to keep the Cortana component checked in NTLite/Components/Windows Apps/Apps/Cortana.
After installing the custom ISO Image with Cortana beeing installed, you have to manually uninstall Cortana by running following command in powershell (Administrator):


View attachment 9373

In both scenarios Cortana has been removed. But in the left the settings/search still works.
In the right machine the settings/search doesn't work.

View attachment 9371
The left picture shows Cortana beeing first installed using the ntlite ISO image and then afterwards beeing removed using powershell.
The right picture shows Cortana beeing removed in the first place by unchecking the component in ntlite.

As you see, the only option to remove Cortana and keep the settings-search is the left option (first install Cortana and then remove it manually after installation).

View attachment 9375

So my question is still (like the title of the thread):
How can I run a "Remove-AppPackage" powershell-command in Windows 11 Post-Setup using NTLite?

I'm doing something wrong, but I could not figure out what it is.
Because manually running the powershell command works.
Only running it automatically in Post-Setup unfortunately is still not working. (Cortana is still there).

So, please do only reply to my question if you have any idea regarding Post-Setup Command Execution as Administrator!
Thank you very much!

Please pay attention to the typing syntax........ you are closing the powershell statement with AppPackage in ntlite and AppxPackage in powershell.


As garlin has suggested to you earlier, maybe you have typed that part of the command wrong
 
The package isn't removed from Windows, Remove-AppxPackage will only de-provisioning it from your account.
Remove-AppxProvisionedPackage actually removes packages.

I'm out.
 
Please pay attention to the typing syntax........ you are closing the powershell statement with AppPackage in ntlite and AppxPackage in powershell.


As garlin has suggested to you earlier, maybe you have typed that part of the command wrong
Hallo Taosd, thank you for your fast reply.
Okay, I will try out with adding an "x" in Remove-AppxPackage.

Get-AppxPackage -AllUsers Microsoft.549981C3F5F10 | Remove-AppxPackage

1677489148484.png

Unfortunately it didn't solve my problem.
Cortana is still activated.
So, I have no idea what to try next.
I think maybe its not working because of unsufficiant previlidges (run as Admin needed).
But how am I going to tell NTLite to run that command as Administrator???

1677490618118.png

Maybe this command cannot be executed in Post-Setup, but I don't know why.
If anyone has some idea and expertise with Post-Setup code execution, please let me know!
Thank you!
 
...Unfortunately it didn't solve my problem...
I think I can re-explain this thread and provide extra insight that will help you understand what's going on:

Remove-AppxPackage
Remove-AppxPackage (it needs the "x" in there) essentially means that all the files still remain on the machine, but for that user it will basically just disable the app. It does not uninstall it (remove files). This is why the search/settings continue to work properly, because you have not actually removed files, which means you haven't lost any dependencies.

Remove-AppxProvisionedPackage
Remove-AppxProvisionedPackage (it needs the "Provisioned" in there) doesn't just disable the app, it also uninstalls it (removes files). This causes search/settings to break, because now all the files that other parts of Windows rely on (dependencies) get removed from the machine. NTLite uses this command and that's why things break when Cortana is checked for removal.

Incorrect Commands
The main issue here is that the syntax of commands are extremely important, and by typing in the wrong command you aren't uninstalling Cortana. On your live install of Windows, use the Remove-AppxProvisionedPackage command and you will see that search/settings will probably break, just like it does when you uninstall Cortana through NTLite. You are also making the additional mistake of trying to use "App" instead of "Appx" in some places, which is causing extra problems.

Optimizing Cortana
If you want to keep functionality so that search/settings still work, but also lower the resources/annoyances of Cortana, look at this guide (link) and see if it's something that will work for you.

Cortana Discrepencies
There is general confusion among people regarding Cortana, as some people will say removing it breaks things, and others will say it doesn't. I haven't tested every scenario myself to know for sure, but I believe the reason for this discrepency is because Cortana has gone through many iterations over the years, and the operating system (W10 vs W11), as well as the version (22H2, etcetera), may make it behave differently. I've also heard that there are some regional differences in Cortana too. The version of NTLite used probably matters as well. The point here is to be aware that all the information you come across about Cortana may not be accurate because of these many factors.
 
Last edited:
I think I can re-explain this thread and provide extra insight that will help you understand what's going on:

Remove-AppxPackage
Remove-AppxPackage (it needs the "x" in there) essentially means that all the files still remain on the machine, but for that user it will basically just disable the app. It does not uninstall it (remove files). This is why the search/settings continue to work properly, because you have not actually removed files, which means you haven't lost any dependencies.

Remove-AppxProvisionedPackage
Remove-AppxProvisionedPackage (it needs the "Provisioned" in there) doesn't just disable the app, it also uninstalls it (removes files). This causes search/settings to break, because now all the files that other parts of Windows rely on (dependencies) get removed from the machine. NTLite uses this command and that's why things break when Cortana is checked for removal.

Incorrect Commands
The main issue here is that the syntax of commands are extremely important, and by typing in the wrong command you aren't uninstalling Cortana. On your live install of Windows, use the Remove-AppxProvisionedPackage command and you will see that search/settings will probably break, just like it does when you uninstall Cortana through NTLite. You are also making the additional mistake of trying to use "App" instead of "Appx" in some places, which is causing extra problems.

Optimizing Cortana
If you want to keep functionality so that search/settings still work, but also lower the resources/annoyances of Cortana, look at this guide (link) and see if it's something that will work for you.

Cortana Discrepencies
There is general confusion among people regarding Cortana, as some people will say removing it breaks things, and others will say it doesn't. I haven't tested every scenario myself to know for sure, but I believe the reason for this discrepency is because Cortana has gone through many iterations over the years, and the operating system (W10 vs W11), as well as the version (22H2, etcetera), may make it behave differently. I've also heard that there are some regional differences in Cortana too. The version of NTLite used probably matters as well. The point here is to be aware that all the information you come across about Cortana may not be accurate because of these many factors.
Hello Hellbovine,

thank you for your detailed comment!
Yes, I tried out several options.
Unfortunately I'm still struggling with this Post-Setup routine.

I don't understand what I'm doing wrong.
I just want to run a simple powershell command on first User Logon.
Why is this command not executed?
Maybe there is a bug in NTLite?

I tried out another approach: I tried out not to run the command directly in NTLite but rather executed a .ps1 Powershell script which calls the desired command.
1677632127919.png1677632240291.png

Unfortunately this doesn't works either.
I'm very frustrated, because the command is correct.
I tried it out on Windows 11 and it works fine!
Get-AppxPackage *Microsoft.549981C3F5F10* | Remove-AppxPackage
But on Post-Setup it does not!
Why is that so?
There must be a logical answer?
Thanks!
 
Try these two things together:

1) Add -AllUsers back into your commands
2) Move the ps1 file into the "User - Execution queue" instead of "Machine"

I don't use post-setup in my images, so I don't have a lot of experience with it. If this doesn't work then someone else will have to help you there, since I currently cannot test this to figure it out because my computer is tied up on other projects.

You could also try and see if the registry key below removes Cortana from the start menu. If you have a live install of Windows where Cortana is still showing up in the start menu, add this key then reboot and see if it disappears afterward. If so, you could integrate it using NTLite as the solution:

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search]
"AllowCortana"=dword:00000000
 
Back
Top