Powershell

How to Export a PFX Certificate from Azure Key Vault

Azure Key Vault is a convenient place to store and manage SSL/TLS certificates, but there are times when you need to take a certificate out of Key Vault and use it somewhere else. For example, you may need to export a certificate as a PFX (.pfx) file so that it can be installed on a Windows server, imported into IIS, configured on another application, or transferred to a system that cannot retrieve certificates directly from Azure Key Vault. In this guide, I’ll show you how to export a certificate from Azure Key Vault using PowerShell, including how to protect the resulting PFX file with a password. Before you start There is an important limitation to be aware of before attempting to export a certificate. The certificate’s private key must have been created as exportable. When a certificate is created in Azure Key Vault, its certificate policy determines whether the private key can be exported. If the certificate was created with a non-exportable private key, you cannot simply change the setting later and export the private key. Microsoft also notes that exportable keys are supported for RSA and EC keys, while HSM-backed keys are non-exportable. This distinction is important because downloading the certificate itself is not necessarily the same as exporting the private key. A certificate without its private key is generally not sufficient when you need to install it on another server. What is stored in Azure Key Vault? When you create a certificate in Azure Key Vault, Key Vault maintains several related objects. The certificate contains the X.509 certificate information, while an associated secret contains the certificate value. When the certificate is exportable, the secret can contain the certificate together with its private key. This is why the PowerShell method below retrieves the secret rather than simply downloading the certificate. What you will need You’ll need: If you are using a workstation with the Az PowerShell modules installed, you can first authenticate with: If you have multiple Azure subscriptions, make sure you are working in the correct one: You can change subscriptions with: Export the certificate as a PFX The simplest approach is to retrieve the certificate’s associated secret, decode the Base64 value and write it to a .pfx file. For example: Microsoft documents this approach for exporting the certificate and private key from Key Vault. At this point you should have: However, there is an important detail with this method. The exported PFX may not have the password you want The certificate value stored by Key Vault can be retrieved as a PFX, but if you need to provide the certificate to another administrator or application, you may want to create a new password-protected PFX. That’s where the following approach is useful. Export the certificate and apply a new PFX password The following script retrieves the certificate from Key Vault, loads it with its private key and then exports it again as a password-protected PFX. This produces a PFX file protected by the password you specify. Why retrieve the secret instead of the certificate? This is one of the slightly confusing aspects of Azure Key Vault. If you run: you are retrieving the Key Vault certificate object and its metadata. That includes information such as: The private key isn’t exposed directly through the certificate object. The associated Key Vault secret is what contains the certificate value that can include the private key when the certificate is exportable. That’s why the export process ultimately uses: rather than only: Verify the PFX file Before copying the certificate to another server, it’s a good idea to verify that the PFX contains the private key. On Windows, you can use PowerShell: You want: for: You can also inspect the certificate using the Windows certificate import wizard. Right-click the .pfx file and select Install PFX. During the import process, Windows will ask for the password you assigned to the PFX. Exporting through the Azure Portal You don’t necessarily need PowerShell. Azure Key Vault also provides certificate download options through the Azure portal. Navigate to: Azure Portal → Key Vault → Certificates → Your Certificate → Current Version Depending on the certificate and configuration, you can use the download option to obtain the certificate in formats such as CER or PFX/PEM. The portal is convenient for a one-off export, while PowerShell is much more useful if you need to repeat the process or incorporate it into an administrative workflow. One thing to be aware of is that Azure Key Vault does not retain a certificate import password for later export. Microsoft states that when a certificate is exported from Key Vault, the export password is blank; if you need a PFX protected with a specific password, you can re-export it with PowerShell as shown above. What if the private key is missing? If the resulting certificate doesn’t contain a private key, the first thing to check is whether the Key Vault certificate was created as exportable. You can inspect the certificate in the Azure portal and review its configuration. If the certificate was created with a non-exportable private key, Azure Key Vault will not provide the private key when the certificate is retrieved as a secret. Unfortunately, you cannot turn a non-exportable private key into an exportable one after the fact. In that situation, you may need to create or import a new certificate with an exportable private key, depending on your security requirements. Security considerations A PFX file containing a private key should be treated as a sensitive credential. Once you export it from Key Vault: This is particularly important because one of the advantages of Azure Key Vault is that applications can use certificates without requiring administrators to distribute private-key files manually. Microsoft recommends limiting who can export certificates containing private keys and auditing certificate access and export operations. Azure CLI alternative If you prefer Azure CLI, you can retrieve the certificate’s public portion with: However, that downloads the public portion of the certificate. To retrieve the certificate including its private

How to Export a PFX Certificate from Azure Key Vault Read More »

How to Install All RSAT Tools on Windows 11 Using PowerShell

