0

Im trying to run one PowerShell script using C# application.

Get-CimInstance MSStorageDriver_FailurePredictStatus -Namespace root\wmi |select PredictFailure

I am running this script from c# application which is not running as admin and this script is giving me an error

access denied-HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand

On some R&D I got that Ciminstance need admin access to run so I wanted to know how to run get-ciminstance as non-admin user. Please suggest me any way to run this script as System or with highest privilege.

James Z
  • 12,209
  • 10
  • 24
  • 44
Shivani G
  • 71
  • 2
  • 13
  • 1
    As **Admin** or as [**System**](https://stackoverflow.com/a/51612478/1701026)? – iRon Jan 04 '22 at 12:25
  • I want to run script as System – Shivani G Jan 04 '22 at 12:47
  • I am running this script from c# application which is not running as admin and this script is giving me an error(access denied-HRESULT 0x80041003,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand ). On some R&D I got that Ciminstance need admin access to run so I wanted to know how to run `get-ciminstance` as non-admin user. – Shivani G Jan 04 '22 at 13:23
  • You can set the set WMI namespace security using the [MMC snap-in located in the Control Panel](https://learn.microsoft.com/en-us/windows/win32/wmisdk/setting-namespace-security-with-the-wmi-control) – iRon Jan 04 '22 at 13:51
  • Can we set this from script only? As we can't perform above operations because application is already installed on different machine. So we want modify our script only. – Shivani G Jan 04 '22 at 13:57
  • That is not possible (catch22): you will require admin privileges to change the security privileges... – iRon Jan 04 '22 at 14:02
  • Okay.. thank you – Shivani G Jan 06 '22 at 05:35

0 Answers0