Jun-28-2024, 03:19 PM
ok got it working, now in cmd i see the print error, now got to figure out how to show the error in html, any takers
try: result = subprocess.run(f'powershell.exe $cred = Import-CliXml -Path C:\\python\\cred.xml; Set-ADAccountPassword -Credential $cred -Identity {form.un.data} -OldPassword (ConvertTo-SecureString -AsPlainText {form.op.data} -Force) -NewPassword (ConvertTo-SecureString -AsPlainText {form.cnp.data} -Force) -Server {form.dom.data}', check=True, capture_output=True, text=True, shell=False) print("STDOUT:", result.stdout) print("STDERR:", result.stderr) return '<h1>The username is {}. The old password is {}. the new password is {}. changing for domain {}'.format(form.un.data, form.op.data, form.cnp.data, form.dom.data) except: print("something went wrong") return render_template('password.html', form=form)