Updated $Report parameter

Changed [switch] to [string] input
client_ports
n03lx 2015-07-23 08:57:09 -04:00
parent 7406673dca
commit 692915a294
1 changed files with 17 additions and 10 deletions

View File

@ -73,7 +73,7 @@ function Invoke-EgressAssess
[Parameter(Mandatory = $False)] [Parameter(Mandatory = $False)]
[int]$Loops = 1, [int]$Loops = 1,
[Parameter(Mandatory = $False)] [Parameter(Mandatory = $False)]
[switch]$Report [string]$Report
) )
begin begin
@ -1014,9 +1014,8 @@ function Invoke-EgressAssess
function Write-Report function Write-Report
{ {
Write-Verbose "[*] Building Report" Write-Verbose "[*] Building Report"
Write-Output "----------Egress-Assess Report----------" Write-Verbose "----------Egress-Assess Report----------"
$ReportFile = "C:\Egress-Assess\report.txt" Write-Verbose "Report File = $Report"
Write-Output "Report File = $ReportFile"
$EAreport = [ordered]@{ $EAreport = [ordered]@{
"Server"=$IP "Server"=$IP
"Datatype"=$datatype.toUpper() "Datatype"=$datatype.toUpper()
@ -1026,12 +1025,20 @@ function Invoke-EgressAssess
"Time (seconds)"=[Math]::Round($(($endTime-$startTime).totalseconds),2) "Time (seconds)"=[Math]::Round($(($endTime-$startTime).totalseconds),2)
"Date" = Get-Date "Date" = Get-Date
} }
if((Test-Path -path $ReportFile) -eq $False) try
{ {
New-Item "C:\Egress-Assess" -Type Directory -Force if((Test-Path -path $Report) -eq $False)
$null > $ReportFile {
} else {} Write-Verbose "[*] Writing new report file..."
Write-Output $EAreport | Format-Table | Tee-Object -file $ReportFile -Append $null > $Report
} else {}
Write-Output $EAreport | Format-Table | Tee-Object -file $Report -Append
}
catch
{
Write-Verbose "You do not have permission to write to this directory."
break
}
} }
} }
@ -1080,7 +1087,7 @@ function Invoke-EgressAssess
#get end time #get end time
$endTime = (Get-Date) $endTime = (Get-Date)
if($Report -eq $true) if($Report -gt 0)
{ {
Write-Report Write-Report
} else {} } else {}