J'essaie d'automatiser un déploiement complet de sessions Bureau à distance mais je rencontre un problème pour ajouter la passerelle via powershell. Je peux ajouter chaque serveur à l'exception de la passerelle. Ce qui produit l'erreur :
Unable to create a Remote Desktop resource authorization policy on <computer name>. The error is
Object reference not set to an instance of an object.. Please check the eventlog on RD Gateway server for more info.
Je ne vois rien dans les journaux qui pourrait m'aider à résoudre ce problème.
Si je vais dans le gestionnaire de serveur et que je l'ajoute via cette interface :
Tout fonctionne comme prévu. Y a-t-il des étapes supplémentaires à suivre pour que cela fonctionne ?
Voici le script qui est actuellement en cours d'exécution (EC2, userdata) :
<powershell>
try {
$SecretAD = "SuperSecretSauceSuzzySaid"
$SecretObj = (Get-SECSecretValue -SecretId $SecretAD)
}catch {
Write-Output 'Failed to get Secret'
return
}
$sys = Get-WmiObject -Class Win32_ComputerSystem
if ( -Not ($sys.PartOfDomain))
{
Write-Output "Not A domain member yet. Joining..."
[PSCustomObject]$Secret = ($SecretObj.SecretString | ConvertFrom-Json)
$password = $Secret.password | ConvertTo-SecureString -asPlainText -Force
$username = $Secret.username
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
Write-Output "Starting Domain Join and Restarting"
Add-Computer -DomainName "6565.fake.com" -Credential $credential -Restart -Force
Write-Output "Initiating restart..."
}
Try {
$process = (Get-NetAdapterBinding -InterfaceAlias "Ethernet" -ComponentID ms_tcpip6).Enabled
If ($process.toString() -ne "False"){
Get-NetAdapterBinding –InterfaceAlias "Ethernet"
Disable-NetAdapterBinding –InterfaceAlias "Ethernet" –ComponentID ms_tcpip6
Write-Output "Disabled ipv6"
Import-Module RemoteDesktop
Add-WindowsFeature –Name RDS-RD-Server –IncludeAllSubFeature
Write-Output "Restarting..."
Restart-Computer -Force
}
Start-Sleep 200
$installed = (Get-WindowsFeature RDS-RD-Server).Installed
If ($installed.toString() -eq "True"){
$broker = (Get-WindowsFeature RDS-Connection-Broker).Installed
If ($broker.toString() -eq "False"){
$ErrorActionPreference = 'SilentlyContinue'
Write-Output "Installing the new session deployment"
New-RDSessionDeployment -ConnectionBroker "$env:COMPUTERNAME.6565.fake.com" -SessionHost "$env:COMPUTERNAME.6565.fake.com"
Write-Output "Restarting..."
Restart-Computer -Force
}
}
Start-Sleep -Seconds 100
New-RDSessionCollection -CollectionName QuickSessionCollection -SessionHost "$env:COMPUTERNAME.6565.fake.com" -CollectionDescription "POR Stuff" -ConnectionBroker "$env:COMPUTERNAME.6565.fake.com"
Write-Output "Installing Gateway with managnent tools"
Add-WindowsFeature -Name RDS-Gateway -IncludeManagementTools -ComputerName $env:COMPUTERNAME
Start-Sleep -Seconds 100
Add-RDServer -Server "$env:COMPUTERNAME.6565.fake.com" -Role "RDS-GATEWAY" -ConnectionBroker "$env:COMPUTERNAME.6565.fake.com" -GatewayExternalFqdn "6565.fake.com"
Add-RDServer -Server "$env:COMPUTERNAME.6565.fake.com" -Role "RDS-LICENSING" -ConnectionBroker "$env:COMPUTERNAME.6565.fake.com"
} Catch [System.Exception] {
Write-Output "Failed"
Write-Output "Failed to install RD Gateway components $_"
Exit 0
}
</powershell>
<persist>true</persist>