Closed teskemj closed 3 years ago
It seems there is a conflict between core modules: PS7 vs. Windows PowerShell
PS C:\Users\max_t> Get-Module -L Microsoft.PowerShell.Management Directory: C:\program files\powershell\7\Modules ModuleType Version PreRelease Name PSEdition ExportedCommands ---------- ------- ---------- ---- --------- ---------------- Manifest 7.0.0.0 Microsoft.PowerShell.Management Core {Add-Content, Clear-Content, Get-Clipbo… Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules ModuleType Version PreRelease Name PSEdition ExportedCommands ---------- ------- ---------- ---- --------- ---------------- Manifest 3.1.0.0 Microsoft.PowerShell.Management Core,Desk {Add-Content, Clear-Content, Clear-Item… PS C:\Users\max_t>
It can't find it the Add-Computer help files and is returning something else. And, it doesn't even work if you use the following command:
Import-Module Microsoft.PowerShell.Management -UseWindowsPowerShell
Something is going on! :)
Cool...I was just poking around between Windows Powershell and 7 as I'm onboarding systems and wanted to test out 7.
I am using PowerShell 7.0 as released in Windows 10. This fails here too.
The command executes, but look at the help. It displays the help for select-XML :)
@doctordns
This happens to me in the beginning, then I realized that the help for Add-Computer is not equal to the Select-XML help. Unless I'm missing something.
In my case, I got PowerShell 7 install in of my environments (Physical and VM's) and the Add-Computer cmdlet is not available at first. You said that works! Hum!
I wonder! How did you install PowerShell 7? I use the "PowerShell-7.0.0-win-x64.msi". :)
Installed using the MIS via Install-PowerShell7,ps1 script on github. Have you tried Update-Help??
OK - so I tried this on a newly created DC:
ANd if I update the help , the examples reutrn
NO Idea why the earlier command worked like that!!!
@doctordns
Yes! It works in Windows PowerShell but not in PowerShell 7.0.
It's possible there's a conflict of modules that the Get-Help can't resolve.
:)
I believe this is a side effect of https://github.com/PowerShell/PowerShell/issues/11419. Going through the code, Get-Help
initiates command discovery and finds this command in the Windows PowerShell Management module, so uses that index into the PS7 Management module help which shows the wrong content.
Can somebody with the repro please try it on the latest daily build? Thank you.
To install the latest daily build:
Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -daily"
PS C:\> $psversiontable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 0 0 daily.20200322
PS C:\> get-help add-computer
NAME
Add-Computer
SYNTAX
Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName
<string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential
@anmenaga
At least I'm not getting the Help Select-Xml now.
@anmenaga
Ah! No luck!
I just did an Update-Help -Force and the issue came back. Sorry!
Just did a little investigation: it looks like this is a symptom of the fact that you can't run Add-Computer
from 7.x due to it existing in the system32
/WinPS instance of MS.PS.Management
. @anmenaga kinda fixed this where "first one wins" with cmdlets like ConvertFrom-String
in MS.PS.Utility
, but I suspect that because MS.PS.Mgmt
is being loaded at startup time, you can never load the one system32
one that has Add-Computer.
@teskemj (or anyone else in the thread): are you able to actually run Add-Computer
at all from 7.x? I cannot, hence my conclusion above.
If that's the case, we should rename this to "Add-Computer won't run from WinPS Microsoft.PowerShell.Management"
This might answer your question.
Definitely it should be tagged! This cmdlet won't work in PS7.
I verified that this is working now in 7.1.0. If it's still failing for you on 7.1 or newer, please file a new issue.
Steps to reproduce
Expected behavior
Actual behavior
Environment data