forked from jamf/Jamf-Nation-Extension-Attributes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CrashPlan - Status.xml
96 lines (87 loc) · 3.64 KB
/
CrashPlan - Status.xml
1
<?xml version="1.0" encoding="UTF-8"?><extensionAttribute> <displayName>CrashPlan - Status</displayName> <displayInCategory>Backup</displayInCategory> <description>This attribute displays the status of the computer. Values that are returned are either "Active" or "Deactivated". This attribute applies to both Mac and Windows.</description> <dataType>string</dataType> <scriptContentsMac>#!/bin/shCP_ServerAddress="EditFromTemplate_CrashPlan_Server_Name"CP_ServerPort="4285"CP_AdminUsername="EditFromTemplate_CrashPlan_Service_Account_Username"CP_AdminPassword="EditFromTemplate_CrashPlan_Service_Account_Password"if [ "$CP_ServerAddress" == "" ] || [ "$CP_ServerPort" == "" ] || [ "$CP_AdminUsername" == "" ] || [ "$CP_AdminPassword" == "" ];thenecho "<result>Please ensure all variables are set in the extension attribute script.</result>"elseif [ -f /Library/Application\ Support/CrashPlan/.identity ];then GUID=`/bin/cat /Library/Application\ Support/CrashPlan/.identity | grep guid | sed s/guid\=//g` echo "<result>`/usr/bin/curl -u "$CP_AdminUsername":"$CP_AdminPassword" -k https://"$CP_ServerAddress":"$CP_ServerPort"/rest/computers?guid="$GUID" | grep -w status | awk '{print $2}' | sed s/,//g | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/'`</result>"else echo "<result>Not installed</result>"fifi </scriptContentsMac> <scriptTypeWindows>VBScript</scriptTypeWindows> <scriptContentsWindows>On Error Resume Next 'Declaration of Objects, Constants, VariablesDim objFSODim objTextFileDim strTextFileDim objHTTPDim arrResultsDim strResultDim GUIDDim CP_ServerAddressDim CP_ServerPortDim CP_AdminUsernameDim CP_AdminPassword'Set VariablesCP_ServerAddress = "EditFromTemplate_CrashPlan_Server_Name"CP_ServerPort = "4285"CP_AdminUsername = "EditFromTemplate_CrashPlan_Service_Account_Username"CP_AdminPassword = "EditFromTemplate_CrashPlan_Service_Account_Password"'Validate Variables Have Been SetIf CP_ServerAddress = "" Or CP_ServerPort = "" Or CP_AdminUsername = "" Or CP_AdminPassword = "" ThenWScript.Echo "<result>Please ensure all variables are set in the extension attribute script.</result>"Else'Set ObjectsSet objFSO = CreateObject("Scripting.FileSystemObject")Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")'Set ConstantsConst WinHttpRequestOption_SslErrorIgnoreFlags = 4'Read in CrashPlan GUIDSet objTextFile = objFSO.OpenTextFile("C:\ProgramData\CrashPlan\.identity")strTextFile = objTextFile.ReadAllobjTextFile.ClosearrResults=Split(strTextFile, Chr(13))For i = 0 to ubound(arrResults) If inStr(arrResults(i), "guid") > 0 Then strResult = Replace(arrResults(i), "guid=", "") GUID = strResult strResult = "" Exit for End ifNextIf GUID = "" Then WScript.Echo "<result>Not installed</result>"Else 'Connect to the CrashPlan Pro Server Rest API objHTTP.open "GET", "https://" & CP_ServerAddress & ":" & CP_ServerPort & "/rest/computers?guid=" & GUID & "", False objHTTP.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = &H3300 objHTTP.SetCredentials CP_AdminUsername, CP_AdminPassword, 0 objHTTP.send 'Parse the JSON Output arrResults=Split(objHTTP.ResponseText, ",") For i = 0 to ubound(arrResults) If inStr(arrResults(i), "status") > 0 Then strResult = arrResults(i) strResult = Replace (strResult, chr(10), "") strResult = Replace (strResult, chr(32), "") strResult = Replace (strResult, chr(34), "") strResult = Replace (strResult, "status:", "") Exit for End if Next WScript.Echo "<result>" & strResult & "</result>"End IfEnd If</scriptContentsWindows></extensionAttribute>