powershell version upgrade on windows server 2008 R2

Hi,
I’m trying to upgrade powershell version on windows server 2008R2 through powershell commands.
if I run those commands on powershell directly it is working fine but if use same commands in ansible playbook it is throwing Fatal Error.

Please help me out .

Thanks in advance,
Sukanya

My guess is that is because you are also replacing Windows Management Framework, which includes WinRM, which is the mechanism used to communicate with the windows machine. If the WinRM service gets restarted during the upgrade I can imagine this will fail.

You might be able to get around this by setting up a scheduled task to run the installation - but this is not something I have tried myself.

Jon

Thank you for your suggestion but it is not even installing dotNet framework 4.5v.

this is my playbook.

Sukanya

Here is my playbook to install dotNet framework 4.5

sukanya

Powershell itself is completely dependent on .net so I guess this is not surprising either.

I’d suggest trying win_scheduled_task module.

If you are going to the trouble then it might be worth going straight to .net 4.7 - if so be aware of this (although you are on S2008SP2 so probably not affected): https://support.microsoft.com/en-us/help/4020302/the-net-framework-4-7-installation-is-blocked-on-windows-7-windows-ser

Jon

The example you gave to install .net 4.5 is an MSU file that is installed with Windows update. There is no easy way to install update files but I’ve been able to install .net 4.5 using the offline installer that is packages as an exe. The link for it is here https://www.microsoft.com/en-au/download/details.aspx?id=42642.

As jhawkesworth was saying there isn’t an easy way to upgrade powershell as it is like pulling the rug out when you are standing on it. You might have luck with scheduled tasks or running with async and no polling but I’ve yet to find an easy way to do this.