I am very new at PowerShell, and an intern, so I'm not the best at PowerShell right now.
I am importing a .CSV with a list of servers with vulnerabilities. I am getting only the name of the servers, not any other information. I want to count how many times each server shows up in this list. The reason why the same server will show up multiple times in this list is because it has multiple vulnerabilities.
So, how can I script this in PowerShell?
So far I 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 the substrings because part of the name in the CSV file is the domain name, and I just need the server name (last 8 characters). So I need this script to be applied too.
I feel like the Group-Object and Get-Unique cmdlets will be used, and possibly a hashtable. I've been searching and searching and cannot quite get the information I need. Once again, I have only been using PowerShell for 2 weeks now.
Thank you!