1

I want to transfer Powershell DSC resources over the network before a configuration enactment, but I have a few restrictions:

  • push mode must be used;

  • SMB shares must not be used;

  • I don't want to open a PSSession just for copying the files; instead, I want to use the same CimSession that will be passed to the Start-DscConfiguration cmdlet.

Is this possible?

mklement0
  • 382,024
  • 64
  • 607
  • 775
Rosberg Linhares
  • 3,537
  • 1
  • 32
  • 35
  • Why was this closed? This question is about PowerShell, not C#. –  Oct 20 '16 at 23:34
  • The question that is linked to in the "duplicate" report doesn't even have a correct answer to the question. –  Oct 20 '16 at 23:36
  • @TrevorSullivan The OP wants to copy files (i.e. transfer data) over the network using WMI only. AFAIK this is not possible (see the accepted answer to the other question), regardless of the language. If you disagree: please elaborate. – Ansgar Wiechers Oct 21 '16 at 00:46
  • @AnsgarWiechers This works to copy a file in powershell using a CimSession (not using SMB): `$ComputerName = "RemoteComputerName" $CimSession = New-CimSession -ComputerName $ComputerName $files = Get-CimInstance -CimSession $CimSession -ClassName CIM_DataFile -Filter “Path = '\\Temp\\' AND Extension = 'exe'” foreach ($file in $files) { # This works to copy the file $newfile = “C:\Test2\$($file.FileName).$($file.Extension)” Invoke-CimMethod -InputObject $file -MethodName Copy -Arguments @{Filename = $newfile} }` – user700048 May 01 '17 at 06:38

0 Answers0