Create script that would search for list of printer serial number ?

Hi

I am looking for Power script  that can search for printers by serial number and will  generate CSV output file with

ip address:
hostname:
mac address:
fax#

Thx. Mike
Devinv.csv
michalek19Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
Hi Mike, are you asking just to filter that input file based on a serial number entered by the user?

Rob.
0
michalek19Author Commented:
What i am looking for is to run script against printer archived  inventory csv file and filter "search"  only serial numbers that i need to find it. The output should create serial number, IP address, hostname, MAC address, FAX#.
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Guess the best way is to extract the "real CSV data" part, import it, and then do some selection and processing:
$sn = 'CN37PEK09Z', 'CNB9B8FBB2'
select-string -Pattern '^,[\s\d]' -Path C:\Temp\EE\Devinv.csv | convertFrom-CSV |
  ? { $sn -contains $_.{Serial Number} } |
  select 'Serial Number', 'IP Address', 'IP Hostname', 'Fax' |
  export-CsV -NoType C:\Temp\EE\DevSel.csv

Open in new window

Note there is no MAC address in the inventory CSV.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

michalek19Author Commented:
I will check this method
0
michalek19Author Commented:
This looks good but how i can also search for MAC address and Serial number and IP address.
I want to have option to choose during the search.
Also, i want to provide input file ".csv" file  that would contain Serial numbers or MAC address or IP address
Devinv.csv
0
RobSampsonCommented:
Hi, try this.

# Input File
$InputFile = 'C:\Temp\Scripts\Devinv.csv'
# Output File
$OutputFile = 'C:\Temp\Scripts\DevSel.csv'
# Possible Search Fields
$searchFields = "Serial Number", "IP Address", "Hardware Address (MAC)"
# Select the index of the search field here
$searchField = $searchFields[0] # Serial Number
#$searchField = $searchFields[1] # IP Address
#$searchField = $searchFields[2] # MAC Address
# Enter the items you want to find here
$searchItems = 'CN37PEK09Z', 'CNB9B8FBB2' # Serial Number
#$searchItems = '10.76.58.9', '10.76.58.6' # IP Address
#$searchItems = '001438A4D24A', '0014383D536E' # MAC Address
# This will perform the search
Select-String -Pattern '^,[\s\d]' -Path $InputFile | ConvertFrom-CSV | 
  Where-Object { $searchItems -contains $_."$searchField" } |
  Select 'Serial Number', 'IP Address', 'IP Hostname', 'Fax' #|
  Export-CSV -NoType $OutputFile
#Invoke-Item $OutputFile

Open in new window


Note that you need to select the appropriate $searchField to search for from this list:
$searchField = $searchFields[0] # Serial Number
$searchField = $searchFields[1] # IP Address
$searchField = $searchFields[2] # MAC Address


And also the items you want to search for from this list:
$searchItems = 'CN37PEK09Z', 'CNB9B8FBB2' # Serial Number
$searchItems = '10.76.58.9', '10.76.58.6' # IP Address
$searchItems = '001438A4D24A', '0014383D536E' # MAC Address

Regards,

Rob.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
michalek19Author Commented:
i will check this
0
Martin LissOlder than dirtCommented:
I've requested that this question be closed as follows:

Accepted answer: 250 points for Qlemo's comment #a40693617
Assisted answer: 250 points for RobSampson's comment #a40728838

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.