Script for OpenVPN

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 7 months ago.

  • Author
    Posts
  • #69030

    Wesley
    Participant

    Hallo, I am Powershell beginner. I need your valuable help with this. I need to be at the startup of the computer.

    Restarting OpenVPN ->
    Check if it is in the domain ->
    if so, then disconnect OpenVPN. ->
    if not, openvpn connect.

    So far I have this

    $SysInfo = New-Object -ComObject "ADSystemInfo"
    Try {
    $UserDN = $SysInfo.GetType().InvokeMember("ComputerName", "GetProperty", $Null, $SysInfo, $Null)
    "Connected"
    }
    Catch {
    "Not connected"
    }

    Its check for domain connecting.

  • #69376

    Don Jones
    Keymaster

    A computer is "in" the domain whether it's talking to a domain controller or not. It might be better to ping a known IP address, like that of an internal DNS server, to see if you're connected to the private network.

You must be logged in to reply to this topic.