Some flags are ignored during icinga wizard reconfiguration

Ok so, I am trying for some time now to reconfigure Icinga agent silently using powershell but each time I run the command bellow the -SelfServiceApiKey flag and the -DirectorUrl flag I think that are skiped.

Start-IcingaAgentInstallWizard `
    -AllowUpdates 1 `
    -AllowVersionChanges 1 `
    -AddFirewallRule 1 `
    -AgentVersion $version `
    -SelfServiceAPIKey $selfserviceapikey `
    -UseDirectorSelfService 1 `
    -PackageSource $packagesource `
    -CAEndpoint $caendpoint `
    -EmptyCA 0 `
    -CAPort '5665' `
    -Endpoints $endpoints `
    -EndpointConnections $endpointconnections `
    -DirectorUrl "https://$($director)/icingaweb2/director/" `
    -OverrideDirectorVars 0 `
    -Ticket '' `
    -EmptyTicket 1 `
    -InstallFrameworkPlugins 0 `
    -InstallFrameworkService 0 `
    -ServiceUser 'NT Authority\SYSTEM' `
    -RunInstaller `
    -Reconfigure;

This is the message that it is being displayed each time I try to run a reconfiguration:

[Error]: The remote host for address "https://<hostname>/icingaweb2/director/self-service/powershell-parameters?key=382a2f4c6eb1c886c2b6c1ce4b024da00a187369" could not be resolved
[Error]: Failed to connect to your Icinga Director at "https://<hostname>/icingaweb2/director/". Please try again
Please re-enter your SelfService API Key for the Host-Template in case the key is no longer assigned to your host (Defaults: "382a2f4c6eb1c886c2b6c1ce4b024da00a187369"): 

When I copy and paste the exact same key and url in the above prompt it works fine.

I have run the exact same command on a clean install (On a machine that never before had icinga configured) and it works fine.

PS: I posted the same question on the icinga-poweshell forum 10 days ago but I haven’t got any answers yet

Expected Behavior

I think that there shouldn’t be an error on these two flags

Current Behavior

There is an error

Environment

  • PowerShell Version used: 4.0
  • Operating System: Microsoft Windows Server 2012 R2 Standard
  • Icinga version: 2.12.3
  • Framework version: 1.4.0
  • Director version: 1.7.2