Counting Number of Times a Server Name Occurs in a CSV File
i new @ powershell, , intern, i'm not best @ powershell right now.
i importing .csv list of servers vulnerabilities. getting name of servers, not other information. want count how many times each server shows in list. reason why same server show multiple times in list because has multiple vulnerabilities.
so, how can script in powershell?
so far have:
$vulnservers= import-csv c:\users\logsdmp\desktop\vuln_top_10\windows_critical_list.csv
$servers = foreach($server in $vulnservers){
$server = $server.netbios_name.tostring()
$server = $server.substring($server.length - 8, 8)
write-host $server
}
i have taken substrings because part of name in csv file domain name, , need server name (last 8 characters). need script applied too.
i feel group-object , get-unique cmdlets used, , possibly hashtable. i've been searching , searching , cannot quite information need. once again, have been using powershell 2 weeks now.
thank you!
import-csv c:\users\logsdmp\desktop\vuln_top_10\windows_critical_list.csv | foreach-objec{ $_.netbios_name.substring($_.netbios_name.length - 8, 8) } | group | select name, count
\_(ツ)_/
Windows Server > Windows PowerShell
Comments
Post a Comment