Remote Server Administration Tools (RSAT) are a collection of Windows tools that allow administrators to remotely manage Windows Server and services such as Active Directory, DNS, DHCP and Group Policy from a Windows client PC. If you regularly manage Windows environments, RSAT is one of those toolsets that is worth having installed on your administrator workstation. This guide shows how to install RSAT on Windows 11 using PowerShell, including how to install all available RSAT components at once. It also covers the graphical installation method and how to install only the RSAT tools you actually need. What is RSAT? RSAT stands for Remote Server Administration Tools. Rather than logging directly onto a Windows Server every time you need to perform an administrative task, RSAT allows many of the familiar Windows administration tools to be installed on your Windows client computer. For example, RSAT includes tools for: The exact RSAT components available can vary depending on the version and architecture of Windows you are running. RSAT on Windows 11 On modern versions of Windows, RSAT is provided as Features on Demand rather than as the old standalone RSAT installer. Microsoft provides RSAT through Windows’ optional features system, and the tools can be installed either through the Windows 11 Settings application or using PowerShell. This makes PowerShell particularly useful if you are setting up an administrator workstation or need to install the same tools on multiple machines. Check which RSAT tools are available Before installing anything, open PowerShell as Administrator and run: You should see a list similar to: The State column tells you whether each component is installed. For example: means the component is already installed, while: means it is available but has not been installed. Install all RSAT tools using PowerShell If you want to install every RSAT component that is currently available, you can use the following PowerShell script: Run PowerShell as Administrator. The script finds every RSAT capability that is not currently installed and passes each one to Add-WindowsCapability. Windows will obtain the required components through the configured Windows servicing source, normally Windows Update. Microsoft documents Add-WindowsCapability as the PowerShell cmdlet used to add Windows capabilities to the running operating system. A shorter version If you prefer a one-liner, you can use: I prefer the longer version because it displays which component is currently being installed. Install only the RSAT tools you need You don’t necessarily need to install every RSAT component. For example, if you primarily manage Active Directory, you can install the Active Directory tools with: For DNS: For DHCP: For Group Policy: You can find the exact capability names on your machine using: Check which RSAT tools are installed To display only the RSAT components that have already been installed: This is useful if you are troubleshooting an administrator workstation or want to confirm that a particular RSAT component has installed successfully. Installing RSAT through the Windows 11 GUI If you don’t want to use PowerShell, RSAT can also be installed through Windows 11. Open: Settings → System → Optional features Then select: View features Search for: RSAT Windows will display the available RSAT components. Select the tools you need and click Next → Install. Microsoft notes that the exact location of Optional Features can vary between Windows 11 releases, particularly on older builds, but the current Windows 11 interface places it under Settings → System → Optional features. You can also open the Optional Features page directly by pressing Win + R and entering: Why use PowerShell instead? For a single PC, the graphical interface is perfectly fine. PowerShell becomes much more useful when you are: For example, the script can be incorporated into a larger workstation deployment process. Installing RSAT without Windows Update There are situations where Windows cannot obtain the RSAT components from Windows Update. This can happen on machines that are restricted from accessing Windows Update, or in environments where servicing is controlled through enterprise management infrastructure. In those situations, Microsoft provides Windows Features on Demand media that can be used as an installation source. For Windows 11, this is provided through the Languages and Optional Features media. You can then specify a local source with Add-WindowsCapability: Replace D: with the drive letter of your mounted Features on Demand media. This is particularly useful when working with controlled or offline Windows environments. Troubleshooting RSAT installation RSAT is not appearing in Optional Features First check whether Windows can see the RSAT capabilities: If the command returns RSAT components, they are available to the operating system even if you cannot easily find them through the Settings interface. Installation fails with a Windows Update error If Add-WindowsCapability fails, check that the computer can communicate with its configured Windows Update or servicing source. You can also try specifying a Features on Demand source using the -Source parameter. Check the Windows version Run: or: This is useful when troubleshooting RSAT because Features on Demand packages need to correspond to the Windows version being serviced. Windows 11 ARM64 considerations There is an important exception for administrators using Windows 11 on ARM64 devices. Microsoft currently documents that, on Windows 11 25H2 ARM64, RSAT Features on Demand are not supported for some tools. A subset of RSAT tools can instead be accessed through the Windows Features interface. If you are using a conventional x64 Windows 11 PC, this limitation generally isn’t relevant. Verify that the tools are working After installation, open the Start menu and search for: Windows Tools Depending on the components installed, you should see tools such as: You can then use these tools to manage your Windows Server environment remotely. Conclusion RSAT is an essential set of tools for anyone who regularly administers Windows Server environments. While Windows 11 provides a straightforward graphical installation method, PowerShell makes the process considerably easier when setting up administrator workstations or deploying the same tools across multiple machines. If you simply want everything installed, the following command is all you really need: Run it from an elevated PowerShell session,

How to Install All RSAT Tools on Windows 11 Using PowerShell Read More »