Please feel free to provide feedback or file bugs here.

WMF 5.1 RestrictedRemoteServer session type fails to import the 'Microsoft.PowerShell.Utility' module

When importing this module in a restricted session type or when making a function or a cmdlet from this module visible, i.e:
VisibleFunctions = 'Get-FileHash'
the following message is returned:
WARNING: The 'Microsoft.PowerShell.Utility' module was not imported because the 'Microsoft.PowerShell.Utility' snap-in was already imported.
In practice, the module is not being imported.
Get-PSSnapin shows that a snapin with the same name is indeed loaded:
Name : Microsoft.PowerShell.Utility
PSVersion : 5.1.14409.1005
Description : This Windows PowerShell snap-in contains utility
cmdlets that are used to view and organize data in different ways.
but exposes no commands
Get-PSSnapin from a regular (not remote) session does not show this snapin.

With default session type everything is working as expected.

1 vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Ori BesserOri Besser shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    This report is a bit confusing, so need some information.
    On the system where you received this error, please try running any of the commands from Microsoft.PowerShell.Utility, such as get-member, or get-date. The error message and the information you provided seems to indicate that the module is already loaded, so we are looking for other indications that it is not.

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Ori BesserOri Besser commented  ·   ·  Flag as inappropriate

        get-date - works as expected
        get-filehash - "The term 'get-filehash ' is not recognized as the name of a cmdlet, function..."

        Based on your suggestion to run Get-Date (which worked as expected) I further investigated the issue and I can narrow it down to that:
        Exporting any of the cmdlets (like get-date, import-csv..) from 'Microsoft.PowerShell.Utility' module works as expected.
        Exporting any of this module functions (like get-filehash, New-Guid..) results in those functions not being imported at all.
        (I am "exporting" because it is a 'RestrictedRemoteServer' session type which has almost no commands by default)

        In addition, when connecting to this session configuration (enter-pssession), I get the following message if I export any 'Microsoft.PowerShell.Utility' function:
        WARNING: The 'Microsoft.PowerShell.Utility' module was not imported because the 'Microsoft.PowerShell.Utility' snap-in was already imported.
        Again, if I export only cmdlets from 'Microsoft.PowerShell.Utility' I do not get this message.

      Feedback and Knowledge Base