使用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第三方远程管理工具 准备远程机器 开启远程机器的远程桌面功能 首先在此电脑(我的电脑)图标上点击鼠标右键,选择" ...
随机推荐
- Java打印金字塔问题
Java打印金字塔问题 public class 金字塔问题 { // //普通金字塔 // public static void main(String[] args) { // //先打印4层 / ...
- JQuery实现父级选择器(广告实现)
效果图如下: HTML代码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- datatable 单元格默认文本
在列字段中添加属性:"defaultContent": "-"
- tp5 使用技巧(持续更新中...)
tp5 使用技巧(持续更新中...) 1.自动写入时间 create_time和update_time 使用save方法才行,insert方法不生效,不知为何 2.过滤字段 allowfield和st ...
- Linux编译移植Qt4的环境_在OMAPL138平台
Linux编译Qt4的环境_OMAPL138 手里有一块创龙OMAPL138的板子,我要在上面成功移植Qt环境和触摸屏幕,这是我第二次进行Linux的Qt环境移植,发现了很多问题,需要重新整理. 我编 ...
- python分布式爬虫--房天下
第一步安装redis redis在windows系统中的安装与启动: 下载:redis官方是不支持windows操作系统的.但是微软的开源部门将redis移植到了windows上.因此下载地址不是在r ...
- realloc函数的用法
realloc(void *__ptr, size_t __size):更改已经配置的内存空间,即更改由malloc()函数分配的内存空间的大小. 如果将分配的内存减少,realloc仅仅是改变索引的 ...
- Docker使用入门
docker images 查看本地镜像 docker ps -a 查询容器 docker ps -l 查询最近使用容器 docker rm CONTAINER_ID 删除容器 docker rm ...
- python-4函数式编程
1-高阶函数 变量可以指向函数. def add(x, y, f): 例如f参数为函数 编写高阶函数,就是让函数的参数能够接收别的函数. Python内建了map()和reduce()高阶函数. ...
- Android 中运行时权限获取联系人信息 Demo
代码比较简单... AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <m ...