I'm trying to run a remote command using Invoke-Command over WSMan in PowerShell on my local machine.
Here’s my test script:
$server = 'localhost'
Invoke-Command -Authentication Negotiate -ConfigurationName Powershell.7 -ComputerName $server {
Write-Host 'hello'
}
However, I get the following error:
OpenError: [localhost] Connecting to remote server localhost failed with the fol
lowing error message : The WS-Management service cannot process the request. Can
not find the Powershell.7 session configuration in the WSMan: drive on the local
host computer. For more information, see the about_Remote_Troubleshooting Help t
opic.
I try enabled remoting:
PS C:\> Enable-PSRemoting -Force
WARNING: PowerShell remoting has been enabled only for PowerShell 6+ configurati
ons and does not affect Windows PowerShell remoting configurations. Run this cmd
let in Windows PowerShell to affect all PowerShell remoting configurations.
WinRM est déjà configuré pour recevoir des demandes sur cet ordinateur.
Set-WSManQuickConfig:
Line |
121 | Set-WSManQuickConfig -force
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Erreur :Impossible d'effectuer une ou plusieurs étapes de mise à jour.
PS C:\>
Get-PSSessionConfiguration It returns nothing (no registered endpoints).
🔹 My Question:
How can I register or enable the Powershell.7 endpoint so that I can use Invoke-Command like in the example?
🔹 Additional Info: I’m using PowerShell 7 and old Windows 2012 r2
I’m aware that PowerShell 7 supports SSH remoting instead of WSMan.
However, I want to know if it’s possible to use WSMan remoting with PowerShell 7 (without SSH) or if there's an equivalent supported method to achieve this.
🔹 What I've Tried: I tried registering a session configuration manually:
Register-PSSessionConfiguration -Name 'Powershell.7' -PowerShellVersion '7.0'
But it throws this error:
Register-PSSessionConfiguration: Cannot bind parameter 'PSVersion' to the target
. Exception setting "PSVersion": "PowerShell remoting endpoint versioning is not
supported on PowerShell Core."
And, this works, but don't use correct version
$server = 'localhost'
Invoke-Command -Authentication Negotiate -ComputerName $server {
Write-Host 'hello'
}
And, Set-WSManQuickConfig don't work
WinRM Quick Configuration
Running the Set-WSManQuickConfig command has significant security implications,
as it enables remote management through the WinRM service on this computer.
This command:
1. Checks whether the WinRM service is running. If the WinRM service is not
running, the service is started.
2. Sets the WinRM service startup type to automatic.
3. Creates a listener to accept requests on any IP address. By default, the
transport is HTTP.
4. Enables a firewall exception for WS-Management traffic.
5. Enables Kerberos and Negotiate service authentication.
Do you want to enable remote management through the WinRM service on this
computer?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
WinRM est déjà configuré pour recevoir des demandes sur cet ordinateur.
Set-WSManQuickConfig: Erreur :Impossible d'effectuer une ou plusieurs étapes de
mise à jour.
PS C:\>
✅ Summary: Is it possible to fix PowerShell 7 with WSMan and Invoke-Command -ComputerName?
If not, is there any supported way to create a WSMan endpoint for PowerShell 7?