Posted in
Virtual Machine Manager,
Windows Powershell |
2 Comments | 34,727 views | 15/04/2009 07:40
This is a basic script about listing vms in Powershell. Output will be Name and Operating System.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
Get-Vmmserver localhost
# VM List Script - Yusuf Ozturk
# http://www.yusufozturk.info
$VMProp = Get-VM | Select-Object -Property Name,OperatingSystem
clear-content -path "C:\VMList.txt"
foreach ($i in $VMProp)
{
$VMName = $i.Name
$VMOprs = $i.OperatingSystem.Name
add-content -path “C:\VMList.txt” -value $VMName
add-content -path “C:\VMList.txt” -value $VMOprs
add-content -path “C:\VMList.txt” -value ‘‘
} |
Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
Get-Vmmserver localhost
# VM List Script - Yusuf Ozturk
# http://www.yusufozturk.info
$VMProp = Get-VM | Select-Object -Property Name,OperatingSystem
clear-content -path "C:\VMList.txt"
foreach ($i in $VMProp)
{
$VMName = $i.Name
$VMOprs = $i.OperatingSystem.Name
add-content -path “C:\VMList.txt” -value $VMName
add-content -path “C:\VMList.txt” -value $VMOprs
add-content -path “C:\VMList.txt” -value ‘‘
}
You could add more property with using other property names.