OpenScript

Reply
Visitor
Posts: 2
Registered: ‎11-17-2017

Not able to put my Switch output to a logfile

Hi Guys,

Here is the piece of code where i am picking an IP and connecting to it and then running a command to show all the port errors and then trying to put that output into a text file. At last sending that output to my mail.

So everything is working out as perfect as i want but i am getting a mail with an empty attachment, where i don't see my port errors and rather the date and the IP . could anybody please help me in solving the issue. i am sure that i am missing a small one.

$SMTPSRV = "smtp.xyz.net"
$EmailFrom = "from@email.com"
$EmailTo ="to@email.com"
$logFile = "Brocade-Log-" + (Get-date -f dd ).tostring() + (Get-date -f MM ).tostring() + ((Get-Date).year).tostring() + ".txt"

(get-date) > $logFile

Get-Content C:\Users\xyzpa\Desktop\fibre-switches.txt | % { $_ >> $logFile ; & 'C:\Users\xyzpa\Desktop\putty.exe' -l admin -pw Sty34viR -m C:\Users\xyzpa\Desktop\brocade1.txt $_ >> $logFile}
#Get-Content .\Desktop\fibre-switches.txt | % { & '.\Desktop\putty.exe' -l admin -pw password -m .\brocade2.txt $_ }

$MyReport = "Cleared Fibre switch errors for all brocade switches"
Send-MailMessage -To $EmailTo -Subject "Brocade switch error clear." -From $EmailFrom -Body $MyReport -SmtpServer $SMTPSRV -Attachments $LogFile

output of the above script.
Brocade-11172017.txt(attachement)

Friday, November 17, 2017 6:53:26 PM
196.20.162.xyz

Here is the files used in the script.

fibre-switches.txt : 196.20.162.xyz
brocade1.txt : porterrshow

Join the Community

Get quick and easy access to valuable resource designed to help you manage your Brocade Network.

vADC is now Pulse Secure
Download FREE NVMe eBook