$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
$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
А запускаете вы под собой