Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the Interface Metric value of the network card using c#, All are working fine in Windows 10 but when I tried my solution on Windows 7 it is failing,
Please find below the code that is running correctly on Windows 10:
PowerShell ps = PowerShell.Create();
ps.AddCommamd("Get-NetIPInterface");
ps.AddParameter("AddressFamily", "IPV4");
ps.AddParameter("InterfaceAlias",nicname);
ps.AddParameter("InterfaceMeyric", 9999);
if(ps.Invoke().Count()>0)
   return 9999;
else
   return 0;

Please help me out how can I replace this with the code that is compatible with windows 7.

What I have tried:

I am trying to find the way to run same with the use of netsh command.
Posted
Updated 21-Oct-20 22:27pm

1 solution

 
Share this answer
 
Comments
Member 14686752 22-Oct-20 4:35am    
Powershell command is not working on windows 7.
Richard MacCutchan 22-Oct-20 5:05am    
Then you need to install it.
Member 14686752 22-Oct-20 6:32am    
It's there, but network related queries are not working on PowerShell of win7
Richard MacCutchan 22-Oct-20 6:49am    
As explained in the SO post above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900