Skip to content

Commit

Permalink
Added Get-VIAUnimportedvmcxFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
DeploymentBunny committed Nov 8, 2016
1 parent 4f274cb commit bfef574
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Tools/Get-VIAUnimportedvmcxFiles/GetVIAUnimportedvmcxFiles.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Function Get-VIAUnimportedvmcxFiles
{
<#
.Synopsis
Script used find not yet imported Hyper-V Configurations
.DESCRIPTION
Created: 2016-11-07
Version: 1.0
Author : Mikael Nystrom
Twitter: @mikael_nystrom
Blog : http://deploymentbunny.com
Disclaimer: This script is provided "AS IS" with no warranties.
.EXAMPLE
Get-VIAUnimportedvmcxFiles
#>
[CmdletBinding(SupportsShouldProcess=$true)]

Param(
[string]$Folder
)

if((Test-Path -Path $Folder) -ne $true){
Write-Warning "I'm sorry, that folder does not exist"
Break
}

$VMsIDs = (Get-VM).VMId
$VMConfigs = (Get-ChildItem -Path $Folder -Filter *.vmcx -Recurse).BaseName

$obj = Compare-Object -ReferenceObject $VMsIDs -DifferenceObject $VMConfigs

$Configs = foreach($Item in ($obj.InputObject)){
$Items = Get-ChildItem -Path $Folder -Recurse -File -Filter *.vmcx | Where-Object -Property Basename -Like -Value "*$Item"
$Items | Where-Object -Property FullName -NotLike -Value "*Snapshots*"
}
Return $Configs.FullName
}

0 comments on commit bfef574

Please sign in to comment.