Useful script to go after servers in VMM and output the list to a csv file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | Import-Module virtualmachinemanager; $MasterList = @(); $serverList = Get-VM -VMMServer seacorpmgmt05 | Where-Object { (( $_ .Name -like '*DEMO*' -or $_ .Name -like '*APP*' -or $_ .Name -like '*WEB*' -or $_ .Name -like '*CORP*' -or $_ .Name -like '*UTIL*' -or $_ .Name -like '*MGMT*' ) -and $_ .Name -notlike '*dev*' ) }; foreach ( $server in $serverList ) { $serverNetworkAdapter = Get-SCVirtualNetworkAdapter -VM $server ; $MyObject = New-Object PSObject -Property @{ ServerName = $server .Name; ServerEnvironment = $server .Name.Substring(3,4); HostName = $server .HostName; VMStatusString = [string] $server .StatusString; VMState = [string] $server .VirtualMachineState; ServerIPAddress = $serverNetworkAdapter .IPv4Addresses; CPUCount = $server .CPUCount; Memory = $server .Memory; OperatingSystem = $server .OperatingSystem; IsHighlyAvailable = $server .IsHighlyAvailable; Description = $server .Description.Replace( [Environment] ::NewLine, '' ); CreationTime = $server .CreationTime; }; $MasterList += $MyObject ; }; $MasterList | Select-Object @{label= 'Server Name' ;expression={ $_ .ServerName.ToUpper()}}, @{label= 'Environment' ;expression={ $_ .ServerEnvironment.ToUpper()}}, @{label= 'VM Status' ;expression={ if ( $_ .VMStatusString -eq $_ .VMState) { $_ .VMStatusString } else { $_ .VMState + ' (' + $_ .VMStatusString + ')' }}}, @{label= 'Host Name' ;expression={ $_ .HostName.Replace( '.companyname.com' , '' ).ToUpper()}},@{Name=’ServerIPAddress’;Expression={ if ( [string] ::join( ";" , ( $_ .ServerIPAddress))) { [string] ::join( ";" , ( $_ .ServerIPAddress))} else { " " }}},@{label= 'Cores' ;expression={ $_ .CPUCount}},@{label= 'Memory' ;expression={ $_ .Memory}},@{label= 'OS' ;expression={ $_ .OperatingSystem}},@{label= 'Highly Available' ;expression={ $_ .IsHighlyAvailable}},@{label= 'Comments' ;expression={ if ( $_ .Description) { $_ .Description + ', Created ' + $_ .CreationTime} else { 'Created ' + $_ .CreationTime }}} | EXPORT-CSV c:\temp\server-list.csv -notype; |