Hola Sanmafe,
De antemano gracias por interesarte en el tema, dejo el codigo del Script para poderlo verificar.
Se esta quedando en el else ( Write-Warning "UNEXPECTED ERROR: Script configuration file missing`nSeek help from your instructor.")
Inicío de Script
# break-5-1.ps1
# This script breaks the the Virtual machine production network
# by removing the nic from vSwitch.
#
$scriptpath = $MyInvocation.MyCommand.Path
$directorypath = Split-Path $scriptpath
$netfile = $directorypath + "\net_commands.ps1"
Import-Module $netfile
Write-Host -NoNewline "Please wait while the system is prepared for your exercise. . . "
Set-PowerCLIConfiguration -confirm:$false -InvalidCertificateAction Ignore | Out-Null
# #######
# Confirm that this script is being run as Administrator
# #######
If (-NOT ( running_with_privilege ) )
{
Write-Warning "FAIL: YOU ARE NOT READY TO START THE LAB`nThis script must be run as an Administrator!"
Exit
}
# #######
# Load global variables, connect to vCenter Server
# #######
If ($classdatafile -and ( Test-Path $classdatafile) ) {
[xml]$classInfo = Get-Content $classdatafile
} else {
Write-Warning "UNEXPECTED ERROR: Script configuration file missing`nSeek help from your instructor."
Exit
}
$vc = $classInfo.Class.vc.Name
If ($credentialfile -and ( Test-Path $credentialfile) ) {
$credential = Get-VICredentialStoreItem -Host $vc -File $credentialfile
trap {
write-warning ("UNEXPECTED ERROR: After reading credential file`n" + $_.Exception.message)
Exit
} Connect-VIServer $vc -User $credential.User -Password $credential.Password -ErrorAction Stop | Out-Null
} else {
$credential = Get-Credential
trap {
write-warning ("UNEXPECTED ERROR: After accepting credential interactively`n" + $_.Exception.message)
Exit
} Connect-VIServer $vc -Credential $credential | Out-Null
}
Write-Debug "Finished script initialization"
Write-Host -NoNewline "."
#Write-Host "Executing script"
#Import-Module "c:\Documents and settings\Administrator.vclass\My Documents\WindowsPowerShell\net_commands.ps1"
#this is the locaton of the file on the hard disk should be the only hardcoded variable in the script
#$xmlfile = "C:\Tools\ClassInfo.xml"
# Open the file that contains the varibles used for this script.
#[xml]$classInfo = OpenXMLFile $xmlfile
#Open the xmlfile
#set the various variables that will be used in the script
#$vc = $classInfo.Class.vc.name
#$vcUser = $classInfo.Class.vc.user
#$vcPass = $classInfo.Class.vc.password
$MyEsx = $classInfo.Class.Host[0].name
$PartnerEsx = $classInfo.Class.Host[1].name
$vS2 = $classInfo.Class.Module5.Switches.Switch2.name
$pg = $classInfo.Class.Module5.Switches.Switch2.pg
#Connect to the Virtual Center Server
#$srv= ConnectToVC $vc $vcUser $vcPass
##If the virtual machines are powered off then power them on
Get-Vm | where {$_.Powerstate -eq "PoweredOff"} | Start-VM -Confirm:$false | out-null
#See where the virtual machines are located and move them to production if
#they are located somewhere else.
$vmpg = Change_VMPortgroup $pg
#This breaks the NIC on the Production Network by removing the NIC from the vSwitch
$h = Get-VMHost $MyEsx
$nic = @() #Empty array
Foreach ($s in Get-VirtualSwitch -Standard ) {
if ($s.Name -eq $vS2) {
Set-VirtualSwitch $s -Nic $nic -Confirm:$false | Out-Null
} #end if
} #end foreach
Disconnect-VIServer -Confirm:$false
Write-Host
Write-Host "You are now ready to start the lab"
break ;
#Disconnect-VIServer -Confirm:$false