
從 ”設定網路適配器為訪客專用「我能夠從來賓作業系統 (Windows Server 2003) 或主機作業系統 (Windows Server 2012) 執行私人 tfpt 啟動網路。這讓我能夠在嵌入式系統上執行目前和舊版軟體測試。
我想要一個腳本來選擇/取消選擇我正在橋接的 NIC 卡上的驅動程式。
對於來賓作業系統,我想停用「VirtualBox NDIS6 橋接網路驅動程式」之外的所有內容。我目前手動執行此操作。
當我切換到主機作業系統時,我想停用“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