I am in need to trying to figure out the Network Access Type of an ethernet connection on various virtual machines.
In short i am trying to find an analogy for
(Get-NetConnectionProfile).IPv4Connectivity
which works great Windows 2012 onwards, i am looking to run this query against Windows 2008 R2 servers.
I got this working on a Windows 2008 server, using a .NET class, cast to an object in powershell, Sample code as follows:
$nlm = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}"))
$nlm.GetNetworkConnections() | ForEach-Object {
[PSCustomObject]@{
NetworkName = ($_.GetNetwork().GetName());
isConnectedToInternet = $_.isConnectedToInternet;
}
if ($nlm.IsConnectedToInternet)
{
$NLAState = 'Internet'
}
"Access type : $NLAState"