Turn Powershell Script Into Function In Mathematics