Documentation Index
Fetch the complete documentation index at: https://docs.getprimo.com/llms.txt
Use this file to discover all available pages before exploring further.
Tous les scripts ci-dessous sont fournis tels quels. Veuillez vérifier leur sortie et leurs effets avant de les déployer. Nous ne sommes pas disponibles pour assister nos clients sur ces scripts.
Modification de tous les noms d’hôtes
#!/bin/bash
# This script changes the hostname on macOS by updating:
# - ComputerName: The user-friendly name seen in Sharing preferences.
# - LocalHostName: The Bonjour name used on the local network (must be sanitized).
# - HostName: The system's POSIX name.
# - NetBIOSName: Used for SMB file sharing.
#
# Usage: sudo ./change_hostname.sh NewHostname
# Check if the new hostname is provided
if [ "$#" -ne 1 ]; then
echo "Usage: sudo $0 <new_hostname>"
exit 1
fi
NEW_HOSTNAME="$1"
# Sanitize the new hostname for LocalHostName (Bonjour) requirements:
# - Convert to lowercase, remove invalid characters (keeping only letters, numbers, and hyphens).
SANITIZED_HOSTNAME=$(echo "$NEW_HOSTNAME" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]-')
echo "Changing hostname to: $NEW_HOSTNAME"
echo "Using sanitized LocalHostName: $SANITIZED_HOSTNAME"
# Change the ComputerName (visible in Sharing settings)
sudo scutil --set ComputerName "$NEW_HOSTNAME"
# Change the LocalHostName (used for Bonjour)
sudo scutil --set LocalHostName "$SANITIZED_HOSTNAME"
# Change the HostName (the underlying POSIX hostname)
sudo scutil --set HostName "$NEW_HOSTNAME"
# Optionally, change the NetBIOS name for SMB file sharing
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$NEW_HOSTNAME"
echo "Hostname successfully updated!"
echo "A reboot might be required for all changes to fully take effect."
Certains utilisateurs peuvent rencontrer des fenêtres contextuelles d’installation répétées pour l’outil d’aide de Slack sur macOS lorsque Slack.app appartient à root, même après avoir saisi les informations d’identification d’administrateur. Pour résoudre ce problème, exécutez le script suivant sur la machine concernée en tant qu’administrateur pour remplacer la propriété de Slack.app par l’utilisateur actuellement connecté :#!/bin/bash
get_target_user() {
local u
u=$(/usr/bin/stat -f "%Su" /dev/console)
if [[ "$u" == "loginwindow" || "$u" == "root" ]]; then
u=$(/usr/bin/defaults read /Library/Preferences/com.apple.loginwindow lastUserName 2>/dev/null || true)
fi
echo "$u"
}
TARGET_USER="$(get_target_user)"
if [[ -z "$TARGET_USER" ]]; then
echo "Unable to determine target user, aborting."
exit 1
fi
echo "Current owner of /Applications/Slack.app:"
ls -ld "/Applications/Slack.app"
echo "Changing ownership to $TARGET_USER..."
sudo chown -R "$TARGET_USER" "/Applications/Slack.app"
echo "Ownership updated. Please retry launching Slack."
Remarques :
- Exécutez ce script avec les privilèges d’administrateur ou avec Fleet
- Ce script détecte l’utilisateur actuellement connecté et change de propriétaire de manière récursive.
- Vérifiez toujours la sortie du script et la propriété de Slack.app après l’exécution.
- Ce correctif répond aux invites d’installation liées aux autorisations provoquées par la propriété root de Slack.app.
- Utilisez une automatisation de stratégie Fleet pour exécuter ce script automatiquement :
SELECT 1 FROM file WHERE path LIKE '/Applications/Slack.app/%%' and uid != 0;
Supprimer le blocage USB
# Run as Admin
Write-Host "Removing RemovableStorage Blocking..." -ForegroundColor Cyan
# CSP Paths
$paths = @(
"HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\ADMX_RemovableStorage",
"HKLM:\SOFTWARE\Microsoft\PolicyManager\current\user\ADMX_RemovableStorage"
)
foreach ($path in $paths) {
if (Test-Path $path) {
Remove-Item -Path $path -Recurse -Force
Write-Host "Key removed : $path" -ForegroundColor Green
} else {
Write-Host "Key not found : $path" -ForegroundColor Yellow
}
}
# Refresh policies
gpupdate /force
Write-Host "USB should now be usable" -ForegroundColor Green