首页 > 解决方案 > 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

标签: windowsperformancepowershellserver

解决方案



推荐阅读