rename_workstation_manual.ps1 - limehawk/rmm-scripts GitHub Wiki

rename_workstation_manual.ps1

Manually rename Windows workstation and sync to SuperOps using custom CLIENT-USERUUID pattern.

Overview

Rename a Windows device and sync the same name to SuperOps.

Naming (Windows-legal; max 15 chars; no trailing hyphen):

  • CLIENT-USERUUID
    • CLIENT : Custom override $YourCustomClientHere, else from $YourClientNameHere Variable length; sanitized A–Z0–9; trimmed if needed to ensure fit.
    • USER : Sanitized username; maximized; truncated if needed to ensure fit.
    • UUID : SMBIOS UUID tail; at least 3 chars; trimmed to fill exactly 15.

Notes:

  • Only A–Z, 0–9, and hyphen used.
  • Name never starts or ends with '-'.
  • Always exactly 15 chars.
  • SuperOps asset name is updated to match.

Purpose

Rename a Windows device and sync the same name to SuperOps. Allows manual override of client segment with custom value instead of auto-generated 3-character abbreviation.

Prerequisites

  • PowerShell 5.1 or later
  • Administrator privileges required
  • SuperOps module available
  • Internet connectivity for SuperOps API calls

Configuration

Required Inputs

  • Runtime: $YourApiKeyHere
  • Placeholders: $YourAssetIdHere, $YourClientNameHere, $YourAssetNameHere
  • Optional: $YourCustomClientHere (custom client segment override)

Settings

  • $SUPEROPS_API_KEY : SuperOps API key (injected at runtime)
  • $CUSTOM_CLIENT_SEG_INPUT : Custom client segment override
  • $SUPEROPS_SUBDOMAIN : "limehawk" (hardcoded)
  • $ASSET_ID : Asset ID placeholder
  • $ASSET_NAME_PLACEHOLDER : Asset name placeholder
  • $CLIENT_NAME_INPUT : Client name placeholder
  • $MaxUserSegmentLen : 8 (maximum username segment length)
  • $MinUuidSuffixLen : 3 (minimum UUID suffix length)
  • $MaxHostLen : 15 (maximum hostname length)

Data Sources & Priority

  1. Hardcoded values (SuperOps subdomain, length constraints)
  2. Runtime placeholders (API key, asset ID, client name, custom client override)
  3. System information (CIM)
  4. SMBIOS UUID
  5. SuperOps GraphQL API

Behavior

  1. Validates SuperOps variables and system information
  2. Uses custom client segment if provided, else derives from client name
  3. Sanitizes logged-in username
  4. Constructs CLIENT-USERUUID hostname (exactly 15 characters)
  5. Checks if current hostname already matches desired name
  6. Renames Windows computer if needed
  7. Updates SuperOps asset name via GraphQL API
  8. Reports success or handles benign rename errors

Security Notes

  • API key is injected at runtime, not hardcoded
  • No secrets logged to console
  • Uses HTTPS for SuperOps API calls
  • Validates hostname format before applying

Exit Codes

  • 0: Success
  • 1: Failure (validation error, API error, or rename failure)

Example Output

[ SUPEROPS VARIABLES ]
--------------------------------------------------------------
AssetId (placeholder)    : 12345
AssetName (placeholder)  : OLD-NAME
ClientName (placeholder) : Example Client Inc
CustomClient (override)  : CUSTOM
Subdomain (hardcoded)    : limehawk
MaxUserSegmentLen        : 8

[ RAW SYSTEM VALUES ]
--------------------------------------------------------------
ENV USERNAME             : jdoe
CIM UserName             : DOMAIN\jdoe
Current HostName (CIM)   : OLD-HOSTNAME
SMBIOS UUID              : 12345678-ABCD-EFGH-IJKL-MNOPQRSTUVWX

[ DERIVED SEGMENTS ]
--------------------------------------------------------------
CLIENT SEGMENT           : CUSTOM
USER SEGMENT             : JDOE
DESIRED/OS NAME          : CUSTOM-JDOE1234
Name Length              : 15

[ RENAME ACTION ]
--------------------------------------------------------------
CURRENT NAME(S)          : OLD-HOSTNAME
STATUS                   : RENAMING

[ SUPEROPS UPDATE ]
--------------------------------------------------------------
Updating asset name in SuperOps...
GraphQL Success

[ RESULT ]
--------------------------------------------------------------
Status                   : SUCCESS

Version History

  • v8.2.1 (2024-12-01) Fixed StrictMode error checking GraphQL response for errors.
  • v8.2.0 (2025-08-20) Clarified README: client segment is variable length; no "CLIENT3".
  • v8.1.0 (2025-08-19) Pattern CLIENT-USERUUID, min UUID=3, maximize USER, exact 15.
  • v8.0.x (2025-08-19) No separators prototype, experimental.
  • v7.4.1 (2025-08-19) Fixed PS5.1 syntax issues; removed ternary shorthand.
  • v7.4.0 (2025-08-19) Added benign rename error handling; canonical name check.
  • v7.3.x (2025-08-19) Added full README in Style A; standardized headers.
  • v7.2.x (2025-08-19) Brand segment always first word; UUID always appended.
  • v7.0 (2025-08-19) Introduced manual client override ($YourCustomClientHere).
  • v6.x (2025-08-19) Split branch from autoname for manual override use-case.
  • v5.x (2025-08-19) CLIENT/BRAND/USER baseline pattern; SuperOps sync.
  • v4.x (2025-08-19) Added GraphQL mutation to update SuperOps asset.
  • v3.x (2025-08-19) Introduced sanitization helpers & diagnostics.
  • v1–2.x (2025-08-19) Early rename iterations (no SuperOps sync).

Links