Posted in
Virtual Machine Manager,
Windows Powershell |
No Comment | 7,764 views | 20/06/2009 08:42
I will list all virtual machines and their ip address, then I will export this informations to Argus, so I can see all virtual machines status with Argus or similar network traffic controller. You can’t get ip address with this method because it’s not possible, at least now. I used MSSQL server to get CIDRs of virtual machines.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
Get-Vmmserver localhost
$VMProp = Get-VM | Select-Object -Property Name,OperatingSystem
foreach ($i in $VMProp)
{
$VMName = $i.Name
$VMIP = $i.IPAddress
$valueone = ' Host "' + $VMName + '" {'
$valuetwo = ' hostname: ' + $VMIP
$valuethree = ' Service TCP/HTTP'
$valuefour = ' }'
add-content -path “C:\argus.txt” -value $valueone
add-content -path “C:\argus.txt” -value $valuetwo
add-content -path “C:\argus.txt” -value $valuethree
add-content -path “C:\argus.txt” -value $valuefour
} |
Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
Get-Vmmserver localhost
$VMProp = Get-VM | Select-Object -Property Name,OperatingSystem
foreach ($i in $VMProp)
{
$VMName = $i.Name
$VMIP = $i.IPAddress
$valueone = ' Host "' + $VMName + '" {'
$valuetwo = ' hostname: ' + $VMIP
$valuethree = ' Service TCP/HTTP'
$valuefour = ' }'
add-content -path “C:\argus.txt” -value $valueone
add-content -path “C:\argus.txt” -value $valuetwo
add-content -path “C:\argus.txt” -value $valuethree
add-content -path “C:\argus.txt” -value $valuefour
}
You can copy Argus.txt codes and past it to your Argus config file, \var\argus\config.php.