AutoIt – Create GUI Box with Title Menu

email me

This is a snippet from a larger program I created.

Screenshot

 

Code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; create gui
$hGUI = GUICreate("The Main Form", 388, 610, 5, 5 ,BitOR($WS_MINIMIZEBOX,$WS_CLIPCHILDREN))
$hButton1 = GUICtrlCreateButton("CLOSE", 260, 510, 100, 40)

; create menu
Local $idFilemenu1 = GUICtrlCreateMenu("&MyMenu")
Local $idFileitem1 = GUICtrlCreateMenuItem("DoThis1", $idFilemenu1)
Local $idFileitem2 = GUICtrlCreateMenuItem("DoThis2", $idFilemenu1)
Local $idFileitem3 = GUICtrlCreateMenuItem("DoThis3", $idFilemenu1)
GUICtrlCreateMenuItem("", $idFilemenu1, 4) ; Create a separator line

GUISetState(@SW_SHOW)
; scan for menu action
While 1
Switch GUIGetMsg()
Case $idFileitem1
Run("cmd /c DoThis1.exe", "", @SW_HIDE)
Case $idFileitem2
Run("cmd /c DoThis2.exe", "", @SW_HIDE)
Case $idFileitem3
Run("cmd /c DoThis3.exe", "", @SW_HIDE)
Case $hButton1
Run("cmd /c DoThisButton.exe", "", @SW_HIDE)
EndSwitch
WEnd

Do
Sleep(10)
Until GuiGetMsg() =-3

GUIDelete()
;.....

SCCM – Use the Remote Control Viewer from Other Computers

email me

If you happen to use and like the SCCM Remote Control Viewer in the SCCM console, you’ll be happy to know…you don’t need SCCM to run it. That’s right—it’s an independent application. All you need to do is copy the files from Program Files\Microsoft Configuration Manager\AdminConsole\bin\i386 (the folder that contains the CmRcViewer.exe) and you’ll be in business.

I copied the above folder to a non-domain machine, non-work machine…ran the CmRcViewer.exe, entered some credentials, and I was able to remotely connect to work machines. No SCCM necessary.

The Files (copy the whole folder)

 

From my home machine

SCCM – Join SMS_R_System and SMS_R_User

email me

In SCCM, this is how you join the System and User tables.

Screenshot


Code

SELECT * FROM  SMS_R_System INNER JOIN SMS_R_User ON SMS_R_User.Username = SMS_R_System.LastLogonUserName

 

Notes

Add SMS_G_System_COMPUTER_SYSTEM

SELECT DISTINCT SMS_G_System_COMPUTER_SYSTEM.Model, SMS_R_System.Name,SMS_R_User.displayName, SMS_R_User.UserName, SMS_R_User.Mail, SMS_R_User.employeeID FROM  SMS_R_System inner join SMS_R_User ON SMS_R_User.Username= SMS_R_System.LastLogonUserName INNER JOIN SMS_G_System_COMPUTER_SYSTEM ON SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_R_System.LastLogonUserName = SMS_R_System.LastLogonUserName

 

Run Query in SQL

SELECT
v_R_System.Name0, v_R_System.Operating_System_Name_and0, v_R_User.User_Name0,v_R_User.displayName0,v_R_User.Mail0, v_GS_COMPUTER_SYSTEM.Model0, v_R_User.employeeID0
FROM
v_R_System
INNER JOIN
v_R_User ON v_R_User.User_Name0 = v_R_System.User_Name0
INNER JOIN
v_GS_COMPUTER_SYSTEM ON v_GS_COMPUTER_SYSTEM.ResourceID = v_R_System.ResourceId

 

Or this to include nulls

SELECT
v_R_System.Name0, v_R_System.Operating_System_Name_and0, v_R_User.User_Name0,v_R_User.displayName0,v_R_User.Mail0, v_GS_COMPUTER_SYSTEM.Model0, v_R_User.employeeID0
FROM
v_R_System
LEFT JOIN
v_R_User ON v_R_User.User_Name0 = v_R_System.User_Name0
INNER JOIN
v_GS_COMPUTER_SYSTEM ON v_GS_COMPUTER_SYSTEM.ResourceID = v_R_System.ResourceId

Remove Dameware Remote

email me

net stop dwmrcs

regsvr32 /u /s C:\Windows\DWRCS\DWRCSh.dll

