Get-WindowsCapability Name

Hello, I am trying to get the Names of the tools that are installed but it gives me the following

Installing the RSAT Tools Microsoft.Dism.Commands.BasicCapabilityObject.Name
Installing the RSAT Tools Microsoft.Dism.Commands.BasicCapabilityObject.Name
Installing the RSAT Tools Microsoft.Dism.Commands.BasicCapabilityObject.Name

The Code is

$Install = Get-WindowsCapability -Online | Where-Object {$.Name -like “Rsat*” -AND $.State -eq “Installed”}

foreach ($Item in $Install) { Write-Host “Installing the RSAT Tools $Item.Name” }

 

You have issues in your syntax.

Try it this way…
Remember that PowerShell has many natural line breaks to break up very long lines of code to make it more readable.
The pipe, comparison operators, math symbols, etc., are just a few.

Get-WindowsCapability -Online | 
Where-Object {$_.Name -like 'Rsat*' -and $_.State -eq 'Installed'} | 
ForEach{"Installing the RSAT tool $($_.Name)"}

# Results

Installing the RSAT tool Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.BitLocker.Recovery.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.CertificateServices.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.DHCP.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.Dns.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.FailoverCluster.Management.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.FileServices.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.IPAM.Client.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.LLDP.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.NetworkController.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.NetworkLoadBalancing.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.RemoteAccess.Management.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.RemoteDesktop.Services.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.ServerManager.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.Shielded.VM.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.StorageMigrationService.Management.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.StorageReplica.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.SystemInsights.Management.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.VolumeActivation.Tools~~~~0.0.1.0
Installing the RSAT tool Rsat.WSUS.Tools~~~~0.0.1.0