python salt 实现windows账户自动化
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账户自动化的更多相关文章
- Python结合Pywinauto 进行 Windows UI 自动化
转:Python结合Pywinauto 进行 Windows UI 自动化 https://blog.csdn.net/z_johnny/article/details/52778064 说明:Pyw ...
- python自动化测试(2)-自动化基本技术原理
python自动化测试(2) 自动化基本技术原理 1 概述 在之前的文章里面提到过:做自动化的首要本领就是要会 透过现象看本质 ,落实到实际的IT工作中就是 透过界面看数据. 掌握上面的这样的本领 ...
- Windows创建自动化任务
Windows创建自动化任务使得开机就打开相应的Python目录 1:计算机管理 2:找到任务计划程序 3:创建基本任务 4:任务触发器 5: 建立bat执行文件 start "" ...
- python自动化测试(3)- 自动化框架及工具
python自动化测试(3) 自动化框架及工具 1 概述 手续的关于测试的方法论,都是建立在之前的文章里面提到的观点: 功能测试不建议做自动化 接口测试性价比最高 接口测试可以做自动化 后面所谈到 ...
- Python环境搭建(windows)
Python环境搭建(windows) Python简介 Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/),是一种面向对象.直译式计算机编程语言,具有近二十年的发展历史,成 ...
- 转载:python + requests实现的接口自动化框架详细教程
转自https://my.oschina.net/u/3041656/blog/820023 摘要: python + requests实现的接口自动化框架详细教程 前段时间由于公司测试方向的转型,由 ...
- 基于Python实现的死链接自动化检测工具
基于Python实现的死链接自动化检测工具 by:授客 QQ:1033553122 测试环境: win7 python 3.3.2 chardet 2.3.0 脚本作用: 检测系统中访问异常(请求 ...
- 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 ...
- python MySQLdb在windows环境下的快速安装
python MySQLdb在windows环境下的快速安装.问题解决方式 使用python访问mysql,需要一系列安装 linux下MySQLdb安装见 Python MySQLdb在Linux下 ...
随机推荐
- vc通过webbrowser操作ie元素
1>需要引用 webbrowser2.h,mshtml.h //m_web绑定的webbrowser的变量 CComQIPtr<IHTMLDocument2,&IID_IHTMLD ...
- python激活码
- 轻松学SQL Server数据库
轻松学SQL Server数据库pdf 下载地址:网盘下载 目录: 第1章 数据库与SQL Server 2008 11.1 数据库基础 21.1.1 数据库的概念 21.1.2 数据库模型 2 ...
- MapReduceV1作业生命周期图解以及与YARN基本对比
仿照<hadoop技术内幕:深入解析MapReduce架构设计与实现原理>中的原图,我用手绘制了一份类似的图-_- 4大部分:HDFS,Client,JobTracker,TaskTrac ...
- Luogu 2912 [USACO08OCT]牧场散步Pasture Walking
快乐树剖 #include<cstdio> #include<cstring> #include<algorithm> #define rd read() #def ...
- 修改socket缓冲区大小
#include <stdio.h>#include <sys/time.h>#include <sys/types.h>#include <sys/sock ...
- laravel表单图片上传
1.视图 2.控制器
- inline 引起undefined reference to
main.cc:57: undefined reference to `evpp::udp::UdpDecoder::GetHeader()'collect2: error: ld returned ...
- Vue.js (Frontend & Backend)尝试前后端分离
前言 前端用什么框架都可以,这里选择小巧的vuejs. 要实现的功能很简单:1.登录功能,成功将服务器返回的token存在本地2.使用带token的header访问服务器的一个资源 本次实验环境: & ...
- [转]docker 基本原理及快速入门
版权声明:原创作品, 来自海牛部落-青牛,http://hainiubl.com/topics/13 什么是docker Docker 是一个开源项目,诞生于 2013 年初,最初是 dotCloud ...