C
C
Creat1ve2019-01-06 00:27:30
PowerShell
Creat1ve, 2019-01-06 00:27:30

How to establish a PPPoE connection using Powershell?

Good day. How to establish a PPPoE connection using Powershell?
Important: without resorting to rasphone.exe and rasdial.exe .

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor_Ya, 2020-12-06
@Igor_Ya

Unfortunately, this only displays a connection window, followed by another window, and so on. It doesn't connect.
Although in Windows 8 this window displayed on the connection immediately, without new crazy metro windows.

$itemName = 'Ростелеком'
$pressIt = 'Подкл&ючить/отключить'
$sa = New-Object -ComObject Shell.Application
$sa.NameSpace(49).Items() | foreach ({
    if($_.Name -eq $itemName){
        $_.Verbs() | foreach ({
            if ($_.name -eq $pressIt){
                $_.DoIt()
                break
            }
        })
    }
})

It seems that the request "without resorting to rasphone.exe and rasdial.exe" is meaningless ... at least in relation to rasdial.exe.
The fact is that, apparently, it is simply the "entrance gate" to the software connection process, if the user wishes to do so. And his further path will follow the same dlls and executable files, which are activated by the standard click of the connect button.
The simplest Powershell script
$x='Ростелеком'
$a='login';
$b='password';
$c=$env:WINDIR+'\System32\rasdial.exe';
&$c @($x,$a,$b) 2>&1|ForEach{
         $_
};

will display exactly the same errors and messages that you see during a normal connection.
The fact that you need to enter the name of the Rostelecom connection, for example, does not mean anything, you can take it from the registry.
HKEY_USERS\'+your GUID+'\Software\Microsoft\RAS Phonebook
parameter DefaultEntry - Default connection.
Well, the login and password - so that all programs do not en masse begin to break into the open gate.
Important, if you don't want to see the cracks, don't run powershell ISE in the environment.
Run standard Powershell file ps.1 using shortcut
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy Bypass -File "G:\mypath\name.ps1"

A
azarij, 2019-01-06
@azarij

something like this... just plug in the name of the pppoe connection instead of MyDialup. and if Windows is Russian, then you will probably need to change the script, looking at what $sa.NameSpace (49). Items () is and how it is called in Russian.
$sa = New-Object -ComObject Shell.Application
$connections = $sa.NameSpace(49).Items()
$dialupName = "MyDialup"
for($i=0;$i -lt $connections.Count;$i++) {
if($connections.Item($i).name -eq $dialupName){
$dialup = $connections.Item($i);
break;
}
}
$connect = 'C&onnect'
$verbs = $dialup.Verbs()
for($i=0;$i -lt $verbs.Count;$i++){
if($verbs.Item($i).name - eq $connect){
$verbs.Item($i).DoIt();
break;
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question