Jump to content

Recommended Posts

Posted

Half the school are still running Office 2010 while the other half are on 2016.

 

I am trying to create a WMI filter for the two GPOs we have for both Office versions.

 

So far I have the following:

 

SELECT * FROM Win32_SoftwareFeature WHERE ProductName = "Microsoft Office Professional Plus 2016"

OR

SELECT ProductName FROM Win32_SoftwareFeature WHERE ProductName = "Microsoft Office Professional Plus 2016"

 

And

 

SELECT * FROM Win32_Product WHERE Caption = "Microsoft Office Professional Plus 2016"

or

SELECT CAPTION FROM Win32_Product WHERE Caption = "Microsoft Office Professional Plus 2016"

 

As you can see I am calling the classes Win32_Product and Win32_SoftwareFeature, as I am trying to determine which out of the classes loads quickest based on a measure count and optimising the WMI to request one specific attribute against requesting all fields a class can store.

 

With this query I can determine how long each WMI query takes to load

 

$query1 = "SELECT * FROM Win32_SoftwareFeature WHERE ProductName = 'Microsoft Office Professional Plus 2016'"
Measure-Command { Get-WmiObject -Query $query1 }

$query2 = "SELECT ProductName FROM Win32_SoftwareFeature WHERE ProductName = 'Microsoft Office Professional Plus 2016'"
Measure-Command { Get-WmiObject -Query $query2 }


$query3 = "SELECT * FROM Win32_Product WHERE Caption = 'Microsoft Office Professional Plus 2016'"
Measure-Command { Get-WmiObject -Query $query3 }

$query4 = "SELECT CAPTION FROM Win32_Product WHERE Caption = 'Microsoft Office Professional Plus 2016'"
Measure-Command { Get-WmiObject -Query $query4 }

 

The outcome is

 

Query 1
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 16
Milliseconds      : 768
Ticks             : 167688126
TotalDays         : 0.000194083479166667
TotalHours        : 0.0046580035
TotalMinutes      : 0.27948021
TotalSeconds      : 16.7688126
TotalMilliseconds : 16768.8126

Query 2
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 15
Milliseconds      : 795
Ticks             : 157957491
TotalDays         : 0.000182821170138889
TotalHours        : 0.00438770808333333
TotalMinutes      : 0.263262485
TotalSeconds      : 15.7957491
TotalMilliseconds : 15795.7491

Query 3
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 16
Milliseconds      : 270
Ticks             : 162709574
TotalDays         : 0.000188321266203704
TotalHours        : 0.00451971038888889
TotalMinutes      : 0.271182623333333
TotalSeconds      : 16.2709574
TotalMilliseconds : 16270.9574

Query 4
Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 14
Milliseconds      : 449
Ticks             : 144495215
TotalDays         : 0.000167239832175926
TotalHours        : 0.00401375597222222
TotalMinutes      : 0.240825358333333
TotalSeconds      : 14.4495215
TotalMilliseconds : 14449.5215

 

From the timings above you can see how long each query takes to load.

 

So, fellow Edugeekers, what query should I use to get it under 10ms and prevent the error ID 1035 showing in the Event Viewer, which increases log on times for end users?

Posted

Query 5? It's significantly faster than any of your queries. :)

 

$query5 = "SELECT Name FROM Win32_Directory WHERE Name = 'C:\\Program Files (x86)\\Microsoft Office\\Office16'"
Measure-Command { Get-WmiObject -Query $query5 }

 

Days              : 0
Hours             : 0
Minutes           : 0
[color="#FF0000"]Seconds           : 0
Milliseconds      : 9[/color]
Ticks             : 91855
TotalDays         : 1.06313657407407E-07
TotalHours        : 2.55152777777778E-06
TotalMinutes      : 0.000153091666666667
TotalSeconds      : 0.0091855
TotalMilliseconds : 9.1855

  • Thanks 1
Posted (edited)

@Arthur, I was going to post my findings on using the CIM_DataFile and Win32_Directory classes and your findings tally up with what I found with the Win32_Directory class.

 

CIM_DataFile

$query1 = "SELECT Path FROM CIM_DataFile WHERE Path = '\\Program Files\\Microsoft Office\\Office16'"
Measure-Command { Get-WmiObject -Query $query1 }

$query2 = "SELECT Path FROM CIM_DataFile WHERE Path = '\\Program Files (x86)\\Microsoft Office\\Office16'"
Measure-Command { Get-WmiObject -Query $query2 }

 

Query1
Days              : 0
Hours             : 0
Minutes           : 0
[color="#FF0000"]Seconds           : 0
Milliseconds      : 61[/color]
Ticks             : 616142
TotalDays         : 7.13127314814815E-07
TotalHours        : 1.71150555555556E-05
TotalMinutes      : 0.00102690333333333
TotalSeconds      : 0.0616142
TotalMilliseconds : 61.6142

Query2
Days              : 0
Hours             : 0
Minutes           : 0
[color="#FF0000"]Seconds           : 0
Milliseconds      : 69[/color]
Ticks             : 692457
TotalDays         : 8.01454861111111E-07
TotalHours        : 1.92349166666667E-05
TotalMinutes      : 0.001154095
TotalSeconds      : 0.0692457
TotalMilliseconds : 69.2457

 

 

Win32_Directory

$query1 = "SELECT Name FROM Win32_Directory WHERE Name = 'C:\\Program Files\\Microsoft Office\\Office16'"
Measure-Command { Get-WmiObject -Query $query1 }

$query2 = "SELECT Name FROM Win32_Directory WHERE Name = 'C:\\Program Files (x86)\\Microsoft Office\\Office16'"
Measure-Command { Get-WmiObject -Query $query2 }

 

Days              : 0
Hours             : 0
Minutes           : 0
[color="#FF0000"]Seconds           : 0
Milliseconds      : 9[/color]
Ticks             : 99960
TotalDays         : 1.15694444444444E-07
TotalHours        : 2.77666666666667E-06
TotalMinutes      : 0.0001666
TotalSeconds      : 0.009996
TotalMilliseconds : 9.996

Days              : 0
Hours             : 0
Minutes           : 0
[color="#FF0000"]Seconds           : 0
Milliseconds      : 9[/color]
Ticks             : 92019
TotalDays         : 1.06503472222222E-07
TotalHours        : 2.55608333333333E-06
TotalMinutes      : 0.000153365
TotalSeconds      : 0.0092019
TotalMilliseconds : 9.2019

Edited by Chuckster
Posted

Also interesting are the times the queries take if you run each one a thousand times and average the result. This figure should be more accurate apparently.

 

Measure-Command { for($i=0; $i -lt 1000; $i++) {
   Get-WmiObject -query "SELECT Name FROM Win32_Directory WHERE (Name = 'C:\\Program Files\\Microsoft Office\\Office16' OR Name = 'C:\\Program Files (x86)\\Microsoft Office\\Office16')" }
} | Select-Object @{Name="Average Milliseconds (Win32_Directory)";Expression={$_.TotalMilliseconds / 1000}}


Average Milliseconds (Win32_Directory)
--------------------------------------
[color="#FF0000"]5.9176912[/color]

 

Measure-Command { for($i=0; $i -lt 1000; $i++) {
   Get-WmiObject -query "SELECT Drive,Path FROM CIM_DataFile WHERE Drive = 'C:' AND (Path = '\\Program Files\\Microsoft Office\\Office16\\' OR Path = '\\Program Files (x86)\\Microsoft Office\\Office16\\')" }
} | Select-Object @{Name="Average Milliseconds (CIM_DataFile)";Expression={$_.TotalMilliseconds / 1000}}


Average Milliseconds (CIM_DataFile)
-----------------------------------
[color="#FF0000"]37.8454523[/color]

Posted
The different office ADMX templates and associated group policies don't interfere with each other. Something you set in the 2010 policy won't apply to Office 2016. Would you need WMI as well?
Posted
The different office ADMX templates and associated group policies don't interfere with each other. Something you set in the 2010 policy won't apply to Office 2016. Would you need WMI as well?

 

Really? I thought it did which is why I was looking at WMI filtering. I suppose it's out of habit when I would create WMI filters from the days of transitioning from XP > 7 > 10.

Posted (edited)
Really?

When you create an Office 2010 (User) GPO, the associated registry entry ends up under...

 

[HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Office\[color="#FF0000"]14.0[/color]]

 

and for Office 2016...

 

[HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Office\[color="#FF0000"]16.0[/color]]

 

@FN-GM is right. The policies for each Office version are independant of each other.

 

Edit. Btw, never use Win32_Product in any WMI filters. :)

Edited by Arthur

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...