SCCM Application Dependency Graph / Tree

Sometimes we have very complicated apps we have to deploy and need to view the application dependency tree to help investigate failed deployments. I found the built in view in the SCCM console clunky, buggy and annoying. So I wrote a small script to query WMI, list app dependencies and then output this visually using graphviz dot language.

The first thing the script does is query all the apps on your site server WMI for a search term. It then displays a list of applications in a grid view. You then choose which Application you want to create a dependency graph for. Once you have chosen one, the script will recurse through all the dependencies and build a graph.

It’s still in its infancy, it doesn’t highlight AND / OR relations and may have some redundant code that needs tiding up… But I find it useful to demonstrate to support staff why some applications take a while to deploy due to the complexity and amount of pre-reqs required!

  • Install graphviz for windows from here
  • Add an entry in your PATH environment varibale to the location of dot.exe – on Windows 10 for me it was : “C:\Program Files (x86)\Graphviz2.38\bin”
  • Download the script from Github Gist Here
  • Edit the variables in the script
    • $server – should be the management point server with the WMI Provider for your SCCM Site
    • $sitecode – should be the sitecode for your site
    • $graph_filetype – filetype of the output (I’ve only tested png, svg and pdf so far…)
    • $query – should be an application search string, the first thing the script will do is search and list the applications found using this. You can then choose which app you want to see the dependency tree for.
  • Run the script!
  • You should get two output files in the output directory
    • AppName.gv
    • AppName.(pdf/png/svg – depending on selected output filetype)
An example output png from the SCCM App Dependency Graph script.
An example output png from the SCCM App Dependency Graph script.

 

Advertisements

Filter SMSTS.logs to view only the main action steps (using cmtrace)

If you have a long Task Sequence with lots of steps and want to pinpoint when specific actions ran, you can filter the log using Entry Text contains “The action (” in cmtrace.

If some steps are missing you may need to merge in the rolled over logs which are named smsts-xxxxx.log

SMSTS Filter

List Preparation for SQL Query

I often need to query a database using a where in filter and a list of items. The items are generally in a list format in an excel or csv file, once copied they are on different lines. This is how I convert to a usable string for an SQL query filter using Notepad++ :

  • Paste list into Notepad++
  • Open the Find and Replace dialog (Ctrl+F)
  • Change search mode to ‘Extended’
  • Find what : \r\n
  • Replace with : ‘,’
  • Add an quote mark at beginning and end of line
Screenshot of Find and Replace dialog in Notepad++

Then you can paste this string into a SQL ‘where in’ clause between the brackets.

Checking SCCM Task Sequence Variables using Powershell

While running an OSD task sequence you can use powershell to check the TS Environment variables.

I added a ‘Pause’ step using this guide. If, like me, you are using an x64 PE image, you need use the ‘serviceui.exe’ from either the Program Files location on the machine with MDT installed, or a MDT package :

%MDTInstallLocation%\Templates\Distribution\Tools\x64\
%MDTPackage%\Tools\x64\

Once you have your Task Sequence paused, you can press F8 (if enabled in the boot image) and start powershell.

$env = New-Object -COMObject Microsoft.SMS.TSEnvironment

This will create an interface to the com object we need to use to interact with the TS environment.

$env.GetVariables() | % {$_ + "=" + $env.Value($_)}

This will dump out all the variables to the screen, this is a bit messy as there are lots of variables – some with quite long xml text as the values.

This will output all the variables to a text file :

 
$env.GetVariables() | % {$_ + "=" + $env.Value($_)} | out-file "variables.txt"

This will display the value of a specific variable (e.g. Architecture):

 
$env.Value("Architecture")

You could adapt this into a script to run automatically, instead of manually if required.

SMBIOS Chassis Type Table

Table I use for reporting on ratio of Desktop / Laptops using Chassis Types. Derived from the DMTF SMBIOS Spec November 2016 : http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.0.pdf

Hex Value Dec Value Meaning Laptop-Desktop-Other
1 1 Other Other
2 2 Unknown Other
3 3 Desktop Desktop
4 4 Low Profile Desktop Desktop
5 5 Pizza Box Desktop
6 6 Mini Tower Desktop
7 7 Tower Desktop
8 8 Portable Laptop
9 9 Laptop Laptop
A 10 Notebook Laptop
B 11 Hand Held Laptop
C 12 Docking Station Other
D 13 All In One Desktop
E 14 Sub Notebook Laptop
F 15 Space-saving Desktop
10 16 Lunch Box Desktop
11 17 Main Server Chassis Other
12 18 Expansion Chassis Other
13 19 SubChassis Other
14 20 Bus Expansion Chassis Other
15 21 Peripheral Chassis Other
16 22 RAID Chassis Other
17 23 Rack Mount Chassis Other
18 24 Sealed-case PC Desktop
19 25 Multi-system chassis Other
1A 26 Compact PCI Other
1B 27 Advanced TCA Other
1C 28 Blade Other
1D 29 Blade Enclosure Other
1E 30 Tablet Laptop
1F 31 Convertible Laptop
20 32 Detachable Laptop
21 33 IoT Gateway Other
22 34 Embedded PC Desktop
23 35 Mini PC Desktop
24 36 Stick PC Desktop

Creating Offline Repositories for CentOS / RHEL – Part 1

I’ve started doing more and more with linux, I wanted a way to store updates and packages offline – in the same way we do for Windows using WSUS and SCCM etc… This is how to host offline repositories, it may not be the most secure method – but is aimed at LAN hosting where you trust the LAN members!

  • Set up a server to host the RPM content, I used CentOS 7.
  • Install a web server service, I used nginx – my base path is /var/www/html
  • Create a folder for the repo you want to host – in this example I’m going to use “base”
  • Use reposync to download the RPM’s
    • reposync -p /var/www/html -r base -l
  • Create a repo
    • createrepo /var/www/html/base
  • Update the repo after a reposync
    • createrepo –update /var/www/html/base

You can now amend your yum config files on clients to use this repo, I will post another entry sometime with more information on how to automatically update the repo.

Oh-My-Zsh Agnoster Theme Windows 10 Client

I wanted to try out Oh-My-Zsh, I needed to set up a new CentOS box to run some stuff and decided now was the time give it a go.

It was easy to get working on the server side, but to get the rendering right on Windows client took a bit of work!

  • Install git, curl and zsh
  • Install oh-my-zsh using the curl commandline from here.

This went fine and worked as expected (I was connected via mobaxterm from Windows 10) But I wanted something a bit more fancy, so I edited the file ~/.zshrc and changed the theme to “agnoster”. As stated on the themes page, I needed to install some patched fonts to get the nice icons – this is where it got tricky. I followed the powerline instructions and installed the fonts on the CentOS box, but this didn’t work. Then I installed some of the fonts in Windows and switched the MobaXTerm font to one of these – didnt work.

It turns out that some of the powerline fonts work better in Windows than others. I messed around trying to get some of the fonts working in MobaXTerm, then I gave up and tried in Putty. The one I found which worked was DejaVu Sans Mono – thanks to this blog.

I had only just started using MobaXTerm, and quite liked it – but as I couldn’t get this working, I’ll probably go back to just using Putty Tray (a putty fork, i like!)

I found this page – which has instructions of enabling the nice Solarized theme in Putty-Tray 🙂

More External Themes to try : https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes