davidu davidu - 3 months ago 24
PowerShell Question

.NET API for DirectAcces status

we are currently developing a .NET application that needs to know the Microsoft DirectAccess connection state. I know it is possible to query the status via the PowerShell command

Get-DAConnectionStatus
.

But is it also possibly to query this DirectAccess status via a managed .NET library/API? A workaround would be to run a PowerShell script from C# but I don't think this is ideal from a performance perspective (we need to check this status regularly).

Thanks,
David

Answer

I could imagine the following (not testet yet though):

You can query the same information via

Get-CimInstance -Namespace "root/StandardCimv2" MSFT_DAConnectionStatus

and you can query CIM instances by C# via the assembly Microsoft.Management.Infrastructure of the Windows SDK as explained here

Comments