Ihre Frage ist ziemlich schwer zu verstehen, ohne zu sehen, alle Beispiele, aber ich denke, Sie etwas tun könnte wie folgt aus:
#Imports CSV file as variable
$Csvfile = Import-Csv -Path "C:\SomePath\file.csv" -Delimiter ","
#Change 1513 to the actual managers PositionID
$Csvfile | Where {$_.PositionID-eq "1513"} | Select -ExpandProperty LoginID
Um zu testen, ich eine schnelle csv mit einigen Zufallszahlen erstellt:
loginID PositionID ReportstoPositionid
1111 3654 1513
2222 1513 54123
3333 54123 16543564
4444 156413 156413
5555 16543564 3654
Dann entschied ich, dass 1513 der Manager Position Code wäre und dann die PowerShell-Befehle oben ausgeführt, um die Loginid zu erhalten.
PS C:\> $Csvfile | Where {$_.PositionID -eq "1513"} | Select -ExpandProperty LoginID
2222
Wenn Sie das alles ohne eine Variable wollten Sie folgendes tun können:
PS C:\> Import-Csv -Path "C:\SomePath\file.csv" -Delimiter "," | Where {$_.PositionID -eq "1513"} | Select -ExpandProperty LoginID
2222
Schließlich könnten Sie die Select-Anweisung entfernen, wenn Sie die volle Linie in der CSV-Datei sehen wollte. Beispiel:
loginID PositionID ReportsPositionid
------- ---------- -----------------
2222 1513 54123
Wieder war Ihre Fragen ein wenig schwer zu verstehen, sondern auf das, was ich hier lesen ist, was ich kam mit.
Hoffe, das hilft!
EDIT
Nachdem mit den Beispieldaten testen, ich glaube, Sie folgende verwenden:
$CSV1 = Import-Csv -Path "C:\Users\Tyler\Desktop\test1.csv" -Delimiter ","
$Manager = $CSV1 | Where {$_.'Position ID' -eq 'YQM000076'} | Select -ExpandProperty "Legal First Name"
Write-Output "The Following Employees Report To $Manager :"
foreach ($Row in $CSV1)
{
if ($Row.'Reports to Position ID' -eq 'YQM000076')
{
Write-Output "$Row"
}
}
OUTPUT Sie
The Following Employees Report To Bob :
@{Person ID=; Position ID=YQM000051; Legal First Name=DIANE; Reports To Position ID=YQM000076}
@{Person ID=S9999991; Position ID=YQM000052; Legal First Name=CHARISSE; Reports To Position ID=YQM000076}
@{Person ID=S9999992; Position ID=YQM000052; Legal First Name=CHARISSE; Reports To Position ID=YQM000076}
@{Person ID=S9999993; Position ID=YQM000052; Legal First Name=CHARISSE; Reports To Position ID=YQM000076}
Dies ist das dritte Mal in ein paar Stunden fragte im Grunde die gleiche Frage. Bitte tu das nicht. –