I have this command below that uses the WMI and Win32_process to run a command on a remote computer.The computer is called 7-df-1 in the example below.
I am having an issue with my quotes I have tried single and double quotes but the command still doesn't work. It's supposed to download a Surface firmware installer to the C drive on the remote computer.
What am I doing wrong? Thanks for looking into this
([WMICLASS]"\\7-df-1\Root\CIMV2:Win32_Process").create(“ (new-object system.net.webclient).downloadfile('https://download.microsoft.com/download/6/A/C/6ACB37C4-E4C1-4E0E-BBAE-AC7A0C303593/SurfacePro4_Win10_15063_1701801_0.msi', 'c:\save.msi')”)
Create() method accepts commandline as string, so if you simply give a PowerShell cmdlets/expression it won't recognize.
So you have to mention the handler for the particular commanline you give.
([WMICLASS]"\\localhost\Root\CIMV2:Win32_Process").create(“Powershell.exe -c &{ (new-object system.net.webclient).downloadfile('https://download.microsoft.com/download/6/A/C/6ACB37C4-E4C1-4E0E-BBAE-AC7A0C303593/SurfacePro4_Win10_15063_1701801_0.msi', 'c:\save.msi')}”)
You can get help infor for Create() method for Win32_Process here