[英]How to pass parameter to netsh command
請讓我知道如何在執行腳本時傳遞ipaddress,subnetmask,網關
下面是腳本:
$VMNetworkSettings = 'netsh interface ip set address "Ethernet0" static x.x.x.x(ipaddress) x.x.x.x(subnet mask) x.x.x.x(gateway)'
我嘗試了以下方法來實現,但收到錯誤消息作為無效參數
$Ip = Read-Host -Prompt "Enter the ip address"
$sub = Read-Host -Prompt "Enter the subnet"
$gateway = Read-Host -Prompt "Enter the gateway"
$VMNetworkSettings = 'netsh interface ip set address "Ethernet0" static $Ip $sub $gateway'
嘗試轉義雙引號( `"
),以便可以在字符串的開頭使用它們。
$VMNetworkSettings="netsh interface ip set address `"Ethernet0`" static $Ip $sub $gateway"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.