0
PowerCLIスクリプトを使用して、CSVファイルに基づいて仮想マシンを作成しようとしています。私が働いている現在のコードは、「接続-VIServer」スクリプト内の変数としてハードコーディングされた「$ vcenter_srv = 『vcenter.seba.local』」:PowerCLI「Connect-VI Server」のサーバ名を尋ねる
$ScriptRoot = Split-Path $MyInvocation.MyCommand.Path
$csvfile = "$ScriptRoot\vms2deploy.csv"
$vcenter_srv = 'vcenter.seba.local'
$timeout = 1800
$loop_control = 0
$vmsnapin = Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
$Error.Clear()
if ($vmsnapin -eq $null)
{
Add-PSSnapin VMware.VimAutomation.Core
if ($error.Count -eq 0)
{
write-host "PowerCLI VimAutomation.Core Snap-in was successfully enabled." -ForegroundColor Green
}
else
{
write-host "ERROR: Could not enable PowerCLI VimAutomation.Core Snap-in, exiting script" -ForegroundColor Red
Exit
}
}
else
{
Write-Host "PowerCLI VimAutomation.Core Snap-in is already enabled" -ForegroundColor Green
}
if ($env:Processor_Architecture -eq "x86") {
#Connect to vCenter
Connect-VIServer -Server $vcenter_srv
私はかどうかを判断しようとしています「Connect-VIServer -Server $ vcenter_srv」スクリプトでPowerCLIスクリプトが「Connect-VIServer」コマンドを使用してサーバー名の入力を要求し、CSVファイルから引き出された残りの値を続行する方法があります。
は、あなたが提供するすべての情報をありがとう
接続するサーバーを指定しないとどうなりますか? – TessellatingHeckler