Search code examples
powershellcmdtelnetnmap

Output results of telnet and nmap to powershell/cmd session


So I have a serious fundamental gap in my knowledge that I'm sure has an easy answer, but after googling and looking on here, I can't find what I'm looking for:
I use nmap and telnet on an almost daily basis for checking ports and logging into IP codecs and I use them through either the powershell or cmd consoles, but when I tried to script something and run that script with either a .bat or .ps1 suffix, either will give me the classic not recognized... message. But, if you're able to run it in the console, you should be able to script it, right? How can one go about that?

Sample code for telnet (that works in when inputting to either console, but not in script form):

telnet 192.168.87.21

Sample code for nmap (again, works when inputting to either console, but not in script form):

nmap -p 9999 192.168.87.101

Solution

  • Add a '&' symbol before 'telnet' like that: & telnet 127.0.0.1

    For more information how to run executables from Powershell look there: https://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx