Blog Posts by chucksteel

Ask a question

Linking Power BI to the K1000

I have started a series on my blog on using Microsoft Power BI with the K1000 database. I know that there have been others doing similar work and wanted to contribute to the effort.
Be the first to comment

Custom Inventory Rules Querying values in plist files

Problem: 
I am trying to use the PlistValueEquals function in a Custom Inventory Rule to check the value of an item but it won't work properly. I believe the issue is being caused by the value being nested inside of a dictionary. The plist looks like this:
Dict {
RepeatingPowerOn = Dict {
time = 1200
weekdays = 8
eventtype = wakepoweron
}
}

When I try to check the value for time it does not return properly. Even when using PlistValueReturn(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, time, NUMBER) to see what the value is I do not get anything back.

I have also tried PlistValueReturn(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, RepeatingPowerOn, TEXT) and this returns the following:
Dict {
time = 1260
weekdays = 8
eventtype = wakepoweron
} [string]

Note that in the database the value appears as:
'Dict {<br/> time = 1260<br/> weekdays = 8<br/> eventtype = wakepoweron<br/>}'

However, this rule: 
PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, RepeatingPowerOn, TEXT, Dict {<br/> time = 1260<br/> weekdays = 8<br/> eventtype = wakepoweron<br/>})
does not work to identify machines with those settings.

We are trying to detect the power on settings for the machines in our inventory so that we can deploy the settings that we would like to be in place.

Solution: 
By checking the syntax for the PlistBuddy command on macOS I found that you can query keys inside of a dictionary by using colons. The same syntax works for the Plist functions in custom inventory rules. Using that logic, this rule works:
PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, :RepeatingPowerOn:weekdays, NUMBER, 8) and PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, :RepeatingPowerOn:time, NUMBER, 1200) and PlistValueEquals(/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist, :RepeatingPowerOn:eventtype, TEXT, wakepoweron)
Be the first to comment

Creating an Office 2016 package for Mac Deployment

I combined several resources to create our Office 2016 for Mac installer. The steps below outline the process that I followed. The resources I used include the following:

https://github.com/maxschlapfer/MacAdminHelpers/tree/master/Office2016PackageBuilder 

https://github.com/kcrawford/dockutil

https://github.com/talkingmoose/Outlook-Exchange-Setup-5

Things you will need:

* The scripts from the above sites

* A copy of the volume serializer package from the Microsoft Volume Licensing website (Microsoft_Office_2016_VL_Serializer.pkg). This is found inside of the Office 2016 for Mac download.

* The Packages app for creating a combing package. http://s.sudre.free.fr/Software/Packages/about.html

