windows - Powershell脚本CPU使用率高
问题描述
我有一个简单的脚本,可以在一堆服务器中查找文件。问题是,在每台服务器上,它都与 CPU 挂钩并导致生产工作负载出现问题。我怎样才能让这个脚本不对我的机器进行 DDoS 攻击?!
Start-transcript C:\tools\Querylog.txt
$Servers = Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")} -Properties OperatingSystem
Invoke-command -ComputerName $Server-ScriptBlock {Get-ChildItem -Path $_.Root -Recurse -Force -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -like '*somefile-readme*' } |Out-File -FilePath <filePath>\results.txt -Append}
Stop-Transcript
解决方案
推荐阅读
- javascript - JQuery在一个值中查找并删除点击的id号
- python - 在 Python 中设置嵌套数组值时,数组中的所有值都成为最后一个
- python - Python2.7。访问 HTTPS 网站并检索内容
- haskell - `ReadP` 关于`fmap head` 的奇怪行为
- database - Laravel - 从其他框架迁移数据库
- python-3.x - (Python 3)花了一个小时但找不到错误
- c# - C# 中的 SQL Linq 表达式有问题吗?
- firebase - Firestore 规则未按预期工作,用户仍然可以访问其他用户的数据
- ionic3 - lb-ng (loopback-sdk-angular-cli) 生成的角度 SDK 是否可以在具有 Angular 6.x 的 IONIC 3 项目中使用
- python - 高效的 double for 循环,其中第二个循环的范围取决于第一个循环的值