samples/vm-extensions.json

[
    {
        "MemberType": "ScriptProperty",
        "MemberName": "TestVHD",
        "Value": "\n if ($this.HardDrives) {\n #test if there are any false results\n if ( ($this | Get-VMHardDiskDrive | Test-Path) -contains $False ) {\n $False\n }\n else {\n $True\n }\n }\n else {\n #no hard drive files configured\n $false\n } \n",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "ConfigurationFile",
        "Value": "Join-path -Path \"$($this.configurationLocation)\\Virtual Machines\" -ChildPath \"$($this.vmid).vmcx\" -Resolve ",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "DiskPath",
        "Value": "$this.Harddrives.path",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "Running",
        "Value": "if ($this.state -eq 'Running') {$True} else { $False}",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "SizeGB",
        "Value": " \r\n $stat = Get-VMHardDiskDrive -VMName $this.vmname | Get-Item | Measure-Object -Property length -sum\r\n [math]::Round($stat.sum/1GB,2)\r\n ",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "MemoryMB",
        "Value": "$this.MemoryAssigned/1mb",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "MemoryDemandMB",
        "Value": "$this.MemoryDemand/1mb",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "HasSnapshot",
        "Value": " if ($this.parentSnapshotName) { $True } else { $False}",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "IPAddress",
        "Value": "($this | Get-VMNetworkAdapter).IPAddresses | where {$_ -match \"\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\"}",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
        "MemberType": "ScriptProperty",
        "MemberName": "Runtime",
        "Value": "\"{0}.{1:00}:{2:00}:{3:00}\" -f $this.uptime.Days,$this.uptime.Hours,$this.uptime.Minutes,$this.uptime.Seconds",
        "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    },
    {
    "MemberType": "ScriptProperty",
    "MemberName": "VMSwitch",
    "Value": "($this | Get-VMNetworkAdapter).SwitchName",
    "TypeName": "Microsoft.HyperV.PowerShell.VirtualMachine"
    }
 
]