简体   繁体   English

使用Windows Server 2008 R2上的Com对象通过PowerShell在特定NIC上禁用IPV6?

[英]Disable IPV6 on specific NIC via PowerShell using a Com Object on Windows Server 2008 R2?

I need to script some Windows Server 2008 R2 builds, preferably in PowerShell. 我需要编写一些Windows Server 2008 R2版本的脚本,最好是在PowerShell中。 I need to disable or uncheck IPV6 on a specific NIC (the same NIC every time). 我需要在特定NIC(每次都使用相同的NIC)上禁用或取消选中IPV6。 Currently, I have to set it manually. 目前,我必须手动设置它。 I do not want to disable IPV6 completely for the entire server other things may use that in the future. 我不想完全禁用整个服务器的IPV6,以后可能会使用其他东西。 Is there an object I can reference in a PowerShell command specifying my NIC "Intel(R) PRO/1000 MT Network Connection" and disable IPV6? 我可以在PowerShell命令中引用一个对象来指定我的NIC“Intel(R)PRO / 1000 MT网络连接”并禁用IPV6吗? Unfortunately, Group Policy is not an option says the boss. 不幸的是,老板说组策略不是一个选择。 I've tried finding an appropriate WMI object via "PowerShell Scriptomatic" but failed to find the difference between an enabled setting versus disabled on the Intel NIC. 我已尝试通过“PowerShell Scriptomatic”找到合适的WMI对象,但未能找到Intel NIC上已启用设置与已禁用设置之间的区别。 Thanks in advance. 提前致谢。

Microsoft has a command line program nvspbind ( https://gallery.technet.microsoft.com/Hyper-V-Network-VSP-Bind-cf937850 ), that can disable ipv6 on a specific interface. Microsoft有一个命令行程序nvspbind( https://gallery.technet.microsoft.com/Hyper-V-Network-VSP-Bind-cf937850 ),可以在特定接口上禁用ipv6。 It seems to be identical to unchecking the IPv6 box in adapter settings dialog. 它似乎与在适配器设置对话框中取消选中IPv6框相同。 You can launch this program from a script or your program. 您可以从脚本或程序启动此程序。

The command line arguments to disable IPv6 on a particular interface is: 在特定接口上禁用IPv6的命令行参数是:

nvspbind -d {GUID} ms_tcpip6

First before removing IPV6 you'better read these Microsoft articles : 首先在删除IPV6之前,请阅读以下Microsoft文章:

How to disable IP version 6 (IPv6) 如何禁用IP版本6(IPv6)

What are Microsoft's recommendations about disabling IPv6? Microsoft关于禁用IPv6的建议是什么?

In summary you can disable IPV6 on all interfaces using (detailled explanation here ): 总之,您可以使用( 此处详细说明)在所有接口上禁用IPV6:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters]
“DisabledComponents”=dword:ffffffff

Edited 编辑

According to @David Brabant comment to desable IPV6 on only one adapter you can bind or unbind it with the registry key : 根据@David Brabant对只有一个适配器的desable IPV6的评论,您可以使用注册表项绑定或取消绑定它:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip6\Linkage]
"Bind"=RegmultiSZ

of the form : 形式:

\Device\{DBB82A20-A485-4CB6-AD31-EF14B91F5EFB}

You can build this line with : 您可以使用以下内容构建此行:

# Public Name NetworkCard Name
$networkCardName = "Connexion au réseau local 1"

# Get Device GUID
$guid=(gwmi -query "select * from win32_networkadapter where netconnectionid= '$networkCardName'").guid

I use simple .bat files with the "netsh" command. 我使用简单的.bat文件和“netsh”命令。 You can certainly use "netsh" with Powershell, if you prefer. 如果您愿意,您当然可以将“netsh”与Powershell一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows Server 2008 R2上通过Powershell 4.0创建计划任务? - How can I create scheduled tasks via Powershell 4.0 on Windows Server 2008 R2? Windows Server 2008 R2使用Powershell编辑网络设置 - Windows Server 2008 R2 editing network settings with powershell Windows Server 2008 R2 PowerShell和Internet Explorer 9 - Windows Server 2008 R2 PowerShell and Internet Explorer 9 使用Powershell Windows Server 2008 R2将用户导入本地 - Import users to local with powershell windows server 2008 r2 更改芬兰语Windows Server 2008 R2上Powershell脚本的文化 - Change culture on Finnish Windows Server 2008 R2 for Powershell Script 在 Windows Server 2008 R2 上的 PowerShell 中创建专用队列 - Creating private queues in PowerShell on Windows Server 2008 R2 是否会为在Win Server 2008 R2上运行的Windows 7开发PowerShell脚本? - Will a PowerShell script developed for a Windows 7 run on Win Server 2008 R2? 使用Powershell激活Windows 2008 R2 Server - Use Powershell to Activate Windows 2008 R2 Server 在 windows server 2008 r2 上使用 csv 文件将 AD 用户添加到安全组 - Adding AD users to security group using a csv file using powershell on windows server 2008 r2 如何使用PowerShell脚本在Windows Server 2008 R2上静默安装.NET 4.5。 - How to install .NET 4.5 silently on Windows Server 2008 R2 using powershell Script.?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM