Multiple WMI query for Multiple Servers - Any fastest way?

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Akash Kheradia Akash Kheradia 5 months, 1 week ago.

  • Author
    Posts
  • #45009
    Profile photo of Akash Kheradia
    Akash Kheradia
    Participant

    Expert,

    I have script which call for many WMIobject for many servers.
    I tried with Get-WMIObject as well as using Get-CIMInstance method with new-cimsession.
    But it took very long time to get all result.
    Any way that i can tune the script to get me result fast?
    Following is the script block i am running with invoke-command for many servers.

    $ScriptBlock = {
    $instance = new-cimsession
    $ComputerSys = get-ciminstance -classname win32_computersystem -CimSession $instance
    $Logicadisk = get-ciminstance -classname win32_logicaldisk -CimSession $instance
    $service = get-ciminstance -classname win32_service -CimSession $instance
    $PnPDriver = get-ciminstance -classname Win32_PnPSignedDriver -CimSession $instance
    $NetAdapter = get-ciminstance -classname Win32_NetworkAdapter -CimSession $instance
    $NetAdapterConfig = get-ciminstance -classname Win32_NetworkAdapterConfiguration -CimSession $instance | ?{$_.ipaddress -ne $null}
    $Product = get-ciminstance -classname Win32_Product -CimSession $instance
    $QFE = get-ciminstance -classname Win32_QuickFixEngineering -CimSession $instance
    $Processor = get-ciminstance -classname Win32_Processor -CimSession $instance
    $BIOS = get-ciminstance -classname Win32_BIOS -CimSession $instance
    $OSCIM = get-ciminstance -classname Win32_OperatingSystem -CimSession $instance
    $OS = Get-WmiObject win32_operatingsystem
    $PF = get-ciminstance -classname Win32_PageFile -CimSession $instance
    $OSTimeZone = get-ciminstance -classname Win32_TimeZone -CimSession $instance
    $License = get-ciminstance -classname SoftwareLicensingProduct -CimSession $instance | ?($_.Description -like "VOLUME_KMSCLIENT channel")

    $start = Invoke-Command -ComputerName $Server -ScriptBlock $ScriptBlock

    Also tried with
    $start = Invoke-Command -ComputerName $Server -ScriptBlock $ScriptBlock -AsJob -JobName "$server-Job"
    but facing problem with getting variable from Job

    Please help ..!

  • #45014
    Profile photo of Richard Siddaway
    Richard Siddaway
    Moderator

    Why create a CIM session AND use PowerShell remoting through Invoke-Command. One or the other not both. You are gathering a lot of data here so I'd not expect your script to be particularly quick. Examine the objects returned by each call to a CIM class and determine what data you actually need.

    • #45028
      Profile photo of Akash Kheradia
      Akash Kheradia
      Participant

      I need multiple properties from each WMI. That would be need for a Validation report of every server.
      I am pulling following values to show in my reports.and for i thought to call whole WMI Object intead of specific property.

      Server,Domain,Client Name,Serve Role,OS,Version,Service Pack,OS Architecture,Install Date,GPO Version,WSUS Missing Patch,Last patch install date,Disk Space,Days Since Last Boot,Bios Version,Model,Machine Serial Number,Total Memory,Processor Speed,Number of Processors,Activation Status,Ip Address,Subnet Mask,Default Gateway,DNS,IPv6 Address,NetBIOS,LMHost Lookup,TCP/IP RSS,TCP/IP Chimney Offload,TCP/IP Receive Window Auto-Tuning,Page File,Processor Scheduling,Time Zone,Time Server,IE ESC,UAC,RDP,Windows Error Reporting,Automatic Updates,Power Scheme,VMware Tools,McAfee McShield Status,"McAfee Framework Status""",Mcafee Agent,Mcafee VirusScan Enterprise,Symantec NetBackup Client,NetIQ Agent,Office,Visual Studio,Ms Report Viewer,Ms WSE,EMC Master Agent,EMC PowerPath,NIC Binding Order

You must be logged in to reply to this topic.