@bpavlov Sorry, I'm no longer in Mac Administration. I haven't tested/debug this since the beginning of this year.
@justinrummel Thanks for responding! Just read your blog post on that. Hope the new job is treating you well. I did manage to copy your profile and it works so it gives me something further to look at now.
After a little bit of testing it seems the difference that allows both ShowStatus and ShowTime to work is in the frequency. If you set it to ONCE rather than ALWAYs, it works fine. Weird, I know. I also found you can take out some pieces out of the com.apple.systemuiserver.plist
com.apple.networkConnect.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>VPNShowStatus</key>
<true/>
<key>VPNShowTime</key>
<true/>
</dict>
</plist>
com.apple.systemuiserver.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>menuExtras</key>
<array>
<string>/System/Library/CoreServices/Menu Extras/VPN.menu</string>
</array>
</dict>
</plist>
Profile:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.networkConnect</key>
<dict>
<key>Set-Once</key>
<array>
<dict>
<key>mcx_data_timestamp</key>
<date>2015-08-06T21:33:07Z</date>
<key>mcx_preference_settings</key>
<dict>
<key>VPNShowStatus</key>
<true/>
<key>VPNShowTime</key>
<true/>
</dict>
</dict>
</array>
</dict>
</dict>
<key>PayloadEnabled</key>
<true/>
<key>PayloadIdentifier</key>
<string>MCXToProfile.72daecd7-dac9-4bdb-b62a-a3e2d4b9523f.alacarte.customsettings.afb7ef3c-580a-416e-baa6-78493ff9e507</string>
<key>PayloadType</key>
<string>com.apple.ManagedClient.preferences</string>
<key>PayloadUUID</key>
<string>afb7ef3c-580a-416e-baa6-78493ff9e507</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.systemuiserver</key>
<dict>
<key>Set-Once</key>
<array>
<dict>
<key>mcx_data_timestamp</key>
<date>2015-08-06T21:33:07Z</date>
<key>mcx_preference_settings</key>
<dict>
<key>menuExtras</key>
<array>
<string>/System/Library/CoreServices/Menu Extras/VPN.menu</string>
</array>
</dict>
</dict>
</array>
</dict>
</dict>
<key>PayloadEnabled</key>
<true/>
<key>PayloadIdentifier</key>
<string>MCXToProfile.72daecd7-dac9-4bdb-b62a-a3e2d4b9523f.alacarte.customsettings.7da2b7cd-1d11-4442-a059-4c8f56cd602a</string>
<key>PayloadType</key>
<string>com.apple.ManagedClient.preferences</string>
<key>PayloadUUID</key>
<string>7da2b7cd-1d11-4442-a059-4c8f56cd602a</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</array>
<key>PayloadDescription</key>
<string>Included custom settings:
com.apple.networkConnect
com.apple.systemuiserver
</string>
<key>PayloadDisplayName</key>
<string>Company - OS X VPN Menu</string>
<key>PayloadIdentifier</key>
<string>OS X VPN Menu</string>
<key>PayloadOrganization</key>
<string>Company</string>
<key>PayloadRemovalDisallowed</key>
<true/>
<key>PayloadScope</key>
<string>System</string>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>72daecd7-dac9-4bdb-b62a-a3e2d4b9523f</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist>
Very interesting results to say the least. It seems that in certain cases ONCE will do what you need it to do instead of trying to force it ALWAYS.
Hi all,
I have added the following syntax to a script
defaults write com.apple.systemuiserver menuExtras -array-add "/System/Library/CoreServices/Menu Extras/vpn.menu"
killall SystemUIServer -HUP
In testing I can see if empties and then repopulates the menu bar but without the VPN icon.
If I manually run the /System/Library/CoreServices/Menu Extras/vpn.menu file from the macbook it will add but I cannot for the life of me automate this process.
Anyone have any suggestions?
Thanks,
Matt
@mjohnston Seeing the same issue here. :/
Worked great with mcxToProfile :D
Sorry to revive this ancient topic, but has anyone gotten this to work with 10.11? I tried @justinrummel's mobileconfig, but nada. =/
I've done this in two different ways. First, I'll just say that it did take me quite a bit of research last year. In these solutions, I'm going to skip talking about the profile and only talk about the menu extra item. Suffice to say that I am manually downloading a .mobileconfig to the /tmp directory and then applying it. Early in the process I tried the following:
#!/bin/sh
#!/bin/bash
loggedInUser=$(ls -l /dev/console | awk '{print $3}')
## Loads the Staff VPN profile
/usr/bin/profiles -I -F /private/tmp/VPN.mobileconfig
defaults write /Users/$loggedInUser/Library/Preferences/com.apple.systemuiserver menuExtras -array-add "/System/Library/CoreServices/Menu Extras/vpn.menu"
## Fix the permissions
chown "$loggedInUser" "/Users/$loggedInUser/Library/Preferences/com.apple.systemuiserver.plist"
killall SystemUIServer -HUP
exit 0
Unfortunately, the process did not reliably get the actual VPN menu extra to appear immediately and reliably. A restart of the system fixed this, but I figured that it wasn't a good way to go. Also, in tests a user could inadvertently cause multiple VPN menu items to appear by repeatedly applying the policy. So, with that attempt under my belt, and a lot more research (i.e. borrowing) of things I found here on the 'Nation', I came up with the following after having decided that I wanted to take a look at everything that I wanted in the menu bar:
#!/bin/sh
#!/bin/bash
## Loads the Student VPN profile
/usr/bin/profiles -I -F /private/tmp/VPN.mobileconfig
PreferredMenuExtras=(
"/System/Library/CoreServices/Menu Extras/AirPort.menu"
"/System/Library/CoreServices/Menu Extras/Battery.menu"
"/System/Library/CoreServices/Menu Extras/Bluetooth.menu"
"/System/Library/CoreServices/Menu Extras/Clock.menu"
"/System/Library/CoreServices/Menu Extras/VPN.menu"
)
currentUser=$( ls -l /dev/console | awk '{print $3}' )
userHome=$( dscl . read /Users/$currentUser NFSHomeDirectory | awk '{print $NF}' )
MenuExtras=$( defaults read "$userHome/Library/Preferences/com.apple.systemuiserver.plist" menuExtras | awk -F'"' '{print $2}' )
for menuExtra in "${PreferredMenuExtras[@]}"; do
menuShortName=$( echo "${menuExtra}" | awk -F'/' '{print $NF}' )
if [[ $( echo "${MenuExtras}" | grep "${menuExtra}" ) ]]; then
echo "Menu Extra "${menuShortName}" present"
else
echo "Menu Extra "${menuShortName}" not in plist. Opening..."
open "${menuExtra}"
fi
done
exit 0
Someone could probably point out what I missed on the first attempt, but it works and it works well. Additionally, I apologize for my inconsistency in variable naming conventions.
@staze
I use the following single line script which will enable VPN status in menu bar regardless of weather or not you have a VPN configuration.
open "/System/Library/CoreServices/Menu Extras/vpn.menu"
I have this script run via policy, once per day on all laptops.
My VPN connections are pushes as a Config Profile.
This method has worked flawlessly across 10.10 and 10.11
@mjohnston ... well that was simple. I like it!
Hi...has anyone succeed into showing VPN in the menu bar with menuconfig? I am following the suggestions for the xml file, and it is not working.
@mjohnston Awesome! This worked great for me.
@mjohnston works well with Mojave and Sierra. Only other item that would be beneficial is to set "Show Time Connected" using a script as well. This is a great visual to show people if they are or not connected to the VPN.
@steve.summarell I found the preference for Show Time Connected. And I was able to change it once via terminal on Mojave but could not replicate it again even on another machine.
This will show you the value for VPNShowTime
defaults read com.apple.networkconnect
I have tried changing this value several times and while I can get the value to change ( defaults write com.apple.networkconnect VPNShowTime 1 ), it doesn't seem to actually take effect. Maybe someone else has an idea of why.
EDIT:
Figured out it was because the c in com.apple.networkconnect was not capitalized. It works if you capitalize it.
defaults write com.apple.networkConnect VPNShowTime 1; killall SystemUIServer
It only appears to work locally for some reason though and not as a policy.
Hello JAMF Nation,
Has anyone actually been able to get this working?
I tried
open "/System/Library/CoreServices/Menu Extras/vpn.menu"
It was pushed via Policy and get an Error. However when I run the command via terminal it works as intended.
Has anyone come up with a better solution on this piece?
Thanks all.
@CorpIT_eB I use a config profile to add the VPN menu icon, it's an MCX profile so the user won't see any change take effect until a logout or restart. I have a few other menu extras in this profile, but you can edit that out to just have the VPN icon.
@sshort Forgive my ignorance I am very new to being a JAMF Admin where would this MCX profile go?
In Other words I take your XML script there edit it for just VPN then where would I upload it for testing I am unfamiliar with .plists and XML conversions to profiles.
Total NOOB here so steps would be crucial in my learning processes.
Thanks Again.
@CorpIT_eB copy and paste that into your preferred text editor (and take out other menu items you don't want to control) then save the document with a .mobileconfig
file extension. Check out this post on signing profiles, then upload to Jamf.

So not sure if anyone has noticed but this plist at least in my environment macOS 10.14.6 is no longer adding the icon to the menu bar. It still runs ok and adds the configuration itself but it's not adding the Icons to the menu bar any longer. Does anyone know if they have changed the switches for these checkboxes?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadContent</key>
<dict>
<key>com.apple.systemuiserver</key>
<dict>
<key>Set-Once</key>
<array>
<dict>
<key>mcx_preference_settings</key>
<dict>
<key>NSStatusItem Visible Siri</key>
<false/>
<key>NSStatusItem Visible com.apple.menuextra.airplay</key>
<true/>
<key>NSStatusItem Visible com.apple.menuextra.volume</key>
<true/>
<key>NSStatusItem Visible com.apple.menuextra.vpn</key>
<true/>
<key>__NSEnableTSMDocumentWindowLevel</key>
<true/>
<key>menuExtras</key>
<array>
<string>/System/Library/CoreServices/Menu Extras/Battery.menu</string>
<string>/System/Library/CoreServices/Menu Extras/AirPort.menu</string>
<string>/System/Library/CoreServices/Menu Extras/Volume.menu</string>
<string>/System/Library/CoreServices/Menu Extras/Displays.menu</string>
<string>/System/Library/CoreServices/Menu Extras/VPN.menu</string>
</array>
</dict>
</dict>
</array>
</dict>
</dict>
<key>PayloadDisplayName</key>
<string>Custom: (com.apple.systemuiserver)</string>
<key>PayloadEnabled</key>
<true/>
<key>PayloadIdentifier</key>
<string>com.apple.mdm.macserver-imac.local.e619bbc0-3444-0136-d464-2c87a33a6849.alacarte.customsettings.04410560-3445-0136-d466-2c87a33a6849</string>
<key>PayloadType</key>
<string>com.apple.ManagedClient.preferences</string>
<key>PayloadUUID</key>
<string>04410560-3445-0136-d466-2c87a33a6849</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</array>
<key>PayloadDescription</key>
<string>Add shortcuts to the menu bar</string>
<key>PayloadDisplayName</key>
<string>Settings for menubar_icons</string>
<key>PayloadEnabled</key>
<true/>
<key>PayloadIdentifier</key>
<string>com.apple.mdm.macserver-imac.local.e619bbc0-3444-0136-d464-2c87a33a6849.alacarte</string>
<key>PayloadOrganization</key>
<string>CompanyName</string>
<key>PayloadRemovalDisallowed</key>
<false/>
<key>PayloadScope</key>
<string>System</string>
<key>PayloadType</key>
<string>Configuration</string>
<key>PayloadUUID</key>
<string>e619bbc0-3444-0136-d464-2c87a33a6849</string>
<key>PayloadVersion</key>
<integer>1</integer>
</dict>
</plist>
After deploying the actual VPN configuration, try running this in a script or under Files & Processes:
user=$(stat -f %Su /dev/console); sudo -u $user open "/System/Library/CoreServices/Menu Extras/vpn.menu"
Still works on 10.14, haven't tested on Catalina yet.
@pete_c That definitely works in Catalina.
@pete_c If I wanted to add more icon could you pipe in other icons like Volume, and Battery Percentage?
hello everyone, I would like to create this policy to automatically show the VPN icon to the menubar.
@pete_c command works perfectly by pasting in the terminal, BUT, it seems I cannot configure correctly the script in JAMF platform.
I have attached the trigger settings, but even trying with other options (login/startup, etc) it is not applied.
any hint?
ty vm!
