Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Clears terminal screen
- Clear-Host
- #Sets all error action
- $ErrorActionPreference= 'silentlycontinue'
- Remove-Item .\collatedData.csv
- $serverList = Get-ADComputer -LDAPFilter "(&(ObjectCategory=Computer)(OperatingSystem=*server*))" | Select-Object Name | Sort-Object Name
- $serverNames = $serverList.Name
- ForEach ($server in $serverNames)
- {
- C:\Progra~2\Nmap\nmap.exe -sS $server --script=ssl-cert -oX .\$server.xml
- [xml]$allXml = Get-Content .\$server.xml
- $allPorts = $allXml.nmaprun.host.ports.port
- Foreach($port in $allPorts)
- {
- $portID = ""
- $commonName = ""
- $endDate = ""
- $portID = $port.portid
- $commonName = $port.script.table.elem[0]
- $endDate = $port.script.table[4].elem[1]
- $portIDString = $portID
- $commonNameString = $commonName
- $endDateString = $endDate
- $collatedData = $server+"`t"+$portIDString+"`t"+$commonNameString.InnerText+"`t"+$endDateString.InnerText | Out-File .\collatedData.csv -Append
- $collatedData
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment