Share via


How to control Internet connection sharing (ICS) through command line or PowerShell command?

Question

Wednesday, May 27, 2020 3:37 AM

This is the page in the picture above. How to set it through the command line or PowerShell?

All replies (8)

Wednesday, May 27, 2020 5:15 AM

I can't read Chinese, but from the title of the dialog you want to configure a Hyper-V virtual switch?
Take a look at the powershell commands: New-VMSwitch, Get-VMSwitch, etc.


Wednesday, May 27, 2020 5:27 AM

No, I'm just using this as an example. Its location is in the control panel, right-click the network adapter, select properties, and select "share" in the tab above.


Wednesday, May 27, 2020 5:37 AM

Hi ,

Thanks for your posting here. If you are using OS version pre-windows 7, you can use netsh routing commands to set this up, but that feature was removed from windows 7.

There’s no easy way to configure ICS with PowerShell in windows 10, it always need to write scripts to achieve it.

There are some thread talking about how to enable Windows ICS from PowerShell, you could have a look:

Enabling Windows ICS from PowerShell

How to enable Internet Connection Sharing using command line? (Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.)

Configure Internet Connection Sharing with PowerShell(Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.)

In addition, since your query is more related with PowerShell which our network forum doesn't focus on, you would better have this asked in PowerShell forum for better answers.

Here is the link:

Windows PowerShell

You can also find scripts in the Gallery that do what you are asking:

Script Gallery

Hope this can help you.

Best Regards,

Candy

Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]   


Monday, June 1, 2020 1:46 AM

Hi ,

Just checking in to see if the information provided was helpful.

Please let us know if you would like further assistance.

Best Regards,

Candy

Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]   


Monday, June 1, 2020 2:34 AM

I need a way to turn on and turn off ICS through one command. These are not in line with my requirements. Since Microsoft no longer provides this function, I have found other solutions. Thank you for your answer.


Monday, June 1, 2020 2:39 AM

Hi ,

Would you please share the detail solution ? This will benefit all people accessing this forum. Your sharing will be highly appreciated.

Best Regards,

Candy

Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]   


Monday, June 1, 2020 3:02 AM

In fact, my solution has nothing to do with the problem I put forward. I am just looking for an indirect solution to another problem I put forward. You can see it in the link below.

Hyper-V guest network has problems every time the host restarts

Thank you.


Monday, June 1, 2020 3:27 AM

Fine. You could mark the useful reply as answer if you want to end this thread up.

If you have any other questions, you can open a new thread at any time.

Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]