Jun-28-2024, 03:00 PM
(This post was last modified: Jun-28-2024, 03:00 PM by robertkwild.)
ok im doing this
also if the sub process command fails i dont want it to display that return line ie to show what you typed in username old password, new password, domain
@app.route('/password', methods=['GET', 'POST']) def password(): form = PasswordForm() if request.method == 'POST' and form.validate(): 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}', capture_output=True, text=True, shell=False) print("STDOUT:", result.stdout) print("STDERR:", result.stderr) except: print("something went wrong") 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) return render_template('password.html', form=form) if __name__ == '__main__': app.run(debug=True)but when the subprocess command fails its not showing the print message in except
also if the sub process command fails i dont want it to display that return line ie to show what you typed in username old password, new password, domain