Author Posts

April 20, 2017 at 12:51 pm

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.

April 24, 2017 at 1:47 pm

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.