regsvr32 /u /s C:\Windows\DWRCS\DWRCSE.dll

regsvr32 /u /s C:\Windows\DWRCS\DWRCSET.dll

regsvr32 /u /s C:\Windows\DWRCS\DWRCSI.dll

regsvr32 /u /s C:\Windows\DWRCSDWRCRSS.dll

regsvr32 /u /s C:\Windows\DWRCS\DWRCK.dll

regsvr32 /u /s C:\Windows\DWRCS\DWRCWXL.dll

C:\Windows\DWRCS\dwrcs.exe -remove

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\DameWare Development” /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run” /v “DameWare MRC Agent” /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\PnpLockdownFiles\%SystemRoot%/System32/DamewareDisp.dll” /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\PnpLockdownFiles\%SystemRoot%/System32/drivers/DamewareMini.sys” /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\FirewallRules” /v {69FDD839-6B1D-4D7A-9313-2D1E5E31F900} /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Setup\PnpLockdownFiles\%SystemRoot%/System32/DamewareDisp.dll” /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Setup\PnpLockdownFiles\%SystemRoot%/System32/drivers/DamewareMini.sys” /f /reg:64

reg delete “HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Policies\Microsoft\WindowsFirewall\FirewallRules” /v {69FDD839-6B1D-4D7A-9313-2D1E5E31F900} /f /reg:64

del “C:\Windows\DWRCS\*.*” /s /q

 

Notes

  1. Stop your DameWare Remote Support service.
  2. Delete the following folders:
    • C:\Program Files (x86)\SolarWinds\DameWare Remote Support
    • C:\ProgramData\SolarWinds
    • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\SolarWinds\DameWare Remote Support
    • C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\SolarWinds\DameWare Remote Support
    • C:\Users\All Users\SolarWinds
    • C:\Users\Administrator\AppData\Roaming\DameWare Development
  3. Delete the following icons:
    • C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\DRS.lnk
    • C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\StartUp\DRS.lnk
    • C:\Users\Public\Desktop\DameWare Mini Remote Control.lnk
    • C:\Users\Public\Desktop\DameWare Remote Support.lnk
  4. Delete the following Registry keys:
    This key is unique for every version of the installation. To find it, search for the DisplayName key containing DameWare Remote Support value. See the following example:

    • HKEY_CLASSES_ROOT\dwrcc – This key removes any custom protocols handled.
    • HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{2189e608-cfee-4ae7-8d17-529bf84c192e} – This key removes the application from the Programs and Features list.

 

PowerShell

#Set Logfile

$logfile = "$env:systemdrive\Temp\DW-remove.log"
#Set Service List

$ServiceList = "DWMRCS",
"DNTUS26"
#Set Registry Path

$RegPathList = "HKLM:\Software\DameWare Development"
#MSI Code List
$MSICodeList =
"{385FED21-85D3-401E-8B8A-38140333FAC8}", #x64 installer
"{9F660272-3D31-47CE-BEB6-7A065B8901A5}" #x32 installer
#List of Files to search for
$FindFileList =
"DWRCS.EXE", #Dameware remote control service
"DNTUS26.EXE" #Dameware utility service
#Parent folder to delete if it exists.
$FindFolder =
"DWRCS" #Known location of Dameware files; also known to reside in the system32 folder but we don't want to delete system32 #Define Functions
Function
GetTimeDate {

$Month = Get-Date -Format MM
$Day = Get-Date -Format dd
$Year = Get-Date -Format yyyy
$Hour = Get-Date -Format hh
$Minute = Get-Date -Format mm
$Seconds = Get-Date -Format ss
$SecondsF = Get-Date -Format fff

$TimeDate = ($Month + "-" + $Day + "-" + $Year + "_" + $Hour + ":" + $Minute + ":" + $Seconds + "." + $SecondsF)Return $TimeDate }
Function
OutLog {
((
GetTimeDate) + " " + $LogBuffer) | out-file -FilePath $logfile -Append
{

switch -Wildcard ($LogBuffer)"Error*" {

write-host ((GetTimeDate) + " " + $LogBuffer) -ForegroundColor Red }

"Warning*" {

write-host ((GetTimeDate) + " " + $LogBuffer) -ForegroundColor Yellow }

Default {

}
}
}
write-host ((GetTimeDate) + " " + $LogBuffer) Function
{

{

{

filedelete($folder)foreach ($filename in $CompanionFileList) if (Test-Path ($folder.DirectoryName + "\" + $filename))$LogBuffer = ($folder.DirectoryName + "\" + $filename) + " was found."
outlog
$LogBuffer = "Deleting " + ($folder.DirectoryName + "\" + $filename) + "."
outlog
Remove-Item ($folder.DirectoryName + "\" + $filename) -ErrorAction SilentlyContinue
{

if (Test-Path ($folder.DirectoryName + "\" + $filename))$LogBuffer = "Error: " + $folder.DirectoryName + "\" + $filename + " was not deleted."
outlog }

{

else $LogBuffer = ($folder.DirectoryName + "\" + $filename) + " was successfully deleted."
outlog }
}

else {

$LogBuffer = "Warning: " + ($folder.DirectoryName + "\" + $filename) + " was not found."
outlog }
}
}
Function
{

{

{

FolderDelete($folder)if ($folder.DirectoryName -like "*" + $FindFolder)if (remove-item $folder.DirectoryName -recurse -force -ErrorAction SilentlyContinue)$LogBuffer = ($folder.DirectoryName) + " was successfully deleted."
outlog }

{

else $LogBuffer = "Error: " + ($folder.DirectoryName) + " was not successfully deleted."
outlog }
}
}
Function
FindFile {

{

foreach ($FindFile in $FindFileList)$LogBuffer = "Searching for " + $FindFile + "."
outlog
$files = Get-ChildItem -path $env:systemroot -Filter $FindFile -Recurse -ErrorAction SilentlyContinue
{

if ($files -eq $null)$LogBuffer = "Warning: "+ $FindFile + " was not found."
outlog }

else {

$LogBuffer = "Found " + $FindFile + " in " + $Files.DirectoryNameoutlog
{

}
}
}
}
foreach ($folder in $files) filedelete($folder)folderdelete($folder) Function
MSIx {

{

foreach ($MSICode in $MSICodeList)$LogBuffer = "Executing MSI Uninstall string: MSIEXEC.EXE /X" + $MSICode + " /QN /NORESTART"
outlog

{

{

$Exit = (start-process -FilePath "MSIEXEC.EXE" -argumentlist "/X$MSICode /QN /NORESTART" -wait -passthru).ExitCodeSwitch($Exit)"1603" $LogBuffer = "MSI Result Code was: " + $Exit + " Error: Fatal error during uninstallation. Application not removed."
outlog }

"1605" {

$LogBuffer = "Warning: MSI Result Code was: " + $Exit + " Application is not installed."
outlog }

"0" {

$LogBuffer = "Warning: MSI Result code was: " + $Exit + " Application successfully uninstalled."
outlog
MSISuccessHandler }

Default {

$LogBuffer = "Error: MSI Result Code was: " + $Exit
outlog }
}
}
}
$LogBuffer
= "It looks like PowerShell." outlog
Function
DeleteService {

{

{

foreach ($ServiceName in $Servicelist)if (Get-Service -Name $ServiceName -ErrorAction SilentlyContinue)$ServName = Get-Service -Name $ServiceName
$LogBuffer = "The service '" + $ServName.DisplayName + "' was found."
outlog
$LogBuffer = "Stopping service: '" + $ServName.DisplayName + "'"
outlog
Set-Service $ServName.Name -Status Stopped

$ServiceStatus = Get-Service -Name $ServName.Name$LogBuffer = "The Service: '" + $ServName.DisplayName + "' is " + $ServiceStatus.Status + "."
outlog
$LogBuffer = "Deleting the service '" + $ServName.DisplayName + "'."
outlog

$null = (Get-WmiObject win32_service | where {$_.Name -Like $ServName.Name}).delete()sleep -Seconds 49244925

{

if (Get-Service -Name $ServName.Name -ErrorAction SilentlyContinue)$LogBuffer = "Error: The service: '" + $ServName.DisplayName + "' was not deleted."
}

outlog else {

$LogBuffer = "The service: '" + $ServName.DisplayName + "' was successfully deleted."
outlog }
}

else {

$LogBuffer = "Warning: The service: '" + $ServiceName + "' was not found."
outlog }
}
}
Function
RegClean {

{

{

foreach ($RegPath in $RegPathList)if (Test-Path $RegPath)$LogBuffer = $RegPath + " was found in the registry."
outlog
$LogBuffer = "Deleting " + $RegPath + "."
outlog
Remove-Item $RegPath -Recurse -Force
{

if (Test-Path $RegPath)$LogBuffer = "Error: " + $RegPath + " was not deleted from the registry."
outlog }

else {

$LogBuffer = $RegPath + " was successfully deleted from the registry."
outlog }
}

else {

$LogBuffer = "Warning: " + $RegPath + " was not found in the registry."
outlog }
}
}
Function
StartLog {

$LogBuffer = "----====Logging started====----"
outlog }
Function
StopLog {

$LogBuffer = "----====Logging stopped====----"
outlog }
Function
MSISuccessHandler {

{

if ($Exit -eq "0")$LogBuffer = "Warning: MSI uninstall was successful. Remainder of script is probably not necessary."
outlog }
}
#Do all the things
StartLog
MSIx
DeleteService
FindFile
RegClean
StopLog

POODLE Attack: Registry Settings to Disable SSL 3.0

email me

A POODLE attack is an exploit that takes advantage of the way some browsers deal with encryption. POODLE (Padding Oracle On Downgraded Legacy Encryption) is the name of the vulnerability that enables the exploit.

Microsoft is aware of detailed information that has been published describing a new method to exploit a vulnerability in SSL 3.0. This is an industry-wide vulnerability affecting the SSL 3.0 protocol itself and is not specific to the Windows operating system. All supported versions of Microsoft Windows implement this protocol and are affected by this vulnerability. Microsoft is not aware of attacks that try to use the reported vulnerability at this time. Considering the attack scenario, this vulnerability is not considered high risk to customers.

We are actively working with partners in our Microsoft Active Protections Program (MAPP) to provide information that they can use to provide broader protections to customers.

Microsoft is announcing that with the release of security update 3038314 on April 14, 2015 SSL 3.0 is disabled by default in Internet Explorer 11. Microsoft is also announcing that SSL 3.0 will be disabled across Microsoft online services over the coming months. We recommend customers migrate clients and services to more secure security protocols, such as TLS 1.0, TLS 1.1 or TLS 1.2.

Mitigating Factors

  • The attacker must make several hundred HTTPS requests before the attack could be successful.
  • TLS 1.0, TLS 1.1, TLS 1.2, and all cipher suites that do not use CBC mode are not affected.

Recommendation

Disable SSL 3.0.

 

Solution – Issue command

reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings” /v SecureProtocols /t REG_DWORD /d 2688

The reg mod is the same as making the following change to the local group policy:

  • Browse to Computer Configuration -> Administrative Templates -> Windows Components -> Internet Explorer -> Internet Control Panel -> Advanced Page -> Turn off encryption support
  • Change Turn off Encryption Support setting to “Enabled”
  • Under Options, change the Secure Protocol combinations setting to “Use TLS 1.0, TLS 1.1, and TLS 1.2”

 

Notes

https://docs.microsoft.com/en-us/security-updates/SecurityAdvisories/2015/3009008

PowerShell – Return Installed Windows KBs

email me

Screenshot

 

Code

Clear-host
 
Function Get-KBs
{ 
    $cmdOutput = Invoke-Expression "wmic qfe list" 
    $cmdOutput = $cmdOutput[1..($cmdOutput.length)] 
      
      
    foreach ($item in $cmdOutput) { 
        if ($item) { 
            $item = $item -replace 'Security Update','Security-Update' 
            $item = $item -replace 'NT AUTHORITY','NT-AUTHORITY' 
            $item = $item -replace '\s+',' ' 
            $item = $item -split ' '            
            New-Object -Type PSObject -Property @{ 
                HotFixID = [string]$item[3] 
                  
            } 
        } 
    } 
} 
 
Get-KBs

Windows 7 – PowerShell – Repair Windows Updates

email me

Required KB: https://www.microsoft.com/en-us/download/details.aspx?id=51212

Clear-host
Write-Host "[Launching Windows Updates repair]"
Write-Host ""

Write-Host "[Stop Windows Update Services]"
Stop-Service -Name BITS
Stop-Service -Name wuauserv
Stop-Service -Name appidsvc
Stop-Service -Name cryptsvc

Write-Host "[Remove QMGR Data file]"
Remove-Item "$env:allusersprofile\Application Data\Microsoft\Network\Downloader\qmgr*.dat" -ErrorAction SilentlyContinue

Write-Host "[Rename Windows Updates folders]"
Rename-Item $env:systemroot\SoftwareDistribution SoftwareDistribution.bak -ErrorAction SilentlyContinue
Rename-Item $env:systemroot\System32\Catroot2 catroot2.bak -ErrorAction SilentlyContinue

Write-Host "[Remove Windows Update log]"
Remove-Item $env:systemroot\WindowsUpdate.log -ErrorAction SilentlyContinue

Write-Host "[Reset Windows Update Services]"
"sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)"
"sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)"

# set path
Set-Location $env:systemroot\system32

Write-Host "[Register DLLs]"
regsvr32.exe /s atl.dll
regsvr32.exe /s urlmon.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s browseui.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s scrrun.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s softpub.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s dssenh.dll
regsvr32.exe /s rsaenh.dll
regsvr32.exe /s gpkcsp.dll
regsvr32.exe /s sccbase.dll
regsvr32.exe /s slbcsp.dll
regsvr32.exe /s cryptdlg.dll
regsvr32.exe /s oleaut32.dll
regsvr32.exe /s ole32.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s initpki.dll
regsvr32.exe /s wuapi.dll
regsvr32.exe /s wuaueng.dll
regsvr32.exe /s wuaueng1.dll
regsvr32.exe /s wucltui.dll
regsvr32.exe /s wups.dll
regsvr32.exe /s wups2.dll
regsvr32.exe /s wuweb.dll
regsvr32.exe /s qmgr.dll
regsvr32.exe /s qmgrprxy.dll
regsvr32.exe /s wucltux.dll
regsvr32.exe /s muweb.dll
regsvr32.exe /s wuwebv.dll

Write-Host "[Remove Windows Updates settings]"
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f

Write-Host "[Reset Winsock]"
netsh winsock reset
netsh winhttp reset proxy

Write-Host "[Delete BITS jobs]"
Get-BitsTransfer | Remove-BitsTransfer

Write-Host "[Install Windows Updates Agent]"
Windows6.1-KB3138612-x64.msu /quiet

Write-Host "[Start Windows Updates Services]"
Start-Service -Name BITS
Start-Service -Name wuauserv
Start-Service -Name appidsvc
Start-Service -Name cryptsvc

Write-Host "[Launch discovery]"
wuauclt /resetauthorization /detectnow

Write-Host "Windows Updates repair is complete. Restart computer."

Mac – SCCM Agent Install and PKI Enrollment

email me

creating a scripted package for Macs…

Initiating and completing the SCCM Agent install and Mac PKI enrollment process is nowhere as easy as it should be. Microsoft has went out of its way to force you to manually enter a password for PKI enrollment (older installs, it wasn’t necessary); not great if you’re trying to automate the installation.

I have the whole process working. I thought I would share my scripts and notes here. Maybe they will be helpful; maybe you can even improve the process.

#1 For the Mac SCCM Agent, download the CM DMG from MS, and extract the contents to a folder on a Mac (we’ll be using the contents of that folder to create a single package for deployment).

#2 Make changes and save this script as sccm_enrollment.sh into the folder you created.

#!/bin/bash

## Eddie Jackson
## 05-31-2018
## Version 1.0
## 
## Script to install SCCM Agent and launch enrollment script

Clear

## set current directory
DIR=$( cd "$( dirname "${BASH_SOURCE[]}" )" && pwd)

## change directory
cd ${DIR}

## ADD ROOT CERT -- not really necessary if the DMZ is set up properly
## security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain root-CA.cer

## INSTALL SCCM AGENT
sudo ./ccmsetup


## PKI SERVER
server_address="YourDMZ.Domain.com"

## PKI ACCOUNT NAME
sccmusername=Domain\\UserName

## Now hand off to the expect script to perform the enrollment
sudo ./expect_enrollment.sh $server_address $sccmusername

## DIALOG BOX FUNCTION
function msgBox() {
  osascript << EOT
    tell app "System Events"
      display dialog "$1" buttons {"OK"} default button 1 with icon 1 with title "Software Updates"
      ## icon 0=stop,icon 1=software,icon 2=caution
      return  -- Suppress result
    end tell
EOT
}
 
msgBox "Software has been installed. Please restart your computer!"

exit 0

 

#3 Make changes and save this script as expect_enrollment.sh into the same folder.

#!/usr/bin/expect

## Eddie Jackson
## 05-31-2018
## Version 1.0

## IMPORT VARIABLES FROM THE SCCM SCRIPT
set server_address [lindex $argv 0]; # Get the Server Address from the sccm_enrollment script
set sccmusername [lindex $argv 1]; # Get the sccmuser name form the sccm_enrollment script

# SET TIMEOUT
set timeout 20

## RUN SCRIPT
spawn ./Tools/CMEnroll -s $server_address -ignorecertchainvalidation -u $sccmusername
expect "Please enter your password."

# remember, a complex password may require the backward slash as an escape character
# you could pass this from the sccm script, but with special characters, it fails often
# PASSWORD HERE
send X\(IcAnDoIT\!
send \n 
expect "Successfully enrolled"
interact
unset sccmusername
unset server_address
exit 0

 

#4 If your company requires package branding and/or logging, make sure those are completed before continuing.

#5 Now, using Packages from WhiteBox, create a Distribution package.

#6 Add the extracted files and folders from the SCCM Agent DMG, and the two scripts above, into the Additional Resources under the Scripts tab.

#7 Set the sccm_enrollment.sh script as the Pre-installation script.

#8 Build and Run.

#9 If that works, deploy that package from desktop management software. Note, when deploying from management software, you should not see any Mac GUI setup.

 

Notes

Guidelines for Mac software packaging

Mac – Bash – Create Pop Up Message

email me

Creates a non-intrusive dialog box via the Finder app.

Dialog box will be available here — The Finder app will be jumping up and down.

#!/bin/bash
osascript -e 'tell app "Finder" to display dialog "Software installed. Please restart your computer." buttons {"OK"}'

 

 

Creates a dialog box using System Event.

Dialog box will just appear on desktop

#!/bin/bash

# Dialog Function
function msgBox() {
  osascript <<EOT
    tell app "System Events"
      display dialog "$1" buttons {"OK"} default button 1 with icon caution with title "$(basename $0)"
      ## icon 0=stop,icon 1=software,icon 2=caution
      return  -- Suppress result
    end tell
EOT
}

msgBox "Software has been installed. Please restart your computer!"

 

Notes

killall Terminal

osascript -e ‘tell application “Terminal” to quit’

echo -n -e “\033]0;msgBox\007”
osascript -e ‘tell application “Terminal” to close (every window whose name contains “msgBox”)’ &

closeWindow() {
/usr/bin/osascript << _OSACLOSE_
tell application “Terminal”
close (every window whose name contains “msgBox.sh”)
end tell
delay 0.3
tell application “System Events” to click UI element “Close” of sheet 1 of window 1 of application process “Terminal”
_OSACLOSE_
}

 

PowerShell – Set up Hidden-Special Account

email me

clear-host

$UserName = "TestUser"		
$Password = "LetMeIn99$"
$Description = "Test Account"


$ComputerName = $env:COMPUTERNAME

$ErrorActionPreference = "SilentlyContinue"

# Create User Account
$Computer = [ADSI]("WinNT://" + $ComputerName + ",computer")
$User = $Computer.Create("User",$UserName)

# Set Password
$User.SetPassword($Password)
$User.SetInfo()	
        
# Set PW To Never Expire
$User.PasswordExpired = 0 
$User.SetInfo()
$WMI = Get-WmiObject -class "Win32_UserAccount" -filter "name='$UserName'" 
$WMI.PasswordExpires = $false 
$WMI.Put() 
		

# Set Account Description
If($Description -gt 0)
{
	$objUser.Description = $Description
	$objUser.SetInfo()
}
		
# Add to Groups
$LocalGroup = [ADSI]"WinNT://$ComputerName/Administrators"
$UserAccount = [ADSI]"WinNT://$ComputerName/$UserName"
$LocalGroup.Add($UserAccount.Path)
$LocalGroup.SetInfo()
		
# Set SpecialAccounts Reg Key
$regPath = "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
New-Item -Path "$regPath" -Name SpecialAccounts | Out-Null
New-Item -Path "$regPath\SpecialAccounts" -Name UserList | Out-Null
New-ItemProperty -Path "$regPath\SpecialAccounts\UserList" -Name $UserName -Value 0 -PropertyType DWord | Out-Null
		
Write-Host "Done!" -ForegroundColor Green