Start-Telnet
SYNOPSIS
A full graceful telnet client using PowerShell and the .NET Framework.
SYNTAX
Start-Telnet [-TelnetHost] <String> [[-Port] <Int32>] [[-Conversation] <String[]>] [[-timeout] <Int32>]
[<CommonParameters>]
DESCRIPTION
This function acts as a telnet client, allowing full control over the text stream for automating tasks such as configuring Cisco routers and switches. It supports sending and receiving data, handling telnet commands, and managing conversations with the server.
EXAMPLES
EXAMPLE 1
Start-Telnet -TelnetHost "192.168.1.1" -Port 23 -Conversation @(">enable", "<Password:", ">mypassword")
Connects to the telnet host at 192.168.1.1 on port 23, sends "enable", waits for "Password:", and then sends "mypassword".
EXAMPLE 2
Uses the alias `Do-Telnet` to connect to the telnet host and retrieve the running configuration.
PARAMETERS
-TelnetHost
The address of the server or router hosting the telnet service.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Port
The TCP port number of the Telnet service running on the Telnet host. Defaults to 23.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: 23
Accept pipeline input: False
Accept wildcard characters: False
-Conversation
An array of strings representing the telnet conversation. The first character indicates the direction: - '>' : send data - '\<' : wait for data
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: @()
Accept pipeline input: False
Accept wildcard characters: False
-timeout
The timeout in seconds for waiting for data when using '\<' in the conversation. Defaults to 30 seconds.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 4
Default value: 30
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.