I'm trying to verify the correct firewall rules have been implemented and flows are functional. I've searched and can't seem to find my solution. I'm using PowerShell to automate PortQry requests (based on it's role) for list of servers which seems simple. But I cannot seem to pass the arguments correctly to PortQry and end up with the PortQry help screen.
Here is my function:
Function CheckPorts($x,$y,$z) {
PortQry -n $x -p $y -o $z | Out-File $ResultsFile -Append
}
And here is my ForEach loop that I'm using to iterate through an array created by and imported CSV:
$Type = TCP
Foreach ($Server in $ServerRoleArray.Role1) {
if ($Server -ne "") {
CheckPorts $Server $Type $Role1Ports
}
Added information:
It appears as though I'm not extracting $Server
variable correctly from the array. Here is my import:
$ServerRoleArray = Import-CSV $FilePath\Servers.csv
My Servers.csv looks like:
Role1,Role2
google.com,msn.com
yahoo.com,
Thoughts?? BTW I've tried this in powershell v2 & v3