Sometimes this works, sometimes it doesn't! I often get:
error "System Events got an error: Can’t get menu 1 of menu bar item 5 of menu bar 1 of application process \"SystemUIServer\". Invalid index." number -1719 from menu 1 of menu bar item 5 of menu bar 1 of application process "SystemUIServer"
Sometimes this works, sometimes it doesn't! I often get:
error "System Events got an error: Can’t get menu 1 of menu bar item 5 of menu bar 1 of application process \"SystemUIServer\". Invalid index." number -1719 from menu 1 of menu bar item 5 of menu bar 1 of application process "SystemUIServer"