Skip to content

New MPToolPSDiscovery

AndreasSobczyk edited this page Nov 18, 2016 · 1 revision

#New-MPToolPSDiscovery This function will create a new Powershell discovery from a few simple input parameters and script with a array object that contains the discovery class properties. Will also verify or add all need management pack references.

###Parameters

  • ManagementServerFQDN [string] – FQDN of the management server to connect.
    Example - scom01.contoso.com
  • ManagementPackName [string] – Name of the management pack.
    Example - "Contoso.VMSwitch.Discovery"
  • DiscoveryName [string] – Name of the discovery.
    Example - "Contoso.SCVMM.VMSwitch.Discovery"
  • DiscoveryDisplayName [string] – (Optional) Display name of the discovery.
    Example - "Contoso SCVMM VMSwitch Discovery"
  • DiscoveryClassName [string] – Name of the class to discover. This is the class to discover.
    Example - "Contoso.SCVMM.VMSwitch"
  • TargetClassName [string] – Target class for the discovery to run on.
    Example - "Microsoft.SystemCenter.VirtualMachineManager.VMMManagementServer"
  • TargetClassMPName [string] – (Optional) Name of the target class management pack.
    Example - "Microsoft.SystemCenter.VirtualMachineManager.Library"
  • TargetClassMPAlias [string] – (Optional) Alias of the target class management pack.
    Example - "VMMLibrary"
  • IntervalSeconds [int] – Interval in seconds for the discovery to run.
    Example - 86000
  • TimeoutSeconds [int] – Timeout in seconds for the script to timeout.
    Example - 45
  • Script [string] – PowerShell script for the discovery. This script must create a array object called $DiscoveryObjects with properties matching the properties of the discovery class.
    Example -
@'
$DiscoveryObjects = @()

Get-SCVMMServer $env:COMPUTERNAME | Out-Null
$VMSwitches = Get-SCVirtualNetwork | select Name,VMHost

foreach($VMSwitch in $VMSwitches){
  $ClassProperties = @{} | select DeviceID,Switchname,VMHost
  $ClassProperties.DeviceID = VMSwitch.VMHost.ToString()+","+$VMSwitch.Name.ToString()
  $ClassProperties.Switchname = $VMSwitch.Name.ToString()
  $ClassProperties.VMHost = $VMSwitch.VMHost.ToString()

  $DiscoveryObjects += $ClassProperties
}
'@
  • ScriptParameters [array] – (Optional) Script input parameters is used to get property values from the target class or the target class’s host. The parameters name must match a property on the target class or it’s host.
    Example - @("Version")
  • Enabled [boolean] – (Optional) If the discovery should be enabled - $true/$false – Default: $false.

###Example Creates a new Powershell Discovery called Contoso.SCVMM.VMSwitch.Discovery for the class Contoso.SCVMM.VMSwitch, this class contains properties DeviceID Switchname and VMHost. The discovery will run on all instances of the class, "Microsoft.SystemCenter.VirtualMachineManager.VMMManagementServer", and discovery all the instances of the Contoso.SCVMM.VMSwitch on the VMM server.

New-MPToolPSDiscovery -ManagementServerFQDN scom01.contoso.com `
-ManagementPackName "Contoso.VMSwitch.Discovery" `
-DiscoveryName "Contoso.SCVMM.VMSwitch.Discovery" `
-DiscoveryDisplayName "Contoso SCVMM VMSwitch Discovery" `
-DiscoveryClassName "Contoso.SCVMM.VMSwitch" `
-TargetClassName "Microsoft.SystemCenter.VirtualMachineManager.VMMManagementServer" `
-IntervalSeconds 300 `
-TimeoutSeconds 45 `
-Script @'
$DiscoveryObjects = @()

Get-SCVMMServer $env:COMPUTERNAME | Out-Null
$VMSwitches = Get-SCVirtualNetwork | select Name,VMHost

foreach($VMSwitch in $VMSwitches){
   $ClassProperties = @{} | select DeviceID,Switchname,VMHost
   $ClassProperties.DeviceID = $VMSwitch.VMHost.ToString()+","+$VMSwitch.Name.ToString()
   $ClassProperties.Switchname = $VMSwitch.Name.ToString()
   $ClassProperties.VMHost = $VMSwitch.VMHost.ToString()

   $DiscoveryObjects += $ClassProperties
                                                        }
'@ `
    -Enabled $true

Clone this wiki locally