Forum Discussion

Ma-Po's avatar
Ma-Po
Copper Contributor
Jan 30, 2025

Mandatory AccessKey parameter for Import-WACConnection Powershell cmdlet in 2410

Hello,

I have recently updated to Admin Center 2410, needed to do a fresh install because I ran into some Ajax error 500 problems when I dried to updrade the existing installation.

Now I had a script running one a week which fetched all AD computers and Clusters and imported them as shared connection.

I have already figured that I need to use a different path to import the Microsoft.WindowsAdminCenter.ConnectionTools module, and that the syntax for Import-Connection is now Import-WACConnection.

However, when trying to connect, the commandlet now has a mandatory AccessKey parameter.

The help suggests:

"-AccessKey <String>
        The access key to the endpoint for form login. The access key can be created from Advanced menu of Settings on Windows Admin Center UI."

However, I cannot find that option in the UI, there is only "Advanced" in the Development section of the UI, and there is no option for generating an access key.

P.S. I have installed WAC to use Kerberos integrated Windows Authentication. In the past, the Import-Connection CMDlet was also just using the credentials of the currently logged-on user.

Thank you for your help,

Marc

11 Replies

  • andyroonz's avatar
    andyroonz
    Brass Contributor

    Same issue here using Kerberos and nowhere in the GUI to create an access key. Is there a PowerShell command to generate one?

    • andyroonz's avatar
      andyroonz
      Brass Contributor

      I had a good look through the PowerShell Connection Tools Module - Microsoft.WindowsAdminCenter.ConnectionTools.psm1 found in C:\Program Files\WindowsAdminCenter\PowerShellModules\Microsoft.WindowsAdminCenter.ConnectionTools and found multiple errors:

      • Some very basic inconsistencies in variable names
      • Logical errors in the order of some lines
      • Mistakes in the names of functions being called
      • Missing parameters being passed to functions
      • Responses not being returned from some functions

      The sum of all of this is the script barely worked at all!

      I have made necessary corrections and also set the AccessKey parameter to not mandatory. My version of the script now works to import and delete connections for those using Kerberos.

      I am staggered that this script has been put in to production by Microsoft. It really is quite appalling how broken it is and how easy it would have been to check and fix the script by the developers!

      • wsim71's avatar
        wsim71
        Copper Contributor

        That sounds great, can you share your modified script ?

  • Michael_Unger's avatar
    Michael_Unger
    Copper Contributor

    Hello Marc,
    same story on my side. I installed 2410, faced Ajax 500 error when trying to connect to a server, turns out the services responds with a tcp connection reset when admin center send the ssl client hello. But that's a different story. I had the same idea as you to export the server list but now the export command requires an accesskey.
    But I couldn't find an accesskey in my installation settings and so I tried

    Export-WACConnection "https://your-admin-center" -FileName "WAC-connections.csv" -AccessKey null

     

    And it worked. I got a list of connections including the tags.

    Hope that works for you too.

     

    Regards Michael 

    • Ma-Po's avatar
      Ma-Po
      Copper Contributor

      Hello Michael,

      Thank you for that creative idea, setting the AccessKey parameter to any value definitely helped with Export-WACConnection.

      Unfortunately, with Import-WACConnection it did not, seems like the underlying REST API requires a valid access key for import:

      Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.
      At C:\Program Files\WindowsAdminCenter\PowerShellModules\Microsoft.WindowsAdminCenter.ConnectionTools\Microsoft.WindowsAdminCenter.ConnectionTools.psm1:124 char:17
      +     $response = Invoke-WebRequest @parameters
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
          + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

      At least there's a hint where to look in the code, I will do some research there.

      Regards,

      Marc

      • Michael_Unger's avatar
        Michael_Unger
        Copper Contributor

        Hello Marc,
        you are totally right with the import per Powershell. But import is the easy way as it can be done in WAC itself via Settings - > Shared Connections -> Add -> Import List

        Regards Michael

  • johansmith's avatar
    johansmith
    Copper Contributor

    Hi Marc,

    It sounds like you're dealing with a change in the Import-WACConnection cmdlet after updating to Admin Center 2410. Since you're using Kerberos authentication, the requirement for an AccessKey seems unexpected.

    To generate the AccessKey, you may need to navigate to Settings > Access in Windows Admin Center (WAC). If you don't see the option, it might be related to your authentication method or user permissions. You can check Microsoft's official documentation or community discussions for updates:

    🔹 Microsoft Tech Community - Windows Admin Center  https://techcommunity.microsoft.com/
    🔹 Microsoft Tech Community - PowerShell

    Additionally, have you tried running the command with elevated privileges (Administrator PowerShell)? If the issue persists, consider checking the latest release notes or logs for any relevant changes.

    Hope this helps! 🚀

  • luchete's avatar
    luchete
    Iron Contributor

    Hello Ma-Po!

    With the new version of Admin Center, they’ve added the AccessKey parameter for extra security when using the Import-WACConnection cmdlet. Since you're using Kerberos authentication, you don’t normally need an access key, but with this update, it's required.

    To find the AccessKey, go to the Windows Admin Center UI, then navigate to the "Settings" menu, and in the "General" section, you should see an option to generate an AccessKey under "Authentication." If you can’t find it there, it could be related to a setting in your WAC deployment or version. If it's still not showing up, I recommend checking if there's a new update or patch for Admin Center that may resolve this issue.

    I hope it helps!

    • blakeusblade's avatar
      blakeusblade
      Copper Contributor

      Hi luchete​ Ma-Po​ 


      I think luchete​  is missing the point.

      Ma-Po​ Highlighted that his requirement (which mine is too) that an import needs to happen on schedule/automatically. This will keeps the list of connections in WAC updated.

      The current solution of generating an AccessKey (Found in Settings => Under Gateway Tree on left => Reveal Access Key (Checkbox) must be manually done and can't be automated. Which means this becomes a manual process.

      Unlike many WebUI apps these days, there doesn't appear to be any way of generating a API token that works long term for the purposes of automation like I described above. 

       

      This should be a builtin feature in which the WAC admin can generate an API token and use for exactly this type of purpose.

       

Resources