Hello everyone. Please pardon me if I don't make too much sense with what I'm trying to accomplish. We have a database that extracts data into a CSV file nightly. This database contains a lot of information concerning our physical servers. Whenever we decommission servers we have to fill spreadsheets with information gathered from this CSV file. However, I'm trying to only filter out certain columns and servers (the ones being decommissioned) from the CSV file.
Here is what I have so far:
$test = Import-CSV ".\aperture_servers.csv" |Select @{Name="Server Name";Expression={$_."device_name"}},
@{Name="IP Address";Expression={$_."nic_1_text"}},
@{Name="ILO IP";Expression={$_."console_ilo_text"}},
@{Name="Building";Expression={$_."building"}},
@{Name="Floor";Expression={$_."floor"}},
@{Name="Grid";Expression={$_."placement_grid"}},
@{Name="Serial #";Expression={$_."serial_number"}}
$test | export-csv new-test.csv –notype
This works fine, however, it extracts EVERY (thousands) of servers into the new-test.csv file. I want to create a servers.txt file that has a list of servers and this way the export-csv command only exports servers that match the servers.txt file. Any help would be appreciated. (Sorry I'm very newb at this stuff).