A drive with the name 'WSMan' does not exist

Hi
On Ubuntu 20.04 with powershell 7.1, the following command

Set-Item WSMan:\localhost\Client\TrustedHosts -Value $RemoteMachine -force

returns this error

Line |
  59 |  Set-Item WSMan:\localhost\Client\TrustedHosts -Value $RemoteMachine - …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot find drive. A drive with the name 'WSMan' does not
     | exist.

The value of $RemoteMachine is 10.1.1.50. I don’t have that problem with powershell 5.1 on windows 10.
Any idea about that?

Mahmood,
Welcome tot he forums.

The error is actually pretty obvious, don’t you think? This provider does not exist. I don’t have experience with PowerShell on Linux but I’d think certain providers are available exclusively on Windows.

To get a list of the available providers you can run

Get-PSProvider

On windows I get

PS C:\Users\user> Get-PSProvider

Name                 Capabilities                                        Drives                                             
----                 ------------                                        ------                                             
Registry             ShouldProcess, Transactions                         {HKLM, HKCU}                                       
Alias                ShouldProcess                                       {Alias}                                            
Environment          ShouldProcess                                       {Env}                                              
FileSystem           Filter, ShouldProcess, Credentials                  {C, D}                                             
Function             ShouldProcess                                       {Function}                                         
Variable             ShouldProcess                                       {Variable}                                         
VimInventory         None                                                {vis, vi}                                          
VimDatastore         Filter, ShouldProcess                               {vmstores, vmstore}  

On linux I get

PS /home/mahmood> Get-PSProvider

Name                 Capabilities                                  Drives
----                 ------------                                  ------
Alias                ShouldProcess                                 {Alias}
Environment          ShouldProcess                                 {Env}
FileSystem           Filter, ShouldProcess, Credentials            {Temp, /}
Function             ShouldProcess                                 {Function}
Variable             ShouldProcess                                 {Variable}

Is there any way to get WSMan on linux by installing modules? Or it is specific for windows?

Actually I miss the line with the WSMAN provider. On my Windows it looks like this:

Name         Capabilities                        Drives
----         ------------                        ------
WSMan        Credentials                         {WSMan}

Actually I don’t know. You may use remoting to use the wsman provider on the target Windows computer.