0
PowerCLI 스크립트를 사용하여 CSV 파일을 기반으로 가상 컴퓨터를 만들려고합니다. 내가 함께 일하고 현재 코드가있는 '연결-VIServer'하드 코딩 "$의 vcenter_srv = 'vcenter.seba.local'"스크립트의 변수로 :PowerCLI "Connect-VI 서버"의 서버 이름을 묻는 메시지
$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