powershell - 通过 Powershell 删除所有用户的可执行位
问题描述
我有一个小问题想听听你的意见:
在我们两次在托管中心感染了恶意软件之后 - 我们决定在内部托管我们的服务器。但是为了避免再次感染蜜蜂 - 我们希望对本地 PC 的权限进行一些更改:在收集了大量信息后 - 我发现恶意软件很可能会自行安装在以下文件夹中:C:\Windows\Temp %USERPROFILE%\ Appdata\Local(Win 7/8/10/Vista)%USERPROFILE%\Local 设置
因此,我想从文件夹和子文件夹中删除可执行位 - 但这样做是明智的 - 因为很可能所有程序都是从 %USERDATA%\AppData\Local 执行的 - 那么没有程序将运行。我确实尝试过这个 - 但除非我改回来,否则无法开始任何事情
在谷歌上搜索了很多之后——我发现这个脚本做得最多——但仍然存在所有文件都无法执行的问题???
# Get the ACL for an existing folder For $Users
$existingAcl = Get-Acl -Path 'C:\Windows\Temp'
# Set the permissions that you want to apply to the folder
$permissions = $env:username, 'ExecuteFile', 'ContainerInherit,ObjectInherit', 'None', 'Deny'
# Create a new FileSystemAccessRule object
$rule = New-Object -TypeName System.Security.AccessControl.FileSystemAccessRule -ArgumentList $permissions
# Modify the existing ACL to include the new rule
$existingAcl.SetAccessRule($rule)
# Apply the modified access rule to the folder
$existingAcl | Set-Acl -Path 'C:\Windows\Temp'
有人可以指出我正确的方式或告诉我这是否不好并且会破坏比它解决的更多
提前谢谢P
解决方案
推荐阅读
- python - App Engine 本地环境显示不正确的数据
- mysql - 如何批量更新未更新产品的库存
- sql - 如何减去同一表同一列中配置单元中的计数值
- javascript - 如何有效且高效地将项目分组到成对的存储桶中(如果存在)
- mongodb - 日期范围在聚合管道中不起作用,但在 find() 中起作用
- python - SqlAlchemy“contains_eager”似乎没有加载嵌套关系
- google-cloud-platform - Sqoop 作业通过 Dataproc 失败
- node.js - 无法在 express api 和反应应用程序中使用 http-proxy-middleware 进行代理
- powershell - 有没有办法获得大于 int32 的数字范围?
- java - 警报对话框的 XML?