import random
import string
import json
import logging
import time
import os
import sys
def usage():
print('python ' + sys.argv[0] + 'user' + 'ip')
print ('eg: python '+ sys.argv[0] + 'tengfei1 172.18.200.14') user = sys.argv[1]
ip = sys.argv[2]
host = "host %s" %ip
uid_l = os.popen(host).read()
host = ip_l.split()[-1].strip('.')
str_source = string.ascii_letters + string.digits + string.punctuation
str_list = random.sample(str_source,10)
special=['/','\\','@','I','l','o','O','\'',':','`']
if len(set(str_list) & set(special))==0:
str_final = ''.join(str_list)
cmd1 = 'salt %s user.add %s groups \"Remote Desktop Users\"' %(host,user)
cmd2 = 'salt %s user.update %s password=%s password_never_expires=ture' %(host,user,str_final)
cmd3 = ' salt %s file.copy c:/users/test/desktop/ C:/Users/%s/Desktop/' %(host,user)
os.system(cmd1)
os.system(cmd2)
os.system(cmd3) #半成品脚本,统一桌面功能未测试完成。
#持续功能,ftp的目录权限需要进行管理,该脚本未实现。

  

python salt 实现windows账户自动化的更多相关文章

  1. Python结合Pywinauto 进行 Windows UI 自动化

    转:Python结合Pywinauto 进行 Windows UI 自动化 https://blog.csdn.net/z_johnny/article/details/52778064 说明:Pyw ...

  2. python自动化测试(2)-自动化基本技术原理

    python自动化测试(2) 自动化基本技术原理 1   概述 在之前的文章里面提到过:做自动化的首要本领就是要会 透过现象看本质 ,落实到实际的IT工作中就是 透过界面看数据. 掌握上面的这样的本领 ...

  3. Windows创建自动化任务

    Windows创建自动化任务使得开机就打开相应的Python目录 1:计算机管理 2:找到任务计划程序 3:创建基本任务 4:任务触发器 5: 建立bat执行文件 start "" ...

  4. python自动化测试(3)- 自动化框架及工具

    python自动化测试(3) 自动化框架及工具 1   概述 手续的关于测试的方法论,都是建立在之前的文章里面提到的观点: 功能测试不建议做自动化 接口测试性价比最高 接口测试可以做自动化 后面所谈到 ...

  5. Python环境搭建(windows)

    Python环境搭建(windows) Python简介 Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/),是一种面向对象.直译式计算机编程语言,具有近二十年的发展历史,成 ...

  6. 转载:python + requests实现的接口自动化框架详细教程

    转自https://my.oschina.net/u/3041656/blog/820023 摘要: python + requests实现的接口自动化框架详细教程 前段时间由于公司测试方向的转型,由 ...

  7. 基于Python实现的死链接自动化检测工具

    基于Python实现的死链接自动化检测工具   by:授客 QQ:1033553122 测试环境: win7 python 3.3.2 chardet 2.3.0 脚本作用: 检测系统中访问异常(请求 ...

  8. Fix Python 3 on Windows error Microsoft Visual C++ 14.0 is required

    Fix Python 3 on Windows error Microsoft Visual C++ 14.0 is required Fix the error for Python 3.6 and ...

  9. python MySQLdb在windows环境下的快速安装

    python MySQLdb在windows环境下的快速安装.问题解决方式 使用python访问mysql,需要一系列安装 linux下MySQLdb安装见 Python MySQLdb在Linux下 ...

随机推荐

  1. silverlight的Datagrid控件列绑定属性笔记

    <data:DataGridTemplateColumn Header="给作者留言"> <data:DataGridTemplateColumn.CellTem ...

  2. Java一个文件上传工具类

    /** * 文件上传 * * @author cary * @since 2012-12-19 下午2:22:12 */ public class FileUploader { static fina ...

  3. Codeforces 607A 动态规划

    A. Chain Reaction time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. _GET_

    _GET_:读取属性,没有自动创建

  5. makefile all

    all:udps udpc udps:udpserv.c    gcc -Wall -o udps udpserv.cudpc:udpclient.c    gcc -Wall -o udpc udp ...

  6. c++11多线程学习笔记之一 thread基础使用

    没啥好讲的  c++11  thread类的基本使用 #include "stdafx.h" #include <iostream> #include <thre ...

  7. CentOs7中的网卡配置工具

    CentOs7中的网卡配置工具 摘自:https://blog.51cto.com/13572810/2087991 misslaziness1人评论2715人阅读2018-03-17 22:09:1 ...

  8. sqlldr 笔记

    表结构 CREATE table sqlloader_test ( f1 char(20), f2 char(20), f3 number(16), f4 date ); 数据文件data.csv 1 ...

  9. 负值之美:负margin在页面布局中的应用

    本文转载自:http://www.topcss.org/?p=94,有修改. 负数给人总是一种消极.否定.拒绝之感,不过有时利用负margin可以达到奇妙的效果,今天就表一表负值在页面布局中的应用.这 ...

  10. 2018.10.05 NOIP模拟 阶乘(简单数论)

    传送门 签到题. 直接把所有数先质因数分解. 同时统计每一个在阶乘中会出现的质数出现的最少次数. 然后对于每一个这样的质数,我们求出满足其出现质数的m的最小值,然后求出所有m的最大值. 求m的时候可以 ...