r/Intune • • 2d ago

App Deployment/Packaging Replacing PowerShell 5.1 with PowerShell Core

Microsoft has announced that PowerShell Core will replace PowerShell 5.1 in future versions of Windows.

My concern relates to installation and uninstallation commands.

Currently, I use the "powershell ..." command for all applications.

In PowerShell 7, the command begins with "pwsh".

How can this be resolved?

0 Upvotes

22 comments sorted by

18

u/ViperThunder 2d ago

use pwsh... Instead of powershell..problem solved

-10

u/h3lls_itch 2d ago

Not all user machines will be updated at the same time; I need compatibility with machines that will still be running PowerShell 5.1.

14

u/HuckleberrySad4397 2d ago

Install PowerShell 7 on all your systems?

6

u/diamkil 2d ago

Use install scripts instead of putting the ps1 in the win32 package with a powershell command

4

u/actually_stellaserve 2d ago

You can still call the script with `powershell.exe -File script.ps1` even after the switch, it's not like 5.1 evaporates overnight. If you're packaging for Intune, just wrap it in a.cmd that does a quick check for `pwsh.exe` first and falls back to `powershell.exe` if it's not there. Grabs whichever runtime is handy without needing to rework every app.

2

u/diamkil 2d ago

I still feel like using installation scripts directly in Intune is better though

1

u/Stinjy 2d ago

Unless something has changed, the regular powershell scripts (not remediation) in Intune are awful. They run a few times whenever they feel like it and never again until they're modified. Powershell scripts wrapped as Win32apps are way more reliable with detection.

4

u/CaptainSeitan 2d ago

Its a fairly new feature in win32 apps where you can just select a powershell script, its quite nice as it gets you preview the script from the app

1

u/robidog 1d ago

Exactly. And now that it ACTUALLY runs in 64-bit (and not only claims to) there’s no reason to use scripts embedded in the .intunewin anymore.

1

u/diamkil 2d ago

I'm not talking about those, when you create an app you can use install command or install script

1

u/robidog 1d ago

Interesting. Not in my experience.

1

u/FireLucid 21h ago

I'd love them if they worked. Last time I did, they were messed up bad.

First of all, your can't select them until you type something in the install command. Then it becomes available, you can select it and enter your script. While looking at the properties of the app, I was trying to troubleshoot why the install was failing and noticed it had reverted back to an install command of aaa. After it did that twice (and I think the 32/64bit radio button didn't work either) I went back to packaged a PowerShell script.

1

u/diamkil 21h ago

I updated all my apps to them instead of a packaged script like a month after release once they ironed the kinks out

1

u/FireLucid 21h ago

Both those issues are fixed? I'll have to have a look again.

1

u/diamkil 21h ago

You still need to enter a character in the install command for the dropdown to be available but I haven't had the save issue in forever

1

u/Embarrassed-Survey52 2d ago

.cmd’s look so messy though, like there from a bygone era, i have a completely unreasonable distrain when i see environments where the packagers have set it up with install.cmd and uninstall.cmd, it’s just not transparent enough. And if the install command needs to be changed to add a switch etc, then you’re repackaging the whole intunewim for a short command change.

Better to leave it till the msix has been polished, deploy it then change them all to pwsh at the same time with graph.

1

u/Abject-Mountain-6907 2d ago

This. Use Win32 when you also need to copy files or folders as part of the script action.

-3

u/h3lls_itch 2d ago

I use the IntuneWin32App module for automated deployment via GitHub Actions.

However, this module does not support installation scripts.

10

u/BlackV 2d ago edited 2d ago

They are not doing that at all

There are 2 things happening (separately)

  1. Windows Powershell is being deprecated (that's 5.1) so no more charges
    https://support.microsoft.com/en-us/servicing/os/windows/docs/2026/11/kb5137172-windows-powershell-5-1-deprecation
  2. Powershell is being added as an inbox app (that is currently 7.x)
    https://devblogs.microsoft.com/powershell/powershell-7-coming-to-windows/

Again 2 separate events, and on top of those changes they are removing the MSI install for Powershell after 7.6.x to MSIX, but do not currently have feature parity for that and break a bunch of things

But your code should be tested and handling that anyway

2

u/sneesnoosnake 1d ago

Powershell 5.1 will still be there in all it's glory. Stop worrying about production and move to PS7 as you have time to review your scripts. Everything will still work.
(Yes it will be a Feature on Demand but it will be active by default)

2

u/bill696 2d ago

What i could understand they will make 5.1 compatible with 7 so like ISE would now work in a way for 7

1

u/Optanik 4h ago

You can't really replace 5.1, since Windows PowerShell is part of the OS and Intune platform scripts and remediations run under it. What usually works is deploying PowerShell 7 side by side (the MSI as a Win32 app, or winget), then calling it where you need it. For Win32 apps, put pwsh.exe -ExecutionPolicy Bypass -File script.ps1 straight in the install command. For platform scripts and remediations, keep a small 5.1 wrapper that checks pwsh.exe exists and runs the real script with it, passing the exit code back so detection and reporting still work. Remember that modules installed for 5.1 aren't always picked up by 7 and the other way round, so check module paths if something works locally but fails from Intune.