PowerShell 7 compatibility with PowerShell 5

%3CLINGO-SUB%20id%3D%22lingo-sub-2860062%22%20slang%3D%22en-US%22%3EPowerShell%207%20compatibility%20with%20PowerShell%205%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2860062%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20just%20like%20to%20ask%20if%20a%20.ps1%20file%20written%20in%20PowerShell%207%20can%20work%20in%20PowerShell%205%20without%20any%20major%20issues%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2860062%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2861739%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%207%20compatibility%20with%20PowerShell%205%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2861739%22%20slang%3D%22en-US%22%3EThat's%20way%20too%20broader%20question%20to%20be%20able%20to%20give%20you%20a%20specific%20answer.%20Depends%20on%20the%20module(s)%20used%2C%20generally%20speaking.%20Take%20a%20look%20at%20the%20following%20guidance%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fwhats-new%2Fmigrating-from-windows-powershell-51-to-powershell-7%3Fview%3Dpowershell-7.1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fwhats-new%2Fmigrating-from-windows-powershell-51-to-powershell-7%3Fview%3Dpowershell-7.1%3C%2FA%3E%3CBR%20%2F%3EIn%20most%20cases%2C%20you%20can%20get%20away%20with%20the%20majority%20of%20the%20issues%20by%20using%20the%20-UseWindowsPowerShell%20switch.%3C%2FLINGO-BODY%3E
New Contributor

Hi just like to ask if a .ps1 file written in PowerShell 7 can work in PowerShell 5 without any major issues?

2 Replies
That's way too broader question to be able to give you a specific answer. Depends on the module(s) used, generally speaking. Take a look at the following guidance: https://docs.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51...
In most cases, you can get away with the majority of the issues by using the -UseWindowsPowerShell switch.

@Vasil Michev 

 

Thanks for your answer and help on this.

 

Ok, will see and try things out first then