Powershell docker image, Restart-Computer cmd missing 'ComputerName' parameter

Anonymous
2024-12-02T12:14:39+00:00

Trying to remotely restart a windows computer with powershell and Restart-Computer command.

Powershell is running from a docker container with mcr.microsoft.com/powershell image, and from within the docker container i am running a powerhell script.

The script is also tested on a windows 11 machine with powershell and it works as expected.

Output from the script running from powershell in docker, PowerShell 7.4.2.

PS />/root/scripts/restart.ps1

Restart-Computer: /root/scripts/restart.ps1:9

Line |

9 |  Restart-Computer -ComputerName $server -Credential $credObject -Force …

|                   ~~~~~~~~~~~~~

| A parameter cannot be found that matches parameter name 'ComputerName'.

From the help it look likes there is a ComputerName parameter.

PS /> Get-Help Restart-Computer

NAME

Restart-Computer

SYNOPSIS

Restarts the operating system on local and remote computers.

SYNTAX

Restart-Computer [[-ComputerName*] <System.String[]>] [[-Credential] <System.Management.Automation.PSCredential>] [-Delay <System.Int16>] [-For {Wmi | WinRM | PowerShell}] [-Force] [-Timeout <System.Int32>] [-Wait] [-WsmanAuthentication {Basic*

| CredSSP | Default | Digest | Kerberos | Negotiate}] [-Confirm] [-WhatIf] [<CommonParameters>]

Obviously there is no parameter 'ComputerName' in the Restart-Computer command?

PS /> Get-Help * -Parameter ComputerName

Name                              Category  Module                    Synopsis

----                              --------  ------                    --------

Enter-PSSession                   Cmdlet    Microsoft.PowerShell.Core …

Get-PSSession                     Cmdlet    Microsoft.PowerShell.Core …

Invoke-Command                    Cmdlet    Microsoft.PowerShell.Core …

New-PSSession                     Cmdlet    Microsoft.PowerShell.Core …

Receive-Job                       Cmdlet    Microsoft.PowerShell.Core …

Remove-PSSession                  Cmdlet    Microsoft.PowerShell.Core …

PS /> Get-Help * -Parameter ComputerName

Name                              Category  Module                    Synopsis

----                              --------  ------                    --------

Enter-PSSession                   Cmdlet    Microsoft.PowerShell.Core …

Get-PSSession                     Cmdlet    Microsoft.PowerShell.Core …

Invoke-Command                    Cmdlet    Microsoft.PowerShell.Core …

New-PSSession                     Cmdlet    Microsoft.PowerShell.Core …

Receive-Job                       Cmdlet    Microsoft.PowerShell.Core …

Remove-PSSession                  Cmdlet    Microsoft.PowerShell.Core …

Regards Fredric Andersson

***moved from Windows / Other/Unknown / Other Windows apps***

Windows Server Remote and virtual desktops PowerShell

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-12-03T23:55:20+00:00

    Hello,

    Thank you for posting in Microsoft Support Community. Based on the description, I understand your question is related to PowerShell Docker image.

    Since Docker is not currently supported in the Microsoft Support Community, it is recommended to repost your question in Microsoft Q&A. https://learn.microsoft.com/en-us/answers/questions/

    Or the Powershell-Docker page on GitHub

    Issues · PowerShell/PowerShell-Docker · GitHub

    Thank you for your understanding and support. If you have any question or concern, please feel free to let us know.

    0 comments No comments