Powershell : same input command, but different outputs depending on remote / local execution

萝らか妹 提交于 2019-12-12 05:33:24

问题


I have to check if a driver is installed on a virtual machine.
I need to output a drivers list using Powershell (msinfo32.exe -> Software Components, System Drivers).
The (impersonated) user account I want to check is "test".
When I run my command locally with "test" using Remote Desktop, it works fine, I get all drivers :

PS C:\Users\test> Get-WmiObject win32_systemdriver

So I can check if the concerned driver is running :

PS C:\Users\test> Get-WmiObject win32_systemdriver | Where-Object{$_.name -eq "vsepflt"}

DisplayName : VFileFilter
Name        : vsepflt
State       : Running
Status      : OK
Started     : True

Now I need to do this from my computer, but It doesn't output the full list (just 3 instead) :

PS C:\Users\lh> Get-WmiObject win32_systemdriver -ComputerName $ip -Credential $credTest

DisplayName : Common Log (CLFS)
Name        : CLFS
State       : Running
Status      : OK
Started     : True

DisplayName : NetBT
Name        : NetBT
State       : Running
Status      : OK
Started     : True

DisplayName : Remote Access Auto Connection Driver
Name        : RasAcd
State       : Stopped
Status      : OK
Started     : False

So of course I can't check the concerned driver, because it is not in the list, and it should be.

Note: it works if I use an Admin account as credential on the same VM, I get the full list. So I can look for my driver :

PS C:\Users\lh> Get-WmiObject win32_systemdriver -ComputerName $ip -Credential $credAdmin | Where-Object{$_.name -eq "vsepflt"}

DisplayName : VFileFilter
Name        : vsepflt
State       : Running
Status      : OK
Started     : True

That's what I need it to output from the "test" account

Why don't I get the full list on the user account remotly, but I get it if I run my command locally ? And how to fix it ?
Thanks

Edit : same results using Invoke-command and Enter-PSSession.

Edit 2 : if it makes any difference, my machine runs PS 4.0, and the VM (with both Admin and "test" users) runs 3.0.

来源:https://stackoverflow.com/questions/37110746/powershell-same-input-command-but-different-outputs-depending-on-remote-loc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!