使用PowerShell登陆多台Windows,测试DCAgent方法
目标:
需要1台PC用域账户远程登陆10台PC,每台登陆后的PC执行发送敏感数据的操作后,再logoff。
在DCAgent服务器上,查看这10个用户每次登陆时,DCAgent是否能获取到登陆信息(IP:User)
前提:
- 需要在AD域内添加测试账户,并将这些账户添加到一个group内。
- 需要将每个PC注册到AD域内,并设置group内用户都可以远程登陆。
- 需要设置指定用户登陆后,执行定时任务,定时任务为:发送敏感数据后,执行logoff操作。
- 需要定时读取DCAgent.bak文件的内容并记录。
测试步骤:
- 添加AD域账户,并将这些账户添加到一个group内。
我创建了user21-30这10个用户,并将这些用户添加到dc_group1中。
2. 需要将步骤1中的10个PC注册到AD域内,并设置group内用户都可以远程登陆。
- 1. 对指定的登陆用户设置定时任务:
PC IP地址 |
用户名 |
172.18.0.21 |
user21 |
172.18.0.22 |
user22 |
172.18.0.23 |
user23 |
172.18.0.24 |
user24 |
172.18.0.25 |
user25 |
172.18.0.26 |
user26 |
172.18.0.27 |
user27 |
172.18.0.28 |
user28 |
172.18.0.29 |
user29 |
172.18.0.30 |
user30 |
1) 下载curl.exe程序,用来发送http post请求。
2) 编写test.bat批处理程序,用来执行发送敏感数据和logoff操作
test.bat:
- echo start
- @echo off
- \test_folder\curl.exe -X POST http://172.16.0.10/cgi-bin/save_file_linux.py -F "filename=test.txt" -v
- echo job is done
- shutdown -L
3) 设置定时任务:
开始->所有程序->附件->系统工具->任务计划程序->
4. 在管理PC上执行powershell.ise:
Powershell脚本代码:
- function Connect-RDP {
- param (
- [Parameter(Mandatory=$true)]
- $ComputerName,
- [System.Management.Automation.Credential()]
- $Credential
- )
- # take each computername and process it individually
- $ComputerName | ForEach-Object {
- # if the user has submitted a credential, store it
- # safely using cmdkey.exe for the given connection
- if ($PSBoundParameters.ContainsKey('Credential'))
- {
- # extract username and password from credential
- $User = $Credential.UserName
- $Password = $Credential.GetNetworkCredential().Password
- # save information using cmdkey.exe
- cmdkey.exe /generic:$_ /user:$User /pass $Password
- }
- # initiate the RDP connection
- # connection will automatically use cached credentials
- # if there are no cached credentials, you will have to log on
- # manually, so on first use, make sure you use -Credential to submit
- # logon credential
- mstsc.exe /v $_
- }
- }
- #Connect-RDP 172.18.0.101 -Credential zoo\user12
- $a =
- F:/press_cancel_btn.au3
- DO
- {
- Connect-RDP 172.18.0.21
- Connect-RDP 172.18.0.22
- Connect-RDP 172.18.0.23
- Connect-RDP 172.18.0.24
- Connect-RDP 172.18.0.25
- Connect-RDP 172.18.0.26
- Connect-RDP 172.18.0.27
- Connect-RDP 172.18.0.28
- Connect-RDP 172.18.0.29
- Connect-RDP 172.18.0.30
- timeout /t
- $a++
- } While ($a -le )
- If($a -eq )
- {
- Stop-Process -processname AutoIt3*
- echo finished
- }
press_cancel_btn.au3代码:
需要安装autoit3程序。
- #include <AutoItConstants.au3>
- Dim $count =
- while $count <
- ;click Windows PowerShell Credential Request cancel button
- ControlClick("Windows PowerShell Credential Request", "","Button3")
- Wend
注意:在第一次执行powershell脚本时,需要让PC记录每个远程桌面的Credential,所以在第一次时需要这样执行:
Connect-RDP 172.18.0.21 -Credential zoo\user21
Connect-RDP 172.18.0.21 -Credential zoo\user22
Connect-RDP 172.18.0.21 -Credential zoo\user23
…
…
…
Connect-RDP 172.18.0.21 -Credential zoo\user30
在正常的测试时,只需要按脚本执行即可。
5.在DCAgent服务器上定时查看DCAgent.bak文件并记录:
Record.py
- import time
- while True:
- origin_file=open('DCAgent.bak','rb')
- target_file=open('record.txt','a')
- for line in origin_file:
- content = line.strip()
- target_file.write(content)
- target_file.write('\n')
- origin_file.close()
- target_file.close()
- time.sleep(10)
使用PowerShell登陆多台Windows,测试DCAgent方法的更多相关文章
- windows测试模式
测试模式通常意义就是让windows 操作系统在测试状态下运行,windows操作系统在这种模式下可以运行非官方或无数字签名的驱动程序 . 目录 1 定义 2 进入/退出windows测试模式方法 ...
- 使用PowerShell收集多台服务器的性能计数器
写在前面 当管理多台Windows Server服务器时(无论是DB.AD.WEB以及其他的应用服务器),当出现性能或其他问题后,参阅性能计数器都是一个非常好的维度从而推测出问题可能出现的原因 ...
- Windows 上的 SSH?使用 PowerShell Remoting 远程管理 Windows 服务器
作者:陈计节 个人博客:https://blog.jijiechen.com/post/powershell-remoting/ 在 Linux/Unix 世界里 SSH 是个好东西,SSH 是 Se ...
- 同一台Windows机器中启动多个Memcached服务
同一台Windows机器中启动多个Memcached服务 这就需要在一台机器上启动多个Memcached服务了. 假设Memcached在如下目录:C:\memcached\memcached.exe ...
- ebay如何确定同一电脑登陆了多个账号,以及同一账号登陆过多台电脑
转自hilton 的BLOG http://jimqu.blog.51cto.com/105370/654691 一切要从ebay的买家保护说起 ebay作为一个电子商务平台,之所以可以汇聚如此众多的 ...
- Powershell script to install Windows Updates (msu) from folder
######################################################### # # Name: InstallWindowsUpdates.ps1 # Auth ...
- 一台Windows下配置多个Tomcat服务器
上一篇博客<Windows下配置Tomcat服务器>讲了,如何在一台Windows机器上配置一个Tomcat服务器.这篇介绍一下如何在一台Windows机器上配置多个Tomcat. 第一步 ...
- Perl脚本通过Expect登陆多台设备批量执行命令并Log
本例子尝试使用Perl脚本借助Expect模块实现如下目的: 登陆多台设备 设备登陆信息按如下格式存放于文件中. $ cat hosts.txt 192.168.30.7:node1:telnet:b ...
- Windows如何快速远程到另一台Windows并管理多个远程服务器
Windows如何远程到另一台 Windows管理多个远程服务器 Windows第三方远程管理工具 准备远程机器 开启远程机器的远程桌面功能 首先在此电脑(我的电脑)图标上点击鼠标右键,选择" ...
随机推荐
- activemq启动闪退/失败 (Illegal character in hostname at index 5: ws://****:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600)
java.net.URISyntaxException: Illegal character in hostname at index 5: ws://****:61614?maximumConnec ...
- thinkphp5,单图,多图,上传
/** * 上传单图 */ function upload($path, $filename) { $file = request()->file($filename); $info = $fi ...
- ES6笔记04-class的基本语法
JavaScript 语言中,生成实例对象的传统方法是通过构造函数. ES6 提供了更接近传统语言的写法,引入了 Class(类)这个概念,作为对象的模板.通过class关键字,可以定义类. clas ...
- python__基础 : 类的继承,调用父类的属性和方法
1.继承,调用父类属性方法 在python里面,继承一个类只需要这样写: class Animal: def heshui(self): print('动物正在喝水') class Cat(Anima ...
- elasticsearch 5.x 系列之一 开始安装啦
以下是镇楼用的,各路退让,我要吹liubi 了 // // _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ...
- Bootstrap3适配IE8浏览器的方法
<!--[if lte IE 8]> <script src="js/respond.min.js"></script> <script ...
- Hive 的企业优化
优化 数据优化 一.从大表拆分成小表(更快地检索) 引用:Hive LanguageManual DDL eg2:常用于分表 create table if not exists default.ce ...
- Java线程和多线程(七)——ThreadLocal
Java中的ThreadLocal是用来创建线程本地变量用的.我们都知道,访问某个对象的所有线程都是能够共享对象的状态的,所以这个对象状态就不是线程安全的.开发者可以通过使用同步来保证线程安全,但是如 ...
- P2370 yyy2015c01的U盘
P2370 yyy2015c01的U盘 题目背景 在2020年的某一天,我们的yyy2015c01买了个高端U盘. 题目描述 你找yyy2015c01借到了这个高端的U盘,拷贝一些重要资料,但是你发现 ...
- 开启虚拟机所报的错误:VMware Workstation cannot connect to the virtual machine. Make sure you have rights to run the program, access all directories the program uses, and access all directories for temporary fil
当我们开启虚拟机时出现错误: VMware Workstation cannot connect to the virtual machine. Make sure you have rights t ...