Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Mac OSX – Computer Name

Posted on August 5, 2016 By David Kittell
# Name the Machine in all areas the same - Start
# Get Serial Number
sSerialNumber=$(system_profiler SPHardwareDataType |grep "Serial Number (system)" |awk '{print $4}'  | cut -d/ -f1)
echo $sSerialNumber
 
# Ask User if the computer is a laptop
printf "Is this a laptop, if yes type y or if no type n followed by [ENTER]:"
read sLaptop
#echo "$sLaptop provided"
case $sLaptop in
"y")
sMachineName="L$sSerialNumber"
;;
"n")
sMachineName="D$sSerialNumber"
;;
*)
sMachineName=$sSerialNumber
;;
esac
echo $sMachineName
 
sudo scutil --set HostName $sMachineName
sudo scutil --set ComputerName $sMachineName
sudo scutil --set LocalHostName $sMachineName
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $sMachineName
# Name the Machine in all areas the same - Stop
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Mac OS X Shell Mac OSX UNIX UNIX Shell Scripts

Post navigation

Previous post
Next post

Related Posts

PowerShell – Disable Auto Run In Windows

Posted on April 8, 2016April 8, 2016

function Disable-AutoRun { $item = Get-Item ` "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\AutoRun.inf" ` -ErrorAction SilentlyContinue if (-not $item) { $item = New-Item "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\AutoRun.inf" } Set-ItemProperty $item.PSPath "(default)" "@SYS:DoesNotExist" } function Enable-AutoRun { Remove-Item "REGISTRY::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\AutoRun.inf" -Force } Disable-AutoRun # Enable-AutoRun $path =’HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer’ Set-ItemProperty $path -Name NoDriveTypeAutorun -Type DWord -Value 0xFF Reference: http://stackoverflow.com/questions/14564380/how-to-disable-autorun-for-all-drives…

Read More

Azure CLI – List All VMs with Details

Posted on December 24, 2017

az vm list –show-details –query ‘[].{VMName:name, OSType:storageProfile.osDisk.osType,VMSize:hardwareProfile.vmSize, Location: location,ResourceGroup:resourceGroup,PowerState:powerState, privateIPs: privateIps}’ -o table All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is…

Read More

PowerShell – Get IPv4 Machine IP

Posted on November 12, 2015March 10, 2016

Approach 1 $ip=get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1} $serverIP = $ip.ipaddress[0] Approach 2 $computername = $env:COMPUTERNAME #Test-Connection $computername -count 1 | select Address,Ipv4Address Test-Connection $computername -count 1 | select @{Name="Computer Name";Expression={$_.Address}},@{Name="IPv4 Address";Expression={$_.Ipv4Address}} Approach 3 – More Details $colItems = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace "root\CIMV2" | where{$_.IPEnabled -eq "True"} clear Write-Host "# ————————————–"…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes