Set-RDPublishedName.ps1 gone?

ujan 21 Reputation points
2021-07-01T09:11:04.76+00:00

Cannot find Set-RDPublishedName.ps1 anymore. Is there a reason? Is there a new repo? Is there a new solution for what the script solved?
Thanks,
ujan

Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,563 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leila Kong 3,701 Reputation points
    2021-07-08T01:34:24.75+00:00

    Hello @ujan ,

    Please check the following script:

    [CmdletBinding()]
    Param(
    [Parameter(Mandatory=$True,HelpMessage="Specifies the FQDN that clients will use when connecting to the deployment.",Position=1)]
    [string]$ClientAccessName,
    [Parameter(Mandatory=$False,HelpMessage="Specifies the RD Connection Broker server for the deployment.",Position=2)]
    [string]$ConnectionBroker="localhost"
    )

    $CurrentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
    If (($CurrentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) -eq $false)
    {
    $ArgumentList = "-noprofile -noexit -file "{0}" -ClientAccessName $ClientAccessName -ConnectionBroker $ConnectionBroker"
    Start-Process powershell.exe -Verb RunAs -ArgumentList ($ArgumentList -f ($MyInvocation.MyCommand.Definition))
    Exit
    }

    Function Get-RDMSDeployStringProperty ([string]$PropertyName, [string]$BrokerName)
    {
    $ret = iwmi -Class "Win32_RDMSDeploymentSettings" -Namespace "root\CIMV2\rdms" -Name "GetStringProperty" -ArgumentList @($PropertyName) -ComputerName $BrokerName
    -Authentication PacketPrivacy -ErrorAction Stop
    Return $ret.Value
    }

    Try
    {
    If ((Get-RDMSDeployStringProperty "DatabaseConnectionString" $ConnectionBroker) -eq $null) {$BrokerInHAMode = $False} Else {$BrokerInHAMode = $True}
    }
    Catch [System.Management.ManagementException]
    {
    If ($Error[0].Exception.ErrorCode -eq "InvalidNamespace")
    {
    If ($ConnectionBroker -eq "localhost")
    {
    Write-Host "n Set-RDPublishedName Failed.nn The local machine does not appear to be a Connection Broker. Please specify then FQDN of the RD Connection Broker using the -ConnectionBroker parameter.n" -ForegroundColor Red } Else { Write-Host "n Set-RDPublishedName Failed.nn $ConnectionBroker does not appear to be a Connection Broker. Please make sure you have n specified the correct FQDN for your RD Connection Broker server.n" -ForegroundColor Red
    }
    }
    Else
    {
    $Error[0]
    }
    Exit
    }

    $OldClientAccessName = Get-RDMSDeployStringProperty "DeploymentRedirectorServer" $ConnectionBroker

    If ($BrokerInHAMode.Value)
    {
    Import-Module RemoteDesktop
    Set-RDClientAccessName -ConnectionBroker $ConnectionBroker -ClientAccessName $ClientAccessName
    }
    Else
    {
    $return = iwmi -Class "Win32_RDMSDeploymentSettings" -Namespace "root\CIMV2\rdms" -Name "SetStringProperty" -ArgumentList @("DeploymentRedirectorServer",$ClientAccessName) -ComputerName $ConnectionBroker
    -Authentication PacketPrivacy -ErrorAction Stop
    $wksp = (gwmi -Class "Win32_Workspace" -Namespace "root\CIMV2\TerminalServices" -ComputerName $ConnectionBroker)
    $wksp.ID = $ClientAccessName
    $wksp.Put()|Out-Null
    }

    $CurrentClientAccessName = Get-RDMSDeployStringProperty "DeploymentRedirectorServer" $ConnectionBroker

    If ($CurrentClientAccessName -eq $ClientAccessName)
    {
    Write-Host "n Set-RDPublishedName Succeeded." -ForegroundColor Green Write-Host "n Old name: $OldClientAccessNamenn New name: $CurrentClientAccessName"
    Write-Host "n If you are currently logged on to RD Web Access, please refresh the page for the change to take effect.n"
    }
    Else
    {
    Write-Host "n Set-RDPublishedName Failed.n" -ForegroundColor Red
    }

    Please "Accept as Answer" if it helped, which might be beneficial to other community members reading this thread. Thanks for your cooperation!

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Leila Kong 3,701 Reputation points
    2021-07-02T02:40:05.837+00:00

    Hello @ujan ,

    Thanks for your query.

    Can you download the Set-RDPublishedName.ps1 script under the following link?
    https://github.com/dwj7738/My-Powershell-Repository/blob/master/Scripts/Set-RDPublishedName.ps1

    Best regards,
    Leila

    ----------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. ujan 21 Reputation points
    2021-07-05T19:17:08.493+00:00

    Hi Leila,
    that guy is not the creator of the original script and his code is from 2015. Cannot trust that source. Were you able to verify?

    Thanks
    Jan


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.