Hello fellow Ninjas!
DISCLAIMER: I did not create this entire solution myself. I used bits and pieces from around the net and with a high level of determination and significant testing I have found a viable solution. The reason for this blog is I couldn't find a complete step-by-step solution.
Currently the K1000 doesn't inventory the local display configuration in the Device Inventory page. Meaning there is no way to know what, how many monitors are connected to a users computer, or their position. However, PowerShell is just the tool we need to accomplish this task!
First step: In your favorite PowerShell editor (such as Notepad++) create a PowerShell script with the following code:
del C:\ProgramData\Dell\KACE\user\MonitorList.txt
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Screen]::AllScreens | out-file -Encoding "ASCII" C:\ProgramData\Dell\KACE\user\MonitorList.txt
Add-Content C:\ProgramData\Dell\KACE\user\MonitorList.txt "Last Sync:"
$A = Get-Date; Add-Content C:\ProgramData\Dell\KACE\user\MonitorList.txt $A
Here is the overview of what is happening.
First delete MonitorList.txt at a given location
Then create a variable relating to display information
Then output all display information to a file MonitorList.txt at a given location
Then append MonitorList.txt with Last Sync:
Then append MonitorList.txt with a timestamp.
I wanted to include a timestamp in the .txt file so that when this gets inventoried in our CIR rule (discussed below) we know the last time this was executed.
Then create a new script with the following settings:
Make sure to upload your PowerShell script! I named mine: MonitorConfiguration.ps1
Not sure if you can see everything, but here is the important information.
Windows Run As MUST be set to Logged-in User.
The only step should be to run a batch script with the following code:
powershell.exe powershell.exe -ExecutionPolicy Bypass -File "C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\413\MonitorConfiguration.ps1"
The 413 will need to be replaced with your ID# for the given file. I followed Dell's guide on how to launch a PowerShell script via this link: https://support.software.dell.com/kb/148903
What the end result is something that looks like this:
Now that we have a script that creates a .txt file with all of our display information we need to create a Custom Inventory Rule to read that file and included it in Device Inventory.
Now head over to Inventory -> Software in your K1000 and create a new entry with the following information:
The Custom Inventory Rule code should be:
ShellCommandTextReturn(cmd /c type C:\ProgramData\Dell\KACE\user\MonitorList.txt)
So now that we have everything setup here are some things I wanted to discuss with you. I suggest scheduling the script to run either weekly or monthly as users' display configurations usually don't change and we don't need to bog down the K1000 running it at a shorter interval. Now there is one caveat to all of this. Caveat is that this only captures the list of available displays for the current logged-in user when the script is executed. If only a single user logs onto computer then this wont be an issue. However, if you have multiple users sharing a computer who have different display configurations then you will need to alter my solution to have the script execute against all users who have logged onto the computer (not sure how nor if it would be possible).
I wish all you ninjas luck out there and let me know if you have any questions!
Comments