Fix `Restart-Computer` to work on localhost when WinRM is not present by adityapatwardhan · Pull Request #9160 · PowerShell/PowerShell · GitHub
Skip to content

Fix Restart-Computer to work on localhost when WinRM is not present#9160

Merged
adityapatwardhan merged 6 commits intoPowerShell:masterfrom
adityapatwardhan:FixRestartComputer
Mar 19, 2019
Merged

Fix Restart-Computer to work on localhost when WinRM is not present#9160
adityapatwardhan merged 6 commits intoPowerShell:masterfrom
adityapatwardhan:FixRestartComputer

Conversation

@adityapatwardhan
Copy link
Copy Markdown
Member

@adityapatwardhan adityapatwardhan commented Mar 18, 2019

Fixes #8197

PR Summary

PowerShell core uses WSMan transport for all operation. When winRM is not present creating a session fails. The PR uses the default transport when the target computer is localhost. We get the instance on Win32_ComputerSystem and then call the instance method on it to restart the computer.

The PR also fixes Rename-Computer similarly.

PR Context

On winPE arm64, winRM is not present and hence Restart-Computer fails.

PR Checklist

@adityapatwardhan
Copy link
Copy Markdown
Member Author

Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
@adityapatwardhan
Copy link
Copy Markdown
Member Author

@SteveL-MSFT Please re-review, comments addressed. Rename-Computer change reverted as it is not required.

@adityapatwardhan adityapatwardhan changed the title Fix Restart-Computer and Rename-Computer to work on localhost when WinRM is not present Fix Restart-Computer to work on localhost when WinRM is not present Mar 19, 2019
Copy link
Copy Markdown
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would we test this in CIs?

Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Mar 19, 2019
iSazonov and others added 2 commits March 19, 2019 09:48
Comment thread src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs Outdated
@adityapatwardhan
Copy link
Copy Markdown
Member Author

@adityapatwardhan adityapatwardhan merged commit 0fe9af4 into PowerShell:master Mar 19, 2019
@adityapatwardhan adityapatwardhan deleted the FixRestartComputer branch March 19, 2019 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restart-Computer does not function on arm64

3 participants