从 ”设置网络适配器供客人专用“我能够从客户操作系统 (Windows Server 2003) 或主机操作系统 (Windows Server 2012) 运行私有 tfpt 启动网络。这使我能够在嵌入式系统上运行当前和旧版软件测试。
我想要一个脚本来选择/取消选择我正在桥接的 NIC 卡上的驱动程序。
对于客户操作系统,我想禁用除“VirtualBox NDIS6 Bridged Networking Driver”之外的所有功能。我目前手动执行此操作。
当我切换到主机操作系统时,我想禁用“VirtualBox NDIS6 桥接网络驱动程序”,并启用所有其他驱动程序:
- Microsoft 网络客户端
- 互联网协议版本 6 (TCP/IPv6)
- 互联网协议版本 4 (TCP/IPv4)
- ...(NetBios 等)
我认为我应该能够使用“netsh ..”或“wmic nic.”来执行此操作。到目前为止,命令:netsh interface dump > configA.dat 和 netsh -f configA.dat 或 netsh -f configB.dat 不会进行更改...我仍然必须手动执行此操作。关于如何解决这个问题有什么想法吗?
截屏:
答案1
这是我想出的脚本,它可以帮我解决问题:
#######################################################################
# SelectLAN.ps1
#
# Simple? Windows PowerShell Script to select between
# 1) Win2012 HOST system controlling 10.1.1.100 (Tester network)
# 2) Win2003 VirtualBox Guest Operating System controlling 10.1.100 (Tester network)
#
########################################################################
#
# Revision History
# 0.0 10/18/2016 R.Youngblood
#
########################################################################
function win2012 {
""
" Applying WIN2012 LAN Configuration"
""
" Enabling Local Reciept of IPV4 and IPV6 packets"
" Disable VirtualBox Driver"
Get-NetAdapterBinding -InterfaceAlias "LAN2"
Enable-NetAdapterBinding -Name "LAN2" -ComponentID oracle_vboxnetlwf
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_rspndr
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_lltdio
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_implat
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_msclient
Disable-NetAdapterBinding -Name "LAN2" -ComponentID vflt
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_pacer
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_server
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_tcpip
Disable-NetAdapterBinding -Name "LAN2" -ComponentID ms_tcpip6
}
function win2003VM {
""
" Applying WIN2003 LAN Configuration"
""
" Disable Local IPV4 and IPV6 Packet reciept"
" Enable VirtualBox Driver"
""
Get-NetAdapterBinding -InterfaceAlias "LAN2"
Disable-NetAdapterBinding -Name "LAN2" -ComponentID oracle_vboxnetlwf
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_rspndr
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_lltdio
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_implat
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_msclient
Enable-NetAdapterBinding -Name "LAN2" -ComponentID vflt
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_pacer
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_server
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_tcpip
Enable-NetAdapterBinding -Name "LAN2" -ComponentID ms_tcpip6
}
function endprint {
" Final Network Adapter configuration:"
Get-NetAdapterBinding -InterfaceAlias "LAN2"
" -- Done"
}
cls
""
"IP Configuration"
""
" 1. Win2012 Owns 10.1.1.100 IP"
" 2. Win2003 Virtual Machine Owns 10.1.1.100 IP"
""
$option = Read-Host -Prompt 'Enter your choice'
if ($option -eq 1 ) { win2012 }
if ($option -eq 2 ) { win2003VM }
endprint