Determining installed packages on Solaris 11

If we need to determine which packages have been added to a solaris 11 machine, say because someone is asking for documentation, or you need to build a similar machine/zone, we can use the pkg command's built in history function:

Show everything, from all time:

# pkg history -l

Show which base group is installed (small-server, large-server or desktop groups)

# pkg list group/system* NAME (PUBLISHER)                                  VERSION                    IFO 
group/system/solaris-small-server                 0.5.11-  i--

Show just install operations:

# pkg history -Ho start,command | grep "pkg install" (long output removed) 

Now verify these are all still installed (the inverse grep removes the zone install time operations)

# pkg list -Hs pkg history -Ho command |grep install |sed s/.*install//  | grep -v -- -z  
developer/build/ant                                     Apache Ant 
developer/build/make                                    A utility for managing compilations. 
diagnostic/top                                          provides a rolling display of top cpu using processes 
editor/nano                                             A small text editor 
terminal/xterm                                          xterm - terminal emulator for X 
x11/diagnostic/x11-info-clients                         X Window System diagnostic and information display clients 
x11/library/libxp                                       libXp - X Print Client Library 
x11/session/xauth                                       xauth - X authority file utility 
x11/xclock                                              xclock - analog / digital clock for X

Then store this in your documentation, or pipe it to awk '{print $1}', or whatever tool of choice to grab the first column.