Admin Device Management

デバイスUUIDの取得


サンプルコード

サンプルソース(参考)
行番号ソース
001
002
003set strCommandText to ("/usr/sbin/ioreg -c IOPlatformExpertDevice") as text
004log ("実行したコマンド\r" & strCommandText & "\r") as text
005set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"  | grep IOPlatformUUID | awk -F'\\\"' '{print $4}'") as text
006try
007  set strResponse to (do shell script strExecCommand) as text
008on error
009  log "zshでエラーになりました\r" & strCommandText & "\r"
010end try
AppleScriptで生成しました

|

モデル名を取得する

20240517034654962x229
あくまでも参考にしてください

【スクリプトエディタで開く】 |

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#com.cocolog-nifty.quicktimer.icefloe
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "AppKit"
009use scripting additions
010property refMe : a reference to current application
011
012##############################
013#####model_name取得
014##############################
015set strCommandText to "/usr/sbin/sysctl -n hw.model" as text
016set strHWmodelName to (do shell script strCommandText) as text
017
018##############################
019#####本処理
020##############################
021###【1】URL
022set ocidComponents to refMe's NSURLComponents's alloc()'s init()
023ocidComponents's setScheme:("https")
024ocidComponents's setHost:("hw-model-names.services.jamfcloud.com")
025ocidComponents's setPath:("/1/computerModels.xml")
026set ocidURL to ocidComponents's |URL|
027
028### 【2】NSDATA
029set ocidOption to (refMe's NSDataReadingMappedIfSafe)
030set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidURL) options:(ocidOption) |error| :(reference)
031if (item 2 of listResponse) = (missing value) then
032  log "正常処理"
033  set ocidReadData to (item 1 of listResponse)
034else if (item 2 of listResponse) ≠ (missing value) then
035  log (item 2 of listResponse)'s code() as text
036  log (item 2 of listResponse)'s localizedDescription() as text
037  return "XML エラーしました"
038end if
039
040### 【3】XMLDOCにして
041set ocidOption to (refMe's NSXMLNodePreserveAll) + (refMe's NSXMLDocumentTidyXML)
042set listResponse to refMe's NSXMLDocument's alloc()'s initWithData:(ocidReadData) options:(ocidOption) |error| :(reference)
043if (item 2 of listResponse) = (missing value) then
044  log "正常処理"
045else if (item 2 of listResponse) ≠ (missing value) then
046  log (item 2 of listResponse)'s code() as text
047  log (item 2 of listResponse)'s localizedDescription() as text
048  log "NSXMLDocumentエラー 警告がありました"
049end if
050set ocidXMLDoc to (item 1 of listResponse)
051
052### 【4】computer_model
053set ocidRoot to ocidXMLDoc's rootDocument()
054set listResponse to (ocidRoot's nodesForXPath:("//computer_model") |error| :(reference))
055if (item 2 of listResponse) = (missing value) then
056  log "正常処理"
057else if (item 2 of listResponse) ≠ (missing value) then
058  log (item 2 of listResponse)'s code() as text
059  log (item 2 of listResponse)'s localizedDescription() as text
060  log "nodesForXPathエラー 警告がありました"
061end if
062set ocidComputerModelArray to (item 1 of listResponse)
063
064###【5】Array to Dict
065set ocidModelNameDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
066##Array =エレメントの数
067set numCntArray to ocidComputerModelArray's |count|()
068##エレメントの数だけ繰り返し
069repeat with itemNo from 0 to (numCntArray - 1) by 1
070  set ociidItemArray to (ocidComputerModelArray's objectAtIndex:(itemNo))
071  set ocidModelName to (ociidItemArray's elementsForName:("model_name"))'s firstObject()
072  set ocidDisplayName to (ociidItemArray's elementsForName:("display_name"))'s firstObject()
073  (ocidModelNameDict's setObject:(ocidDisplayName's stringValue()) forKey:(ocidModelName's stringValue()))
074end repeat
075
076set strDisplayName to ocidModelNameDict's valueForKey:((strHWmodelName) as text)
077
078set strMes to ("戻り値\n") as text
079set strMes to strMes & ("モデル名: " & strHWmodelName & "\n") as text
080set strMes to strMes & ("表示名: " & strDisplayName & "") as text
081
082##############################
083#####ダイアログ
084##############################
085##前面に出す
086set strName to (name of current application) as text
087if strName is "osascript" then
088  tell application "Finder" to activate
089else
090  tell current application to activate
091end if
092###アイコンパス
093set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns" as alias
094
095set recordResult to (display dialog strMes with title "戻り値です" default answer strMes buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer)
096###自分自身を再実行
097if button returned of recordResult is "再実行" then
098  tell application "Finder"
099    set aliasPathToMe to (path to me) as alias
100  end tell
101  run script aliasPathToMe
102end if
103
104###クリップボードコピー
105if button returned of recordResult is "IPアドレスをクリップボードにコピー" then
106  set strText to (text returned of recordResult) as text
107  try
108    ####ペーストボード宣言
109    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
110    set ocidText to (refMe's NSString's stringWithString:(strIP))
111    appPasteboard's clearContents()
112    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
113  on error
114    tell application "Finder"
115      set the clipboard to strIP as text
116    end tell
117  end try
118end if
119
AppleScriptで生成しました

|

TB Default Item Identifiers(com.apple.finder.plist)

昔からあって専用のアイコンが用意されているのは4つ(他にもあるかも?ですが) Screen_2

<key>TB Default Item Identifiers</key>
<array>
戻る/進む <string>com.apple.finder.BACK</string>
ビュー <string>com.apple.finder.SWCH</string>
個別 <string>com.apple.finder.loc </string>
情報 <string>com.apple.finder.INFO</string>
ゴミ箱 <string>com.apple.finder.TRSH</string>
検索 <string>com.apple.finder.SRCH</string>
新規フォルダ <string>com.apple.finder.NFLD</string>
プロパティパネル <string>com.apple.finder.PTGL</string>
アクション <string>com.apple.finder.ACTN</string>
クイックルック <string>com.apple.finder.QUIK</string>

エアードロップ <string>com.apple.finder.AirD</string>
クラウド <string>com.apple.finder.AddP</string>
ホーム <string>com.apple.finder.HOME</string>
アプリケーション <string>com.apple.finder.APPS</string>
パス <string>com.apple.finder.PATH</string>
並び替え <string>com.apple.finder.ARNG</string>
書類フォルダ <string>com.apple.finder.DOCS</string>
パブリック <string>com.apple.finder.PBLC</string>
接続 <string>com.apple.finder.CNCT</string>
ディスク焼き <string>com.apple.finder.BURN</string>
イジェクト <string>com.apple.finder.EJCT</string>
ラベル <string>com.apple.finder.LABL</string>

非推奨 iDiskと設定
<string>com.apple.finder.IDSK</string>
<string>NSToolbarCustomizeToolbarItem</string>
</array>

|

[profiles] profiles コマンド書き出したバックアップを各ファイルに書き出す


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

#####################################
### デフォルトロケーション パス
#####################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Mobileconfig/Bakup")
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
set aliasDefaultLocation to (ocidSaveDirPathURL's absoluteURL()) as alias

#############################
###ダイアログ
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
############UTIリスト
set listUTI to {"com.apple.property-list"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
on error
  log "エラーしました"
return "エラーしました"
end try

set strFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
###書き出し先
set ocidSaveFileDirPathURL to ocidFilePathURL's URLByDeletingPathExtension()
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveFileDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)

#####################################
### plist読み込み
#####################################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
set listResults to refMe's NSMutableDictionary's dictionaryWithContentsOfURL:(ocidFilePathURL) |error|:(reference)
set ocidPlistDict to item 1 of listResults
#####################################
### PLISTのROOT項目=ユーザー名を取得
#####################################
set ocidUserName to refMe's NSUserName()
set arrayPlistRoot to ocidPlistDict's objectForKey:(ocidUserName)
##
repeat with itemPlistRoot in arrayPlistRoot
  set ocidDisplayName to (itemPlistRoot's valueForKey:("ProfileDisplayName"))
  set ocidBaseFilePathURL to (ocidSaveFileDirPathURL's URLByAppendingPathComponent:(ocidDisplayName))
  set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("mobileconfig"))
  
  set listDone to (itemPlistRoot's writeToURL:(ocidSaveFilePathURL) atomically:true)
end repeat




return


|

[profiles]現在のユーザー・プロファイル設定をバックアップ


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# OS14対応
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

###書類フォルダ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
##保存先
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Mobileconfig/Bakup")
##フォルダ作成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###日付取得
set strDateNo to doGetDateNo("yyyyMMdd") as text
##
set strSaveFileName to (strDateNo & ".plist") as text
##
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
set appFileManager to refMe's NSFileManager's defaultManager()
##ファイルの有無チェック
set boolFileExists to (appFileManager's fileExistsAtPath:(ocidSaveFilePathURL's |path|) isDirectory:false)
if boolFileExists is true then
  ###すでにある場合はゴミ箱に
  set appFileManager to refMe's NSFileManager's defaultManager()
  set listResult to (appFileManager's trashItemAtURL:(ocidSaveFilePathURL) resultingItemURL:(ocidSaveFilePathURL) |error|:(reference))
  set strSaveFilePath to ocidSaveFilePathURL's |path| as text
else
  set strSaveFilePath to ocidSaveFilePathURL's |path| as text
end if
##ユーザー名取得
set ocidUserName to refMe's NSUserName()
set strUserName to ocidUserName as text
##コマンド整形
set strCommandText to ("/usr/bin/profiles show -user " & strUserName & " -type configuration -output \"" & strSaveFilePath & "\"") as text
###実行
set strResponse to (do shell script strCommandText) as text
###保存先を開く
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
set boolDone to appSharedWorkspace's selectFile:(strSaveFilePath) inFileViewerRootedAtPath:(ocidSaveDirPathURL's |path|())
###エラーならファインダーで開く
if boolDone is false then
  set aliasFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
  tell application "Finder"
    open folder aliasCameraRawDirPathURL
  end tell
return "エラーしました"
end if


#####
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo


|

[MDM]profilesコマンド基本


【スクリプトエディタで開く】|

#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
##################################################
###管理者インストールしているか?チェック

##ユーザー対象のプロファイルリスト
/usr/bin/profiles list
##_computerlevelのみ
/usr/bin/sudo /usr/bin/profiles list
##全プロファイルリスト
/usr/bin/sudo /usr/bin/profiles list -all
##特定ユーザーのみ
/usr/bin/sudo /usr/bin/profiles list -user ユーザーショート名

#登録内容 ユーザー
/usr/bin/profiles show
#登録内容 システム
/usr/bin/sudo /usr/bin/profiles show
#全部
/usr/bin/sudo /usr/bin/profiles show -all
##特定ユーザーのみ
/usr/bin/sudo /usr/bin/profiles show -user ユーザーショート名
##configurationのみ
/usr/bin/profiles show -type configuration
## enrollmentのみ
/usr/bin/sudo /usr/bin/profiles show -type enrollment
## provisioningのみ
/usr/bin/sudo /usr/bin/profiles show -type provisioning

##【削除】
##PayloadScope USERで登録してあるもの
/usr/bin/profiles remove -identifier com.cocolog-nifty.quicktimer.6DCFF6B7-XXXX-XXXX-XXXX-10BD96C39B49

##PayloadScope SYSTEMで登録してあるもの
/usr/bin/sudo /usr/bin/profiles remove -identifier com.cocolog-nifty.quicktimer.6DCFF6B7-XXXX-XXXX-XXXX-10BD96C39B49

#登録済みのバックアップ ユーザー名指定 configurationのみ対象
CONSOLE_USER=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ { print $3 }')
/bin/mkdir -p "$HOME/Documents/Mobileconfig/OutPut"
STR_DATE_TIME=$(/bin/date +'%Y%m%d%H%M%S')
/usr/bin/profiles show -user "$CONSOLE_USER" -type configuration -output "$HOME/Documents/Mobileconfig/OutPut/""$STR_DATE_TIME"".plist"


##シンク
/usr/bin/sudo /usr/bin/profiles sync


exit 0


|

[自分用]edgeとChromの定型のお気に入り

少し更新した com.google.Chrome.ManagedBookmarks com.microsoft.edgemac.ManagedFavorites を更新 SafariとFirefoxはhtml管理している

ダウンロード - browsermanagedfavorites.zip

|

[SPConfigurationProfileData]システム情報 DBの内容をダイアログ表示して取得


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKIt"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

#####################################
######ファイル保存先
#####################################
set ocidUserLibraryPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidFilePathURL to ocidUserLibraryPathArray's objectAtIndex:0
set ocidSaveDirPathURL to ocidFilePathURL's URLByAppendingPathComponent:"Apple/system_profiler"
############################
#####属性
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:511 forKey:(refMe's NSFilePosixPermissions)
############################
###フォルダを作る
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#####################################
######PLISTパス
#####################################
set ocidFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:"SPConfigurationProfileDataType.json"
set strFilePath to (ocidFilePathURL's |path|()) as text
###古いファイルはゴミ箱に
set boolResults to (appFileManager's trashItemAtURL:ocidFilePathURL resultingItemURL:(missing value) |error|:(reference))
#####################################
######コマンド実行
#####################################
set strCommandText to "/usr/sbin/system_profiler SPConfigurationProfileDataType -json"
set strReadString to (do shell script strCommandText) as text
###戻り値をストリングに
set ocidReadString to refMe's NSString's stringWithString:(strReadString)
###NSDATAにして
set ocidReadData to ocidReadString's dataUsingEncoding:(refMe's NSUTF8StringEncoding)
###ファイルに書き込み(使い回し用)-->不要な場合は削除して
ocidReadData's writeToURL:(ocidFilePathURL) atomically:true
#####################################
######JOSN をDictで処理
#####################################
set listJSONSerialization to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadData) options:0 |error|:(reference))
set ocidJsonData to item 1 of listJSONSerialization
set ocidJsonRootDict to (refMe's NSDictionary's alloc()'s initWithDictionary:(ocidJsonData))
set ocidDataTypeArray to (ocidJsonRootDict's objectForKey:("SPConfigurationProfileDataType"))
set strUserOutPutText to ("Userプロファイル:\n") as text
set strDeviceOutPutText to ("Deveiceプロファイル:\n") as text
repeat with itemDataTypeArray in ocidDataTypeArray
  set strName to (itemDataTypeArray's valueForKey:("_name")) as text
  set ocidItemArray to (itemDataTypeArray's objectForKey:("_items"))
  repeat with itemItemArray in ocidItemArray
    ###とりあえずプロファイル名のみ
    set strProfileName to (itemItemArray's valueForKey:("_name")) as text
    ##必要に応じて項目を追加するといいね
    # set strProfileUUID to (itemItemArray's valueForKey:("spconfigprofile_profile_uuid")) as text
    # set strProfileID to (itemItemArray's valueForKey:("spconfigprofile_profile_identifier")) as text
    if strName is "spconfigprofile_section_userconfigprofiles" then
      set strUserOutPutText to (strUserOutPutText & strProfileName & "\n")
    else if strName is "spconfigprofile_section_deviceconfigprofiles" then
      set strDeviceOutPutText to (strDeviceOutPutText & strProfileName & "\n") as text
    end if
  end repeat
end repeat
log strUserOutPutText
log strDeviceOutPutText

set strOutPutText to (strUserOutPutText & "\n" & strDeviceOutPutText) as text

#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set strIconPath to "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/FinderIcon.icns" as text
set aliasIconPath to POSIX file strIconPath as alias
###ダイアログ
set recordResult to (display dialog " 戻り値です\rコピーしてメールかメッセージを送ってください" with title "SPConfigurationProfileDataType" default answer strOutPutText buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
###クリップボードコピー
if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strOutPutText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if

|

[mobileconfig]Githubからダウンロードして設定パネルでmobileconfigを開く

サンプルはスクリプトメニュー

【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

###【1】URL
set strFileURL to "https://raw.githubusercontent.com/force4u/AppleScript/main/Script%20Menu/Applications/Script%20Editor/Script%20Menu/Mobileconfig/Mobileconfig/com.apple.scriptmenu.mobileconfig" as text

set ocidFileURLStr to refMe's NSString's stringWithString:(strFileURL)
set ocidFileURL to refMe's NSURL's URLWithString:(ocidFileURLStr)
#保存用にファイル名取っておく
set ocidFileName to ocidFileURL's lastPathComponent()
#%エンコードされたファイル名は戻しておく
set ocidSaveFileName to ocidFileName's stringByRemovingPercentEncoding

###【2】URL読み込み
#【2-1】NSdataに読み込む(エラー制御したいため-->いきなりNSMutableDictionaryでもOK)
set ocidOption to refMe's NSDataReadingMappedIfSafe
set listReadData to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFileURL) options:(ocidOption) |error|:(reference)
log "【2-1】" & (item 2 of listReadData)
set ocidPlistData to (item 1 of listReadData)
#【2-2】NSdataをNSPropertyListSerializationしてNSMutableDictionaryに格納する
set ocidXmlPlist to refMe's NSPropertyListXMLFormat_v1_0
set ocidPlistSerial to refMe's NSPropertyListSerialization
set ocidOption to refMe's NSPropertyListMutableContainers
set listPlistSerial to ocidPlistSerial's propertyListWithData:(ocidPlistData) options:(ocidOption) format:(ocidXmlPlist) |error|:(reference)
log "【2-2】" & (item 2 of listPlistSerial)
set ocidPlistSerial to (item 1 of listPlistSerial)
##
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidPlistDict's setDictionary:ocidPlistSerial

###【3】値を変更したい場合はここで
set ocidPayloadArray to ocidPlistDict's objectForKey:("PayloadContent")





###【4】ファイルの保存先(書類フォルダ)
###保存先ディレクトリ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidUserDocumentPathArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentPathURL to ocidUserDocumentPathArray's firstObject()
#保存先ディレクトリを作る 700
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set ocidSaveDirPathURL to ocidDocumentPathURL's URLByAppendingPathComponent:("Mobileconfig") isDirectory:false
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
log "【4】" & (item 1 of listBoolMakeDir)
##保存ファイルのパス
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidSaveFileName)

###【5】保存
set boolDone to ocidPlistDict's writeToURL:(ocidSaveFilePathURL) atomically:true
log "【5】" & boolDone

###【6】登録実行
tell application id "com.apple.systempreferences" to launch
tell application id "com.apple.systempreferences"
  activate
reveal anchor "Main" of pane id "com.apple.Profiles-Settings.extension"
end tell

###FinderのURL
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
set strBundleID to "com.apple.finder" as text
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
if ocidAppBundle is not (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else
  set ocidAppPathURL to appShardWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
end if
###パネルのURL
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:("x-apple.systempreferences")
ocidURLComponents's setPath:("com.apple.preferences.configurationprofiles")
set ocidOpenAppURL to ocidURLComponents's |URL|
set strOpenAppURL to ocidOpenAppURL's absoluteString() as text
###ファイルURLとパネルのURLをArrayにしておく
set ocidOpenUrlArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidOpenUrlArray's insertObject:(ocidSaveFilePathURL) atIndex:0
ocidOpenUrlArray's insertObject:(ocidOpenAppURL) atIndex:1
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  set theCmdCom to ("open \"" & strFilePath & "\" | open \"" & strOpenAppURL & "\"") as text
  do shell script theCmdCom
else
  ###FinderでファイルとURLを同時に開く
  set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration
ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true)
appShardWorkspace's openURLs:(ocidOpenUrlArray) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value)
end if
log "【6】Done"

###【7】保存ファイル表示
#選択状態で開く
set boolDone to appShardWorkspace's selectFile:(ocidSaveFilePathURL's |path|) inFileViewerRootedAtPath:(ocidDocumentPathURL's |path|)
log "【7】" & boolDone

###【8】システム設定を前面に
###システム設定を前面に
set ocidRunningApp to refMe's NSRunningApplication
set ocidAppArray to (ocidRunningApp's runningApplicationsWithBundleIdentifier:("com.apple.systempreferences"))
set ocidApp to ocidAppArray's firstObject()
ocidApp's activateWithOptions:(refMe's NSApplicationActivateAllWindows)
set boolDone to ocidApp's active
log "【8】" & boolDone


|

mobileconfigファイルをシステム設定で開く


【スクリプトエディタで開く】|

set theCmdCom to ("open \"" & strFilePath & "\" | open \"x-apple.systempreferences:com.apple.preferences.configurationprofiles\"") as text
  do shell script theCmdCom

↑これをAppleScriptでやります↓

【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application


####ダイアログで使うデフォルトロケーション
tell application "Finder"
  set aliasDefaultLocation to (path to documents folder from user domain) as alias
end tell

####UTIリスト PDFのみ
set listUTI to {"com.apple.mobileconfig"}

set strMes to ("モバイルコンフィグファイルを選んでください") as text
set strPrompt to ("モバイルコンフィグファイルを選んでください") as text

####ダイアログを出す
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
###パス
set strFilePath to POSIX path of aliasFilePath
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)

###起動はさせておく
tell application id "com.apple.systempreferences" to launch
tell application id "com.apple.systempreferences"
  activate
reveal anchor "Main" of pane id "com.apple.Profiles-Settings.extension"
end tell

###FinderのURL
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
set strBundleID to "com.apple.finder" as text
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
if ocidAppBundle is not (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else
  set ocidAppPathURL to appShardWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
end if
###パネルのURL
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:("x-apple.systempreferences")
ocidURLComponents's setPath:("com.apple.preferences.configurationprofiles")
set ocidOpenAppURL to ocidURLComponents's |URL|
###ファイルURLとパネルのURLをArrayにしておく
set ocidOpenUrlArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidOpenUrlArray's insertObject:(ocidFilePathURL) atIndex:0
ocidOpenUrlArray's insertObject:(ocidOpenAppURL) atIndex:1
###FinderでファイルとURLを同時に開く
set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration
ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true)
appShardWorkspace's openURLs:({ocidFilePathURL, ocidOpenAppURL}) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value)
###システム設定を前面に
set ocidRunningApp to refMe's NSRunningApplication
set ocidAppArray to (ocidRunningApp's runningApplicationsWithBundleIdentifier:("com.apple.systempreferences"))
set ocidApp to ocidAppArray's firstObject()
ocidApp's active

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom