import subprocess

def call_command(command):
    process=subprocess.Popen(["powershell",command], stdin=subprocess.PIPE,stdout=subprocess.PIPE, shell=True)
    stdout,stderr = process.communicate()
    ret = process.returncode
    return ret,stdout,stderr

test_ret,test_out,test_err=call_command('Get-AppxPackage -Name MicrosoftTeams -AllUsers')
if test_ret==0:
    if test_out:
        print("microsoft teams personal is found on this machine")
        print(test_out)
        un_ret,un_out,un_err = call_command('Get-AppxPackage -Name MicrosoftTeams -AllUsers | Remove-AppPackage -AllUsers')
        if un_ret==0:
            print("successfully uninstalled the microsoft teams personal")
        else:
            print(un_err)
    else:
        print("microsoft teams personal is not found on this machine")
else:
    print("an error occurred: %s"%(test_err))