Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.37.1.windows.1/Git-2.37.1-64-bit.exe -UseBasicParsing -OutFile git-setup.exe
Start-Process .\git-setup.exe -Wait -ArgumentList '/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS="icons,ext\reg\shellhere,assoc,assoc_sh" /LOG="C:\git-for-windows.log"'
I tried this script by RDP into EC2 instance and ran the script inside using the local PowerShell console then it worked.
But tried on the AWS Session Manager Console then it hung nothing happened for a long time.