# Service 'McpManagementService (McpManagementService)' cannot be queried due to the following error:

**URL:** <https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939>\
**Category:** PowerShell Help\
**Created:** [October 2, 2023, 8:01am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939 "2023-10-02T08:01:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliassal2](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@eliassal2](https://forums.powershell.org/u/eliassal2)\
**Post date:** [October 2, 2023, 8:01am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/1 "2023-10-02T08:01:52Z")

</div>

Hi, I am trying to write a script to get details on a specific service in PS 7,  
`Get-service | ?($_.displayname -match "Windows Insider Service")`  
I get

> Service ‘McpManagementService (McpManagementService)’ cannot be queried due to the following error:

but no error is displayed.  
Then I try in a traditional powershell window I get nothing.  
Is there a config or dll missing in my environment?  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [October 2, 2023, 8:50am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/2 "2023-10-02T08:50:44Z")

</div>

It’s not you, PowerShell 7 seems to have a problem with that service.

```auto
Get-Service -Exclude McpManagementService | 
    Where-Object { $_.DisplayName -match 'Windows Insider Service' }

```

Or better:

```auto
Get-Service -DisplayName 'Windows Insider Service'

```

---

<div class="post-metadata">

**Author:** ![eliassal2](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@eliassal2](https://forums.powershell.org/u/eliassal2)\
**Post date:** [October 2, 2023, 9:57am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/3 "2023-10-02T09:57:42Z")

</div>

So many thanks for your help, yes the 2 work fine. But tell me, what is this service and why it is failing with PS? I need to write a couple of scripts but dont like to put -Exclude everywhere, in my scripts, I will try to match 3 or 4 services in different places. So, is there any fix for PS7? What is strange in Ps 5, it doesnt error, it returns nothing as follows  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/0/00ff33959f32c6e80f929cc9be08fef6a16c2e31.png)

---

<div class="post-metadata">

**Author:** ![eliassal2](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@eliassal2](https://forums.powershell.org/u/eliassal2)\
**Post date:** [October 2, 2023, 10:12am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/4 "2023-10-02T10:12:59Z")

</div>

Matt, I connect to my sql server and issue the following

```auto
[SQL2K12]: PS C:\Users\salam\Documents> Get-service | Where-Object($_.displayname -match "sql")
[SQL2K12]: PS C:\Users\salam\Documents> Get-service | Where-Object($_.displayname -like "*sql*")
[SQL2K12]: PS C:\Users\salam\Documents> Get-service | Where-Object($_.displayname -like "sql")

```

I get nothing as well and no errors. When I issue only  
`Get-service`  
I see that there are several SQL … services as you can notice so nnot match nor like works as well on the server . This iis happening PS7 and Traditional PS  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/6/6e4d898a23299fde0c26108454c941ada29d9095.png)

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [October 2, 2023, 10:59am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/5 "2023-10-02T10:59:42Z")

</div>

> [@eliassal2](#):
>
> I need to write a couple of scripts but dont like to put -Exclude everywhere

It’s considered best practice to filter as far to the left as possible; i.e. request only what you need, rather than request everything then filter with `Where-Object`.

> [@eliassal2](#):
>
> So, is there any fix for PS7?

No, the problem has not been fixed. See:

> <https://github.com/PowerShell/PowerShell/issues/10371#issuecomment-1459112449>
>
> \<!--
> 
> For Windows PowerShell 5.1 issues, suggestions, or feature requests plea…se use the following link instead:
> Windows PowerShell \[UserVoice\](https://windowsserver.uservoice.com/forums/301869-powershell)
> 
> This repository is \*\*ONLY\*\* for PowerShell Core 6 issues.
> 
> \- Make sure you are able to repro it on the \[latest released version\](https://github.com/PowerShell/PowerShell/releases)
> \- Search the existing issues.
> \- Refer to the \[FAQ\](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).
> \- Refer to the \[known issues\](https://docs.microsoft.com/powershell/scripting/whats-new/known-issues-ps6?view=powershell-6).
> 
> \--\>
> 
> \# Steps to reproduce
> Run in elevated PowerShell prompt:
> \`\`\`powershell
> Get-Service -Name msquic
> 
> \`\`\`
> If not run in an elevated prompt, no object is returned in PS6/7, and only the exception is shown. In PS5, the object is returned and there is no exception.
> 
> \# Expected behavior
> From PowerShell 5: 
> \`\`\`
> 
> Status Name DisplayName
> \------ ---- -----------
> Running MsQuic msquic
> 
> \`\`\`
> 
> \# Actual behavior
> From PowerShell 6.2 and 7:
> \`\`\`none
> get-service : Service 'MsQuic (MsQuic)' cannot be queried due to the following error:
> At line:1 char:1
> + get-service -name msquic
> + ~~~~~~~~~~~~~~~~~~~~~~~~
> + CategoryInfo : PermissionDenied: (System.ServiceProcess.ServiceController:ServiceController) \[Get-Service\], ServiceCommandException
> + FullyQualifiedErrorId : CouldNotGetServiceInfo,Microsoft.PowerShell.Commands.GetServiceCommand
> 
> 
> Status Name DisplayName
> \------ ---- -----------
> Running MsQuic MsQuic
> 
> \`\`\`
> 
> \# Environment data
> 
> 
> PowerShell 6.2:
> \`\`\`
> Name Value
> \---- -----
> PSVersion 6.2.1
> PSEdition Core
> GitCommitId 6.2.1
> OS Microsoft Windows 10.0.18956
> Platform Win32NT
> PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
> PSRemotingProtocolVersion 2.3
> SerializationVersion 1.1.0.1
> WSManStackVersion 3.0
> \`\`\`
> PowerShell 7: 
> \`\`\`
> Name Value
> \---- -----
> PSVersion 7.0.0-preview.1
> PSEdition Core
> GitCommitId 7.0.0-preview.1
> OS Microsoft Windows 10.0.18956
> Platform Win32NT
> PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
> PSRemotingProtocolVersion 2.3
> SerializationVersion 1.1.0.1
> WSManStackVersion 3.0
> \`\`\`

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [October 2, 2023, 11:01am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/6 "2023-10-02T11:01:41Z")

</div>

> [@eliassal2](#):
>
> ```auto
> [SQL2K12]: PS C:\Users\salam\Documents> Get-service | Where-Object($_.displayname -match "sql")
> 
> ```

You’re using parentheses `()`, you should be using braces `{}`.

---

<div class="post-metadata">

**Author:** ![eliassal2](https://avatars.discourse-cdn.com/v4/letter/e/3ab097/32.png) [@eliassal2](https://forums.powershell.org/u/eliassal2)\
**Post date:** [October 2, 2023, 11:25am UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/7 "2023-10-02T11:25:03Z")

</div>

Yes correct now it is working like a charm, so many thanks again for your help

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:14pm UTC](https://forums.powershell.org/t/service-mcpmanagementservice-mcpmanagementservice-cannot-be-queried-due-to-the-following-error/22939/8 "2024-05-16T20:14:38Z")

</div>

Closed on May 16, 2024, 8:14pm UTC


