使用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第三方远程管理工具 准备远程机器 开启远程机器的远程桌面功能 首先在此电脑(我的电脑)图标上点击鼠标右键,选择" ...
随机推荐
- JSP页面字符集设置
错误提示: HTTP Status 500 - /test1.jsp (line: 2, column: 1) Page directive must not have multiple occurr ...
- JS - 兼容的事件助手
(function () { // 兼容的事件助手 window.CompatibleEventHelper = { addEventListener: function (elem, type, c ...
- 路由器基础配置之单臂路由实现vlan间通信
我们将以上面的拓扑图开始进行配置,目的为设置单臂路由实现vlan间通信,设置4个vlan,pc0,1,2为vlan10 pc3,4,5为vlan20:pc6,7,8为vlan30:server0,1为 ...
- webmin纯web界面管理linux系统
关键字: 摘要:从Windows环境的管理转到Linux环境的管理时所面临的挑战之一是,您需要去学习利用新的工具.作为一个管理员,您希望理解操作系统的细节以发挥它的最大功效.但是,当您还处在学习阶段时 ...
- 谈一谈你对js线程的理解
js线程:javascript是单线程的,所有任务都需要排队,这些任务分为同步任务和异步任务,单线程上有一个主线程任务.同步任务必须再主线程上排队进行,而异步任务(类似于点击事件)必须在主线程上的任务 ...
- 基本数据类型补充,set集合,深浅拷贝等
1.join:将字符串,列表,用指定的字符连接,也可以用空去连接,这样就可以把列表变成str ll = ["wang","jian","wei&quo ...
- Linux与BSD不同
https://linux.cn/article-3186-1.html https://www.howtogeek.com/190773/htg-explains-whats-the-differe ...
- 20145202 《信息安全系统设计基础》git安装
git的安装 直接输入指令将其安装就可以了. 安装的时候要设置公钥,我不知道以前在windows上设置过的公钥是否还能用所以我就还是从新搞了一个. 验证可以连通 遇到的问题
- 1,VMware与Centos系统安装
选择性 pc可以选择 -纯系统 Linux/windows -双系统 Windows+Linux -虚拟化技术 Windows+vmware workstation 服务器 -物理机纯系统 -物理机+ ...
- 2753: [SCOI2012]滑雪与时间胶囊
2753: [SCOI2012]滑雪与时间胶囊 Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 2633 Solved: 910 Descriptio ...