• WSbeginnerScripting

    WSbeginnerScripting

    @wsbeginnerscripting

    Viewing 3 replies - 1 through 3 (of 3 total)
    Author
    Replies
    • in reply to: Powershell Search string in csv #1556729

      thank you retiredgeek

    • in reply to: Powershell Search string in csv #1556659

      thank thank you retiredgeek,

      Your explanation helped me understand the functioning of powershell, I could get the result through this code:

      $records = Import-Csv C:Srv2Backup.csv -Delimiter “;”
      $Srv=Read-Host “give the name of the server”
      $aa=forEach-Object {$records | Select serveur, domaine | where serveur -eq $Srv }
      $bb=forEach-Object {$aa | Select domaine }

      if ($bb.Domaine -eq “domain1”) {Write-Host “c’est un domaine domain1”}
      elseif ($bb.Domaine -eq “domain2”) {Write-Host “c’est un domaine domain2”}
      else {Write-Host “c’est un Workgroupe”}

      thank you retiredgeek 🙂

    • in reply to: Powershell Search string in csv #1556594

      thank you retiredgeek,

      my file is like:
      server,domain
      sever1,domain1
      server2,doamin2
      server3,domain3

      i want to search variable in the column server if match i want to display the column domaine in the same line

      I wrote this code but it does not give me the desired result

      $records = Import-Csv C:antemetaSrv2Backup.csv -Delimiter “;”
      $Srv=Read-Host “give the name of the server”
      ForEach ($record in $records)
      {
      $name=$record.name

      if ( $srv = $name ) {write-host $record.domain}

      }

      can you help me please

    Viewing 3 replies - 1 through 3 (of 3 total)