Hi All,
I am not sure I am using the right terminology but here goes, I have written a function to retrieve a URL report from VirusTotal, the function I have written converts from the returned JSON to a PSCustomObject and I would like to get a certain element of the output, here is the code so far (I have my own API Key stored in $APIKey):
function VT-RetrieveReport($URLToSend='https://test.co.uk'){ $URL = 'http://www.virustotal.com/vtapi/v2/url/report' $PostParams = @{apikey="$APIKey";resource="$URLToSend"} $TheResponse = Invoke-WebRequest -Uri $URL -Method Post -Body $PostParams | ConvertFrom-Json return $TheResponse.Scans }
This function returns a list like this:
ZCloudsec : @{detected=False; result=clean site}
PhishLabs : @{detected=False; result=unrated site}
Zerofox : @{detected=True; result=clean site}
These are note properties of a PSCustomObject, what I would like to do is get the ‘detected=False’ part of each blacklist name but I do not know how to achieve this, so far I can get the Name property which is just:
ZCloudsec
PhishLabs
Zerofox
by doing
VT-RetrieveReport | Get-Member -MemberType NoteProperty | Select -ExpandProperty Name
How do I access the key/value pairs of each of the Names? Ideally I would like to throw away any name that is detected=false and just keep the ones that say detected=true, so the output would look something like:
Zerofox = True
I hope that explains it, thanks again for any further help