$Computers = Get-ADComputer -Filter * -SearchBase "OU=,OU=,DC=,DC=" | Select Name | Sort-Object Name
$Computers = $Computers.Nameпроще написать как$Computers = Get-ADComputer -Filter * -SearchBase "OU=,OU=,DC=,DC=" | Select -ExpandProperty Name | Sort-Object$result =
foreach (...) {
$test = ...
...
[PSCustomObject]@{
Name = $computer
Result = $test -ne $null
IP = $ip
}
}
$result | Export-csv ... foreach ($pair in $pairs) { $filecontent = $filecontent -replace $pair.oldword,$pair.newword }$pairs = Import-Csv csvfile.txt
$filecontent = Get-Content -Path file.txt
$filecontent | Foreach-Object {
foreach ($pair in $pairs) {
$_ -replace $pair.oldword, $pair.newword
}
} |
Set-Content -Path file.txt Get-Process chrome | Stop-Process -Force Start-ThreadJob использует Powershell Runspace, которое, конечно, занимает время и память, хотя и поменьше, чем Start-Job, который фактически ещё один процесс Powershell порождает.Foreach-Object -Parallel - это всё в рамках одного процесса, но многопоточно[System.Collections.ArrayList]$searchBytes += , $searchHexPattern>$a = 1..10000
>[System.Collections.ArrayList]$searchBytes = New-Object System.Collections.ArrayList
>measure-command { foreach ($i in $a) { [System.Collections.ArrayList]$searchBytes += $i } }
Milliseconds : 681
TotalMilliseconds : 1681,7805
> [System.Collections.ArrayList]$searchBytes = New-Object System.Collections.ArrayList
> measure-command { foreach ($i in $a) { [void]$searchBytes.Add($i) } }
Milliseconds : 24
TotalMilliseconds : 24,8517[pscustomobject]@{'search' = 'xxx'; 'replace'='yyy'}
....
command -search $data.search -replace $data.replace
вот это вы как определяли ?