Open kumar4755 opened 4 years ago
$reference = Import-Csv -Path D:\Dev\test1.csv $lookup = $reference | Group-Object -AsHashTable -AsString -Property Server $resultsNote = "NotMatching" $resultsNote1 = "Matching"
$results = Import-Csv -Path D:\Dev\test2.csv | foreach { $server = $.Server Write-Verbose "Looking for $server" if ($lookup.ContainsKey($server)) { $oldState = ($lookup[$server]).State } else { $oldState = "NotMatching" } if ($.State -ne $oldState) { [PSCustomObject]@{ Server = $server ResultNote = $resultsNote } } else { [PSCustomObject]@{ Server = $server ResultNote = $resultsNote1
}
}
}
$results | Export-Csv -Path D:\Dev\result.csv -NoType -Encoding ASCII
`$reference = Import-Csv -Path D:\Dev\test1.csv $lookup = $reference | Group-Object -AsHashTable -AsString -Property Server $resultsNote = "NotMatching" $resultsNote1 = "Matching"
$results = Import-Csv -Path D:\Dev\test2.csv | foreach { $server = $.Server Write-Verbose "Looking for $server" if ($lookup.ContainsKey($server)) { $oldState = ($lookup[$server]).State } else { $oldState = "NotMatching" } if ($.State -ne $oldState) { [PSCustomObject]@{ Server = $server ResultNote = $resultsNote } } else { [PSCustomObject]@{ Server = $server ResultNote = $resultsNote1
}
}
}
$results | Export-Csv -Path D:\Dev\result.csv -NoType -Encoding ASCII `
Please check ``
$username="admin" $password="12345" $url = "http://testing-ground.scraping.pro/login" $ie = New-Object -com internetexplorer.application $ie.visible = $true $ie.silent = $true $ie.navigate($url)
while($ie.Busy) { Start-Sleep -Milliseconds 10 }
($ie.document.IHTMLDocument3_getElementByName("usr") |select -first 1).value = $username ($ie.document.IHTMLDocument3_getElementByName("pwd") |select -first 1).value = $password ($ie.document.IHTMLDocument3_getElementByName("Login") |select -first 1).click()
$HostID = import-csv D:\XYZABC\HostTest.csv
$HostString = foreach ($Item in $HostID) { "'" + $Item.host + "
'," }
write-host $HostString
$HostID = import-csv D:\XYZABC\HostTest.csv
$HostString = foreach ($Item in $HostID) { "'" + $Item.hostID + "'," }
write-host "$HostString"
$webServicesLogon = "/devices/entities/host-group-actions/v1?action_name=add-hosts"
$Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
# Authentication
$bodyParams = @{action_parameters = @(
@{ name = 'filter'
value = '(device_id:[' + ($HostString).TrimEnd(',') + '])'} | ConvertTo-JSON )
# Execution
try {
$logonResult = Invoke-RestMethod -Uri $webServicesLogon -Method POST -Headers $Header -ContentType "application/json" -Body $bodyParams
return $logonResult
}
catch {
Write-Host "StatusCode: " $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription: " $_.Exception.Response.StatusDescription
Write-Host "Response: " $_.Exception.Message
Return $false
}
}
Download Report from Fireeye Dashboard
Compare Hostnames in Fireeyedoc and Local existing Doc