SimpleHelp Community

Rename PC Simple Help Name to Host Name


#1

We used some cloned images a while back and ended up with multiple computer names in SH showing the same name. So I wrote a toolbox powershell script to set the computer names back to there hostnames without losing the groups there in. Enjoy

$filePath = "C:\ProgramData\JWrapper-Remote Access\JWAppsSharedConfig\serviceconfig.xml"
$replacementText = "AUTODETECT"

# Check if the file exists
if (Test-Path $filePath) {
    try {
        # Load the XML content from the file
        [xml]$xml = Get-Content $filePath

        # Select all <Name> elements
        $nameElements = $xml.SelectNodes('//Name')

        # Iterate through the <Name> elements
        foreach ($nameElement in $nameElements) {
            $text = $nameElement.InnerText
            $lastSlashIndex = $text.LastIndexOf('/')
            if ($lastSlashIndex -ge 0) {
                # Replace the text after the last forward slash with AUTODETECT
                $nameElement.InnerText = $text.Substring(0, $lastSlashIndex) + "/$replacementText"
            }
        }

        # Save the modified XML back to the file
        $xml.Save($filePath)

        Write-Host "Text after the last forward slash within <Name> tags replaced with 'AUTODETECT'."
    } catch {
        Write-Host "An error occurred while processing the XML: $_" 
} 
} else {
Write-Host "File not found: $filePath" 
}

#2

Thanks for this. I was thinking about this the other day.


#3

Thanks Josh for sharing


Bulk move computers to another group?