title: Script that moves files from a NAS to clients, executed on a server
body: <p>I got the following problem: at work, I have to code a script that copies the files from a NAS onto a few clients, using Remote PSSessions. The script is getting executed on a domain controller.</p>
  
  <p>I think something is wrong with the remote session and the "copy the files" part. But I don't know what.</p>
  
  <pre class="lang-cs prettyprint-override"><code>#SRC=Source Data to copy
  $src1 = "\\NAS01\adm\sw\CAD\Dateien_fuer_SUPPORT_Verz\def_KOPA_Linie.lin"
  $src2 = "\\NAS01\adm\sw\CAD\Dateien_fuer_SUPPORT_VerzSchlinie2.shx"
  $src3 = "\\NAS01\adm\sw\CAD\Dateien_fuer_SUPPORT_Verz\Schlinie2.shp"
  
  #PowerShell Check for AD-Service
  Get-Service ad*
  Get-Module
  
  #Searching through AD for PC's called "WS"
  $pc = Get-ADComputer -Filter 'name -like "WS" '
  
  #New Powershell-Remotesession with the $pc
  $session = New-PSSession -ComputerName $pc
  
  #Check if the Directory exists, if it exists, copy the files inside
  $Dir = "C:\Program Files\Autodesk\AutoCAD 2015\Support\"
  if (Test-Path $Dir)
  {
      Copy-Items -FromSession $session -Path $src1 + src2 + src3 -Destination "C:\Program Files\Autodesk\AutoCAD 2015\Support\"
  }
  else
  {
      echo "tohuwabohu"
  }
  </code></pre>