Forum Discussion

sosayush's avatar
sosayush
Copper Contributor
Apr 03, 2021

Prerequisite Error - Access is denied

Error:

The following error was generated when "$error.Clear();

          if (Get-Service MpsSvc* | ?{$_.Name -eq 'MpsSvc'})

          {

            Set-Service MpsSvc -StartupType Automatic

            Start-SetupService -ServiceName MpsSvc

          }

        " was run: "Microsoft.PowerShell.Commands.ServiceCommandException: Service 'Windows Defender Firewall (MpsSvc)' cannot be configured due to the following error: Access is denied ---> System.ComponentModel.Win32Exception: Access is denied

   --- End of inner exception stack trace ---".

  • Kevin_Morgan's avatar
    Kevin_Morgan
    Iron Contributor

    sosayush 

     

    Open the PowerShell console with "Run as administrator" permission and run the commands again.

     

    • Click on the Start button.
    • Look for Windows PowerShell (or PowerShell Core) on the right side of the Start Menu.
    • Right-click on the menu item and choose Run as administrator.
    • Execute your script and check the case again.

Resources