Last active
January 28, 2025 23:23
-
-
Save colorenz/ffcd2906262ade3af16b91361ffef47e to your computer and use it in GitHub Desktop.
Extenstion Attribute to check if a User Desktop or Documents Folder have a Symlinks and are OneDrive KFM Folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
### Version Beta 0.1 | |
### Created by Colorenz | |
### Extenstion Attribute to check if a User Desktop or Documents Folder have a Symlinks and are OneDrive KFM Folders | |
#Get Current logined User | |
CurrentUser=$(scutil <<<"show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }') | |
#Get Current User Home | |
User_Home=$(/usr/bin/dscl . -read /Users/"${CurrentUser}" NFSHomeDirectory 2>/dev/null | /usr/bin/sed 's/^[^\/]*//g') | |
KFMFolders="not activated" | |
#Check if Documents has a Symlink | |
if [ -L "$User_Home/Documents" ]; then | |
{ | |
KFMFolders="Documents Symlink" | |
KFMConfig=$(ls -l $User_Home/Documents) | |
#Get the Symlink from Documents and check if the Symlink contains OneDrive | |
if [[ "$KFMConfig" == *"OneDrive"* ]]; then | |
{ | |
#Check if the Symlink contains OneDrive | |
KFMFolders=$KFMFolders" OneDrive" | |
} | |
fi | |
KFMFolders=$KFMFolders" / " | |
} | |
#Get the Symlink from Desktop and check if the Symlink contains OneDrive | |
if [ -L "$User_Home/Desktop" ]; then | |
{ | |
KFMFolders=$KFMFolders"Desktop Symlink" | |
KFMConfig=$(ls -l $User_Home/Desktop) | |
if [[ "$KFMConfig" == *"OneDrive"* ]]; then | |
{ | |
KFMFolders=$KFMFolders" OneDrive" | |
} | |
fi | |
} | |
fi | |
fi | |
/bin/echo "<result>$KFMFolders</result>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
### Version Beta 0.2 | |
### Created by Colorenz | |
### Extenstion Attribute to check if KFM Status | |
### KFM Values | |
### 0 = Off | |
### 512 = Desktop Backed Up | |
### 1024 = Documents Backed Up | |
### 1536 = Desktop and Documents Backed Up. | |
#Get Current logined User | |
CurrentUser=$(scutil <<<"show State:/Users/ConsoleUser" | awk '/Name :/ { print $3 }') | |
#Get Current User Home | |
KFMFolderStatus=$(/usr/libexec/PlistBuddy -c "print :AccountInfo_Business1:KfmFoldersProtectedNow" /Users/${CurrentUser}/Library/Group\ Containers/UBF8T346G9.OneDriveStandaloneSuite/Library/Preferences/UBF8T346G9.OneDriveStandaloneSuite.plist) | |
#Check KFM Status | |
case "$KFMFolderStatus" in | |
"0") /bin/echo "<result>KFM not activated</result>" | |
;; | |
"512") /bin/echo "<result>Desktop is activated</result>" | |
;; | |
"1024") /bin/echo "<result>Documents is activated</result>" | |
;; | |
"1536") /bin/echo "<result>Desktop and Documents is activated</result>" | |
;; | |
esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment