Function Get-PCRename($ComputerName){

    if(Test-Connection -ComputerName $ComputerName -Count 1)
    {
        $User = $env:username
        $DomainUser = "int\$User"
            
        Write-Host "Current Hostname: $ComputerName"
        $NewHostName = Read-Host "New Hostname"

        $res = Rename-Computer -ComputerName $ComputerName -NewName $NewHostName -DomainCredential $DomainUser -force -Restart -PassThru
        if ($res.HasSucceeded) {
            Write-Host "Renamed PC, successful. Restarting PC... Old Hostname: $ComputerName, New Hostname: $NewHostName" -ForegroundColor Green
        } else {
            Write-Host "Failed to rename PC. Check user credentials" -ForegroundColor Red
        }

    }else{
        
        Write-Host "Unable to connect to PC...Cancelling PCRename script on $ComputerName" -ForegroundColor Red
    }
    
}
