Solution:
Change the target for SharePoint 2010 Management Shell to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "
Right-click on the SharePoint 2010 Management Shell shortcut and click on properties and change the target by adding -Version 2.0 after powershell.exe
OR
open your powershell and type this command:
Powershell –v 2
Change the target for SharePoint 2010 Management Shell to
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 2.0 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "
Right-click on the SharePoint 2010 Management Shell shortcut and click on properties and change the target by adding -Version 2.0 after powershell.exe
OR
open your powershell and type this command:
Powershell –v 2