* The post_install script for the package (https://github.com/csteelatgburg/scripts/blob/master/MacOS/Office%202016%20post_install)

* A customized package from the Outlook Exchange setup site above (not covered in this document)

The basic process is as follows:

1. Create a package that installs Office 2016

2. Combine the Office 2016 package with the Outlook Configuration package and the script to update dock items.

3. Place the combined package in a disk image

4. Create the software title on the K1000

5. Create the managed install on the K1000


Creating the Office 2016 Package

1. Create a folder on your computer to create the package. I recommend something like /temp/Office2016

2. In the folder create a folder titled volume_license

3. Place the Microsoft_Office_2016_VL_Serializer.pkg file in the volume_license folder.

4. Open Terminal and change to the folder you created in step 1.

5. Run the Office2016PkgBuilder.sh script. The script will download the required files and create a folder called result.

6. Open the result folder and mount the disk image found there.

7. Copy the Office installer package to the folder you created in Step 1.


Combining the Office Package with the other components

1. Open the Packages app.

2. Create a new package. I recommend saving it in the same folder that you created above in step 1. I named my package Office2016Deployment.

3. On the Settings tab change the identifier to match your organization.

4. Set the version to the Office version that was created by the script above.

5. On the Scripts tab add the following files to the Additional Resources pane

a. Dockutil

b. The Office 2016 package you built above

c. The Outlook Auto configuration package. If you built a new Outlook Auto Configuration package change the name to OutlookAutoConfig.pkg before adding it to the resources.

6. Set the Post-installation script to the post_install script supplied. The post install script performs the following actions:

a. Installs Office 2012

b. Installs the Outlook configuration package

c. Updates the dock for all users

d. Removes Office 2011

7. Save the package

8. Build the package (click Build, Build).


Place the package in a disk image

1. In Terminal change to the directory you created above

2. Packages should have placed the output of the combined installer in a folder named build. Verify that it is there.

3. Use the following command to create a disk image with the package: hdiutil create –format UDZO –src folder build/Office2016Deployment.pkg Office2016.<version>.dmg Where <version> is the version number of Office, e.g. Office2016.15.21.1.dmg If you named your package something other than Office2016Deployment then change the srcfolder option accordingly.


Create the Software Title on the K1000

Unfortunately the K1000 doesn't detect the Microsoft Office Suite for Mac as an installed application because there isn't one .app that is Office. We will create a custom software title that detects the version of Word instead:

1. In the K1000 interface click Software

2. Click Choose Action, New

3. Enter Microsoft Office 2016 for Mac Standard for the name

4. Enter the version number

5. Select the supported operating systems

6. Enter the following for the custom inventory rule: PlistValueEquals(/Applications/Microsoft Word.app/Contents/Info.plist, CFBundleVersion, NUMBER, 15.19.1) Use the correct version number for the package you created.

7. Associate the disk image you created earlier.

8. Save the software title.


Create the Managed Install on the K1000

When KACE sees a disk image as part of a managed install it will mount the image and install and packages contained on the drive. Because we uploaded a disk image to the software title that means we can leave the defaults for the managed install in place.

1. In the K1000 interface click Distribution

2. Click Choose Action, New

3. Select the Office title that you just created from the Software dropdown menu.

4. Enter Office 2016 for Mac – Removes 2011 or something similar for the name.

5. Set the Execution menu to "With user logged off"

6. Select a test device in the Devices section

7. Click Save

View comments (5)

Calculating User Folder Sizes

Our department is evaluating desktop backup solutions and we wanted a good way to estimate how much space would be required to backup all of our users's data. The K1000 reports disk space used on computers but estimating how much of that is user data vs operating system and applications is difficult. In order to get a better estimate I created two custom software inventory rules to calculate the size of C:\Users on Windows and /Users on MacOS:

Windows Rule:
ShellCommandTextReturn(powershell -Command "& {Get-ChildItem C:\Users -recurse -force -ErrorAction "SilentlyContinue" | Measure-Object -property length -sum -maximum -minimum}")
Example output:
Count : 156707
Average : 
Sum : 100229316154
Maximum : 1033927956
Minimum : 0
Property : length

MacOS Rule:
ShellCommandTextReturn(du -hd 0  /Users)
Example output:
8.0G /Users

Here is a SQL report that pulls in this data:
SELECT MACHINE.NAME, 
ROUND(DISK_SIZE, 0) as "Total Disk Available",
ROUND(DISK_USED, 0) as "Total Disk Used",
CASE 
    WHEN MACHINE.OS_NAME like 'Mac%' and MACUS.STR_FIELD_VALUE like "%G%" THEN substring_index(MACUS.STR_FIELD_VALUE, "G", 1)
WHEN MACHINE.OS_NAME like 'Mac%' and MACUS.STR_FIELD_VALUE like "%M%" THEN round(substring_index(MACUS.STR_FIELD_VALUE, "M", 1)/1000,2)
    WHEN MACHINE.OS_NAME like 'Mic%' THEN round(substring_index(substring(WINUS.STR_FIELD_VALUE, LOCATE("Sum      : ", WINUS.STR_FIELD_VALUE)+ 11), "<br/>", 1)/1000000000, 0)
END as `User Folder Size (G)`
 
FROM MACHINE
LEFT JOIN MACHINE_DISKS D on MACHINE.ID = D.ID
LEFT JOIN MACHINE_CUSTOM_INVENTORY WINUS on MACHINE.ID = WINUS.ID and WINUS.SOFTWARE_ID = 85480
LEFT JOIN MACHINE_CUSTOM_INVENTORY MACUS on MACHINE.ID = MACUS.ID AND MACUS.SOFTWARE_ID = 85481
GROUP BY MACHINE.NAME
HAVING `User Folder Size (G)` > 0
ORDER BY MACHINE.NAME
Note that since this uses custom inventory fields the Software IDs will be unique to your environment if you want to replicate this. In my case the IDs are 85480 and 85481, find those values in the SQL code above and replace them with the values from your appliance.



Be the first to comment

Identifying Software Titles for Cleanup

We have been running into low disk space on our appliance and I decided to go through and clean up our software titles. We make heavy use of managed installations in our environment and that means uploading a lot of installers. We don't have a good process in place for going back and deleting old versions of software when we upgrade the MI to the latest version and I'm starting to put that process in place. The first part is creating a report of software titles that don't have a managed install associated with them. This basic report identifies them:
SELECT ID, DISPLAY_NAME, FILE_SIZE,
( SELECT COUNT(MI.ID) FROM MI WHERE MI.SOFTWARE_ID = SOFTWARE.ID) as MICOUNT
FROM SOFTWARE
WHERE SOFTWARE.FILE_SIZE > 0
HAVING MICOUNT = 0
ORDER BY DISPLAY_NAME
This report can be scheduled to run on a recurring basis to remind someone to clean up the software inventory.

You can also create a smart label to identify software titles that can have their attachment deleted. This can make the process much quicker.
  1. In the admin console browse to Inventory, Software
  2. Click Smart Label under the search box
  3. For the search criteria choose File Size > 0
  4. Create a name for the label, I called mine File Cleanup
  5. Click Save
  6. Once the label is created click on the link in the notification to view smart labels or browse to Home, Label Management, Smart Labels
  7. Find the label that you just created
  8. Replace the SQL with the following:
    SELECT DISPLAY_NAME, PUBLISHER, SOFTWARE.ID as TOPIC_ID, (SELECT COUNT(MI.ID) FROM MI WHERE MI.SOFTWARE_ID = SOFTWARE.ID) as MICOUNT FROM SOFTWARE  WHERE ((FILE_SIZE > '0'))  
    HAVING MICOUNT = 0
  9. Save the label
When you go back to the software inventory you will now be able to filter the results using the new label. 


Be the first to comment
Showing 1 - 5 of 15 results

Top Contributors

Talk About KACE 1000