Answers for "powerhsell write to output file from multiple jobs"

0

powerhsell write to output file from multiple jobs

$sb =  {
   Param($computer, $fileName, $outLog)
   net use "\\$computer\c$" $password /user:$userName | Out-Null
   if(test-path \\$computer\c$\sc\$fileName){
      [xml]$periods = Get-Content \\$computer\c$\sc\$fileName
      $endDate = $periods.IndataDbf.ingredient.PeriodDetail.PeriodEndDate | select -last 1
         $output = "$computer;$endDate"
      }
   Else {
      $output = "$computer;$fileName Not Found"
   }
   Write-Output -InputObject $output
   net use "\\$computer\c$" /de | Out-Null
}

foreach($computer in $computerName){
   while ((Get-Job -State Running).Count -ge 20) {
      Start-Sleep -Seconds 5;
   }
   Start-Job -Scriptblock $sb -ArgumentList $computer,$fileName,$outLog
}
Get-Job | Wait-Job | Receive-Job | Out-File -Append -FilePath $outLog
Posted by: Guest on October-28-2021

Code answers related to "powerhsell write to output file from multiple jobs"

Browse Popular Code Answers by Language