A powershell script to be performed before each export has been prepared. The script must be called PreExportScript.ps1 and needs to be dropped in the C:\ProgramData\AppRecovery\Scripts folder (which is the default location). If the folder does not exist, it has to be created.
If running the script with parameters is desired, please do the following (you may want to use names and paths that make sense to your environment):
1. rename the script provided PreExportScript.ps1 to vnics.ps1
2. copy the script to c:\temp
3. create a file called PreExportScript.ps1 in C:\ProgramData\AppRecovery\Scripts
4. add the following content using only the parameters that apply:
powershell c:\temp\nics.vnics.ps1 -hypervhost <your hyperv server> -logpath <your log path> -vmcheck <machine1>,<machine2>
5. run the script manually to make sure that it works as intended.
The script has the following parameters:
logpath -- by default c:\temp\nics-<date-time>
hypervhost -- by default local core name
vmcheck -- default the list of standby Hyper-V VMs (other types, i.e. Esxi, are excluded)
The provided script is fully documented.
Running
get-help PreExportScript.ps1 -full
will show the complete documentation
It is recommended to run the script manually to check if it is running as expected.
The script code is shown below between horizontal lines and attached to the KB.
______________________________________________________________________
<#
.Synopsis
Deletes all vnics on a Hyper-V virtual standby before a new export takes place thus working around the 8 vnics limit
.Description
Script tested on Hyper-V 2012R2. Make sure that the Hyper-V Powershell module is installed.
Drop the script into C:\ProgramData\AppRecovery\Scripts\PreExportScript.ps1
.Parameter logpath
default c:\temp\nics-<date-time>
.Parameter hypervhost
default local core name
.Parameter vmcheck
default the list of standby Hyper-V VMs (other types, i.e. Esxi, are excluded)
.Example
preexportscript.ps1
.Example
preexportscript.ps1 -hypervhost machine1 -vmcheck machine2,machine3
#>
param ($logpath = "c:\temp\nics-$((get-date).ToString(`"yyyy-MM-dd-HH-mm-ss`")).txt",
$hypervhost=($env:computername),
[array]$vmcheck=((Get-VirtualizedServers | where {$_.LocationDisplayExportTypeName -eq "Hyper-V"}).agentdisplayname))
#filter Out-Default{ $_ | Out-File 'C:\logfile.txt' -append }
Write-Host "`r`nStarting pre-export vnic removal script...`r`nHyper-V host: $hypervhost`r`nList of machines to check:"; $vmcheck | ft
$vm = get-vm -ComputerName $hypervhost
$Title = "Virtual Machines on Hyper-V Host $hypervhost"
$Title
$title >$logpath
$vm >> $logpath
foreach($singlevm in $vm){
$vmachine = $singlevm.name
if ($vmcheck -contains $vmachine){
$nics = Get-VMNetworkAdapter -VMName $vmachine -ComputerName $hypervhost
$nics | ft
$nics | ft >> $logpath
$result = Remove-VMNetworkAdapter -Name "*" -VMName $vmachine -ComputerName $hypervhost
$result
$result >> $logpath
}
}
#dir function:\Out-Default | del
______________________________________________________________________
Product: AppAssure 5.4.2.192 with P-001008 only.