吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1075|回复: 2
收起左侧

[其他原创] 使用PowerShell查询所有用户是否存在某个目录(或者自行决定对该目录的操作)

[复制链接]
BLUE7777777 发表于 2023-6-20 17:46
一般这个代码段适合服务器管理用,个人也可以用来快速查看自己的用户文件夹。

比如一个服务器系统,有多个用户登陆,
我需要查看每个用户下面的XXX的程序的是否存在配置文件
(如果你要修改/提取,就在函数内的代码段后面对$User_ProfileImagePath$YourItem_trc_directory进行操作),
一个个按照用户名路径去翻阅太麻烦了,
就可以使用此代码段进行快速操作。
(不存在不会显示)

代码中
$YourItem_trc_directory="\AppData\LocalLow\YourItem"
双引号就是你要查询的每个用户的对应路径。


[PowerShell] 纯文本查看 复制代码
$YourItem_trc_directory="\AppData\LocalLow\YourItem"
$All_Users=Get-WmiObject -Class Win32_UserAccount
$Users_array=$All_Users.Caption

Function Display_YourItem_cfg_Directory($item)
{for($i=0;$i -le ($item.length -1);$i++)
{$String=$item[$i]
$USER_ob = New-Object System.Security.Principal.NTAccount($String)
$USER_SID = $USER_ob.Translate([System.Security.Principal.SecurityIdentifier]) 
$USER_SID = $USER_SID.Value
$Reg_Key = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\'+$USER_SID
$Reg_Name = 'ProfileImagePath'
$User_ProfileImagePath = (Get-ItemProperty -Path "Registry::$Reg_Key").$Reg_Name
ii $User_ProfileImagePath$YourItem_trc_directory}}
Display_YourItem_cfg_Directory($Users_array)

免费评分

参与人数 2吾爱币 +4 热心值 +2 收起 理由
苏紫方璇 + 3 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
十点睡先生 + 1 + 1 鼓励转贴优秀软件安全工具和文档!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

十点睡先生 发表于 2023-6-21 08:50
适合Windows共享文件夹查询嘛
 楼主| BLUE7777777 发表于 2023-6-21 09:08
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-1 18:09

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表