我想用PowerShell从Python脚本更改当前密码。为此,我需要从下面的代码运行PowerShell命令。最好的办法是什么?在
import datetime
#generated password is always changing. There might be different quotations and slashes so it's tricky to put it into PowerShell command bellow
generated_password=r'/#\n\9{S;-l2H~'
#password to set is changing depending on date. Let's say today it has become 'xxx180220'
password_to_set="xxx"+datetime.datetime.now().strftime("%y%m%d")
#I'd like to run this PS command to change my generated password to value stored in password_to_set variable. How do I do it?
PowerShell.exe -ExecutionPolicy ByPass ([adsi]'WinNT://valueaddco/wadmin,user').ChangePassword('/#\n\9{S;-l2H~','xxx180220')
我创建了新的1.ps文件:
它可以用Python代码启动:
^{pr2}$相关问题 更多 >
编程相关推荐