Exporting Information From iPhone Configuration Utility(from http://krypted.com)
2012-05-21 09:47
579 查看
In a previous post I looked at
automatingiPhone and iPad deployment. There, we looked at the iPhoneConfiguration Utility. Now that Profile Manager is built into MacOS X Server in Lion, and with the number of 3rd party MDM solutionson the market, many users of iPhone Configuration Utility
arelooking to extract information from it and move it into otherplaces. Many of these places can import property lists.
If you look at the file header for .mobileconfig and .deviceinfofiles you’ll notice that they begin with the familiar:
Given that .mobileconfig and .deviceinfo files are propertylists with different extensions, if you want to turn them intoproperty lists, simply rename them. Given that many people willhave 100s or 1000s of devices, this is something that most willwant to
automate. So, let’s use a basic for loop to do so. Thefollowing will convert .mobileconfig files into plist:
This will put them back:
Or to convert the device information to property lists:
Or property lists to device information:
Once files are converted then you can also automate crawlingthrough them to obtain information. For example, to pull theinformation from the two fields in iPhone Configuration Utilitythat are user editable, ownerName and ownerEmail as well as theserial number
of a device with a deviceIdentifierof 26c2d1b2a68c7862bd4c6bfbe708517964733cf3:
You could then redirect this output into a csv file, perhapsgrabbing other information such as:
UniqueChipID
deviceActivationState
deviceBluetoothMACAddress
deviceBuildVersion
deviceCapacityKey
deviceClass
deviceIdentifier (also the basename of the file)
deviceLastConnected
deviceName
deviceProductVersion
deviceType
deviceWiFiMACAddress
And then there are 3 arrays that wouldn’t likely look great in acsv, but could easily be brought out automatically:
provisioningProfiles: useful if you are duplicatingprovisioning profile information into an mdm solution
configurationProfiles: useful if you are duplicatingconfiguration profile information from devices into an mdmsolution
applicationDictionaries: great for pulling off what apps arewhere
You can get all of this without moving the files to plist aswell, but in this example I am making an assumption that you willbe importing these devices via plist and so you would be convertingthem anyway. The ability to dump information into a csv forreporting
or other types of imports is ancillary. Having said this,I’ve taken it all and wrapped it into a shell script:
This script (which should have a bit more logic put into it fordefining things, etc) should convert all of your .deviceinfo filesto property list while building a csv of their contents (minus thearrays, which I didn’t think prudent to put into csv but whichcould
be thrown in there pretty easily) in ~/mydevices.csv (or mydevices.csv in your home directory). ProfileManager can definitelyimport device holders, which you should be able to do with a coupleof columns of this output…
And to undo the conversion to plist (if you didn’t actually meanto do that part):
automatingiPhone and iPad deployment. There, we looked at the iPhoneConfiguration Utility. Now that Profile Manager is built into MacOS X Server in Lion, and with the number of 3rd party MDM solutionson the market, many users of iPhone Configuration Utility
arelooking to extract information from it and move it into otherplaces. Many of these places can import property lists.
If you look at the file header for .mobileconfig and .deviceinfofiles you’ll notice that they begin with the familiar:
<?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"> <plistversion="1.0"><dict>
Given that .mobileconfig and .deviceinfo files are propertylists with different extensions, if you want to turn them intoproperty lists, simply rename them. Given that many people willhave 100s or 1000s of devices, this is something that most willwant to
automate. So, let’s use a basic for loop to do so. Thefollowing will convert .mobileconfig files into plist:
for x in ~/Library/MobileDevice/Configuration\Profiles/*.mobileconfig; do mv $x `basename $x.mobileconfig`.plist; done;
This will put them back:
for xin ~/Library/MobileDevice/Configuration\Profiles/*.plist; do mv $x `basename $x .plist`.mobileconfig;done;
Or to convert the device information to property lists:
for x in ~/Library/MobileDevice/Devices/*.deviceinfo; domv $x `basename $x .deviceinfo`.plist; done;
Or property lists to device information:
for x in ~/Library/MobileDevice/Devices/*.plist; do mv $x`basename $x .plist`.deviceinfo; done;
Once files are converted then you can also automate crawlingthrough them to obtain information. For example, to pull theinformation from the two fields in iPhone Configuration Utilitythat are user editable, ownerName and ownerEmail as well as theserial number
of a device with a deviceIdentifierof 26c2d1b2a68c7862bd4c6bfbe708517964733cf3:
defaults read~/Library/MobileDevice/Devices/26c2d1b2a68c7862bd4c6bfbe708517964733cf3ownerEmail
defaults read~/Library/MobileDevice/Devices/26c2d1b2a68c7862bd4c6bfbe708517964733cf3ownerName
You could then redirect this output into a csv file, perhapsgrabbing other information such as:
UniqueChipID
deviceActivationState
deviceBluetoothMACAddress
deviceBuildVersion
deviceCapacityKey
deviceClass
deviceIdentifier (also the basename of the file)
deviceLastConnected
deviceName
deviceProductVersion
deviceType
deviceWiFiMACAddress
And then there are 3 arrays that wouldn’t likely look great in acsv, but could easily be brought out automatically:
provisioningProfiles: useful if you are duplicatingprovisioning profile information into an mdm solution
configurationProfiles: useful if you are duplicatingconfiguration profile information from devices into an mdmsolution
applicationDictionaries: great for pulling off what apps arewhere
You can get all of this without moving the files to plist aswell, but in this example I am making an assumption that you willbe importing these devices via plist and so you would be convertingthem anyway. The ability to dump information into a csv forreporting
or other types of imports is ancillary. Having said this,I’ve taken it all and wrapped it into a shell script:
echodeviceIdentifier,deviceSerialNumber,ownerName,ownerEmail,UniqueChipID,deviceActivationState,deviceBluetoothMACAddress,deviceBuildVersion,deviceCapacityKey,deviceClass,deviceLastConnected,deviceName,deviceProductVersion,deviceWiFiMACAddress,deviceType> ~/mydevices.csv for deviceID in *.deviceinfo; do mv "$deviceID" "`basename"$deviceID" .deviceinfo`.plist"; deviceID=${deviceID%.deviceinfo} deviceserialnumber=`defaults read~/Library/MobileDevice/Devices/$deviceID deviceSerialNumber` ownerName=`defaults read ~/Library/MobileDevice/Devices/$deviceIDownerName` ownerEmail=`defaults read ~/Library/MobileDevice/Devices/$deviceIDownerEmail` UniqueChipID=`defaults read~/Library/MobileDevice/Devices/$deviceID UniqueChipID` deviceActivationState=`defaults read~/Library/MobileDevice/Devices/$deviceIDdeviceActivationState` deviceBluetoothMACAddress=`defaults read~/Library/MobileDevice/Devices/$deviceIDdeviceBluetoothMACAddress` deviceBuildVersion=`defaults read~/Library/MobileDevice/Devices/$deviceID deviceBuildVersion` deviceCapacityKey=`defaults read~/Library/MobileDevice/Devices/$deviceID deviceCapacityKey` deviceClass=`defaults read ~/Library/MobileDevice/Devices/$deviceIDdeviceClass` deviceLastConnected=`defaults read~/Library/MobileDevice/Devices/$deviceID deviceLastConnected` deviceName=`defaults read ~/Library/MobileDevice/Devices/$deviceIDdeviceName` deviceProductVersion=`defaults read~/Library/MobileDevice/Devices/$deviceIDdeviceProductVersion` deviceType=`defaults read ~/Library/MobileDevice/Devices/$deviceIDdeviceType` deviceWiFiMACAddress=`defaults read~/Library/MobileDevice/Devices/$deviceIDdeviceWiFiMACAddress` echo$deviceID,$deviceserialnumber,$ownerName,$ownerEmail,$UniqueChipID,$deviceActivationState,$deviceBluetoothMACAddress,$deviceBuildVersion,$deviceCapacityKey,$deviceClass,$deviceLastConnected,$deviceName,$deviceProductVersion,$deviceWiFiMACAddress,$deviceType>> ~/mydevices.csv done;
This script (which should have a bit more logic put into it fordefining things, etc) should convert all of your .deviceinfo filesto property list while building a csv of their contents (minus thearrays, which I didn’t think prudent to put into csv but whichcould
be thrown in there pretty easily) in ~/mydevices.csv (or mydevices.csv in your home directory). ProfileManager can definitelyimport device holders, which you should be able to do with a coupleof columns of this output…
And to undo the conversion to plist (if you didn’t actually meanto do that part):
for x in ~/Library/MobileDevice/Devices/*.plist; do mv $x`basename $x .plist`.deviceinfo; done;
相关文章推荐
- Automating iPhone & iPad Deployment(from http://www.krypted.com)
- PreparedStatement 预编译原理 (From@_@http://choelea.javaeye.com)
- Android报错:JNI/NDK相关"Download the NDK from http://developer.android.com/tools/sdk/ndk/."
- A nice gift from SQL Server 2005 SP2 to sync developers(转自http://blogs.msdn.com/synchronizer/default.aspx)
- C#高级编程:信道-from(http://www.tzwhx.com/newOperate/html/1/12/124/10365.html)
- A secure connection is requiered(such as ssl). More information at http://service.mail.qq.com/cgi-bi
- http://www.cnblogs.com/fromchaos/archive/2009/11/29/1613313.html
- Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. T
- Silverlight & Blend动画设计系列三:缩放动画(ScaleTransform) from http://www.cnblogs.com/beniao/archive/2010/03/26/1694157.html
- c#正则表达式 总结 from http://www.cnblogs.com/maxianghui/
- Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. T
- Getting Started Spidering a Site使用Chilkat(python)练习的一个爬虫(from :http://www.example-code.com)
- AIO from http://www.ibm.com/developerworks/cn/linux/l-async/
- ArtifactTransferException: Failure to transfer com.sun.xml.bind:jaxb-xjc:jar:2.0.1 from http://192.1
- CBitMap的用法 from http://www.cnblogs.com/toconnection/archive/2012/08/04/mfc.html
- GDI+中发生一般性错误的解决办法 from http://www.cnblogs.com/winzheng/archive/2008/12/23/1360440.html
- NAL UNIT type ---from http://blog.sina.com.cn/s/blog_465bdf0b010002t1.html
- 一个产品经理的自我总结:我常犯的一些毛病(from http://forum.eet-cn.com)
- Linux 高精確的時序(sleep, usleep,nanosleep) from:http://blog.sina.com.cn/s/blog_533ab41c0100htae.html