I know how to do the steps manually but i would like to automate this as i
have a large number of switches and routers that I want to capture both the
running and startup configs.
I have found a script that makes powershell act like a telnet client, but i
am looking for a way to deal with the telnet data like i would from the old
standard of line by line reading like from a text file.
Any suggestions on how to set up the stream so i can react to and respond
back to the session in say a line by line format (helps for parsing).
Daren Daigle
Boys and Girls Clubs of America
I think I followed you up to this last paragraph...
How about this?
63# start-transcript device1.log
Transcript started, output file is device1.log
64# "testing"
testing
65# stop-transcript
Transcript stopped, output file is C:\powershell\device1.log
66# gc device1.log
**********************
Windows PowerShell Transcript Start
Start time: 20070713153851
Username : ALIANT\MA36788
Machine : NB517949 (Microsoft Windows NT 5.1.2600 Service Pack 2)
**********************
Transcript started, output file is device1.log
64# "testing"
testing
65# stop-transcript
**********************
Windows PowerShell Transcript End
End time: 20070713153900
**********************
67#
You can use start-transcript to record everything going in on the
console. Then you might just have to trim the first and last few lines
to get just your config.
Marco
Might be overkill, but perhaps the System.Console class has what you need
(see the ReadLine method notes):
http://msdn2.microsoft.com/en-us/library/system.console.aspx
There's also the NetCmdlets from nSoftware, which might have easier-to-use
methods to read telnet output:
http://www.nsoftware.com/powershell/default.aspx
Cheers,
Jason
------------------------------------------------------
PowerShell Training at SANS Conferences
http://www.WindowsPowerShellTraining.com
------------------------------------------------------
Lee Holmes' Connect-Computer v2 script is pretty easy to adapt for a
combination of interactive and automated processing in a session (if
that's what you mean):
http://www.leeholmes.com/blog/default,date,2006-12-04.aspx
Scroll down to 29 Nov 2006, 'Scripting Network / TCP Connections in
PowerShell'.
-Hecks
Direct link: http://www.leeholmes.com/blog/ScriptingNetworkTCPConnectionsInPowerShell.aspx
OMG, I was working on this problem using connect-computer.ps1 version
1, didn't know about v2! I basically did v1.1 in a very poor way. Oh
well, I learned some things. :)
Read about it here if you like: http://halr9000.com/article/397