WSMan does not exist.

394 views
Skip to first unread message

MKPhil

unread,
May 24, 2018, 5:25:40 AM5/24/18
to Ansible Project
I'm trying to set up a Windows 2008R2 server using the ConfigureRemotingForAnsible.ps1 script but I get the error:


dir : Cannot find drive. A drive with the name 'WSMan' does not exist.
At line:98 char:3
+   dir 'WSMan:\localhost\Plugin\' -Force:$force | ? { $_.name -like "$filter" } | ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (WSMan:String) [Get-ChildItem], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

  • PowerShell 4.0 is installed
  • The script is being run as Administrator
  • If I run winrm qc is says WinRM is already set up

The same script has worked on over 4000 other servers without a problem but I am stuck on this one!  What am I missing?




Jordan Borean

unread,
May 24, 2018, 6:13:08 AM5/24/18
to Ansible Project
Are you sure you are running the same script as what is at https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1. Line 98 is blank and we don't run "dir 'WSMan:\localhost\Plugin\'..." at all in that script. Does WSMan appear in the list after running "Get-PSDrive"?

Thanks

Jordan

MKPhil

unread,
May 24, 2018, 9:09:49 AM5/24/18
to Ansible Project
Hi Jordan,
I am running the latest script.  If I step through the script in Debug mode of the PowerShell ISE, it hits line 278: 
If (!(Get-PSSessionConfiguration -Verbose:$false) -or (!(Get-ChildItem WSMan:\localhost\Listener)))
It evaluates the Get-PSSessionConfiguration part OK and then the ISE opens Microsoft.WSMan.Management.psd1 [Read Only] and then the error is thrown.


WSMan isn't in the Get-PSDrive list:
PS C:\Windows\system32> get-psdrive


Name           Used (GB)     Free (GB) Provider      Root                                               CurrentLocation
----           ---------     --------- --------      ----                                               ---------------
Alias                                  Alias
C                  
35.09          4.81 FileSystem    C:\                                               Windows\system32
Cert                                   Certificate   \
D                  
49.58           .41 FileSystem    D:\
Env                                    Environment
Function                               Function
HKCU                                  
Registry      HKEY_CURRENT_USER
HKLM                                  
Registry      HKEY_LOCAL_MACHINE
P                  
15.71          1.28 FileSystem    P:\
Variable                               Variable

I'm thinking WinRM is corrupt on this server - any ideas how to fix that?

Jordan Borean

unread,
May 24, 2018, 5:00:10 PM5/24/18
to Ansible Project
Thanks for the info, should have realised it was in one of the cmdlets called.  Sounds like WSMan is hosed if the WSMan provider isn't listed as a PSDrive, I've never come across this before so not sure what the fix would be, usually I would just rebuild a new server.

Thanks

Jordan
Reply all
Reply to author
Forward
0 new messages