PSRemotingTransportException while using WinRM – IIS Web App Deployment

Question:

I have configure the winrm.

I am getting below response after running winrm quickconfig as the winrm service is already running.

Also,
If I Do New-PSSession -ComputerName DESKTOP-0DNHIDE

I am getting below output

I am also able to establish PSConnection using

But Still when I try to deploy CSharp application using Azure Devops Pipeline getting below error

I am using WinRM – IIS Web App Deployment task in azure devops pipeline for deploying CSharp application on local IIS Server.

AzureDevops agent is configured for my local machine.

Complete log from Release pipeline is below:

Answer:

You need to rebuild the WinRM on remote machine.

You should take backup of WinRm before you rebuild.

Corrupt WMI. Follow the steps below.

First Step to Try
1. Disable and stop the WMI service.
a. sc config winmgmt start= disabled
b. net stop winmgmt

  1. Run the following commands.
    a. Winmgmt /salvagerepository %windir%\System32\wbem
    b. Winmgmt /resetrepository %windir%\System32\wbem
  2. Re-enable the WMI service and then reboot the server to see how it goes.
    a. sc config winmgmt start= auto

If the problem remains, then try the following steps to rebuild the repository:

  1. Disable and stop the WMI service.
    a. sc config winmgmt start= disabled (note that there is a blank between ‘=’ and ‘disabled’)
    b. net stop winmgmt
  2. Rename the repository folder (located at %windir%\System32\wbem\repository) to repository.old.
  3. Re-enable the WMI service.
    a. sc config winmgmt start= auto
  4. Reboot the server to see if the problem remains.

If the problem remains, then try the following steps
Re-register all of the dlls and recompile the .mofs in the wbem folder and re-registering WMI Service and Provider. You can use the following script by saving to txt file then renaming to .bat and running from command prompt with admin right and changing focus to following directory: C:\Windows\System32\Wbem.
@echo off
sc config winmgmt start= disabled
net stop winmgmt /y
%systemdrive%
cd %windir%\system32\wbem
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %
wmiprvse /regserver
winmgmt /regserver
sc config winmgmt start= auto
net start winmgmt
for /f %s in (‘dir /s /b *.mof *.mfl’) do mofcomp %s
b. Reboot the machine and test WMI
Warning: Rebuilding the WMI repository has resulted in some 3rd party products not working until their setup is re-run & their MOF re-added back to the repository.

If /salvagerepository or /resetrepository does not resolve the issue, then manually rebuild repository:
1. Change startup type to Window Management Instrumentation (WMI) Service to disabled
2. Stop the WMI Service; you may need to stop IP Helper Service first or other dependent services before it allows you to stop WMI Service
3. Rename the repository folder: C:\WINDOWS\system32\wbem\Repository to Repository.old
4. Open a CMD Prompt with elevated privileges
5. CD C:\windows\system32\wbem
6. for /f %s in (‘dir /b /s *.dll’) do regsvr32 /s %s
7. Set the WMI Service type back to Automatic and start WMI Service
8. cd /d c:\ ((go to the root of the c drive, this is important))
9. for /f %s in (‘dir /s /b *.mof *.mfl’) do mofcomp %s
10. Reboot the server

Win2012 Possible Fix.
Go to C:\WINDOWS\system32\wbem\
Rename Repository to Repository.old
Locate a Repository.xxx folder from a date before WMI was broken and rename to Repository.
Reboot Server

Source:

PSRemotingTransportException while using WinRM – IIS Web App Deployment by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply