noob62 Posted February 17, 2016 Share Posted February 17, 2016 Trying to get a script up and running that will identify if a server or workstation is being managed by either SCCM or KACE. I keep running into a issue where it always seems to default to workstation no matter what with the below script. I'm sure it's an easy fix I'm just missing something simple: Local $SCCM, $KACE, $Type, $OS $OS = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" , "ProductType") If $OS = "WinNT" Then $Type = "Workstation" ElseIf $OS = "ServerNT" Then $Type = "Server" ElseIf $OS = "LanmanNT" Then $Type = "Server" EndIf $SCCM = RegRead("HKLM64\SOFTWARE\Microsoft\SMS\Mobile Client" , "ProductVersion") $KACE = RegRead("HKLM64\SOFTWARE\Dell\Kace" , "Installld") If $Type = "Workstation" & @error = 1 Then MsgBox(4096, "INFO" , "SCCM Client: Not Installed") Elseif $Type = "Server" & @error = 1 Then MsgBox(4096, "INFO" , "KACE Client: Not Installed") Elseif $Type = "Workstation" & @error <> 1 Then MsgBox(4096, "INFO" , "SCCM Client: Installed") Elseif $Type = "Server" & @error <> 1 Then MsgBox(4096, "INFO" , "KACE Client: Installed") EndIf Link to comment Share on other sites More sharing options...
spudw2k Posted February 17, 2016 Share Posted February 17, 2016 (edited) You could probably simplify your last if statement. That section looks a bit convoluted. You should look into using Switch or Select statements in lieu of complex if then statements. Also, for simple "binary" if statements you can employ ternary notation. You can also have a look at the @OS... macros (@OSVersion in particular). Macros are built at run-time and will save time from having to do the first reg lookup. Sure, we're probably talking milliseconds, but hey...why not save time when you can? Sorry....tangent. ;For example only - Untested Local $SCCM, $KACE, $Type, $OS $OS = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" , "ProductType") Switch $OS Case "WinNt" $Type = "Workstation" Case "ServerNT" $Type = "Server" Case "LanmanNT" $Type = "Server" EndSwitch Select Case $Type = "Workstation" $SCCM = RegRead("HKLM64\SOFTWARE\Microsoft\SMS\Mobile Client" , "ProductVersion") ;ternary operator MsgBox(4096, "INFO" , (@error <> 0) ? ("SCCM Client: Not Installed") : ("SCCM Client: Installed")) Case $Type = "Server" $KACE = RegRead("HKLM64\SOFTWARE\Dell\Kace" , "Installld") ;ternary operator MsgBox(4096, "INFO" , (@error <> 0) ? ("KACE Client: Not Installed") : ("KACE Client: Installed")) EndSelect edit: corrected malformed ternary usage Edited February 17, 2016 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now