title: Start-Job and PSVersion Error
body: <p>I need to delete a hell lot of records using a web-service. The module <a href="https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell" rel="nofollow">Microsoft.Xrm.Data.Powershell</a> provides several cmdlets to get this job done. </p>
  
  <p>The following script should be executed by the different jobs:</p>
  
  <pre><code>$packageCmd = {
      param($jobName, $crmConnection, $package)
  
      # Xrm is not a module that is system-wide loaded 
      Import-Module Microsoft.Xrm.Data.Powershell
  
      $counter = 0
  
      write $jobName
  
      foreach($record in $package) {
  
          Remove-CrmRecord -conn $crmConnection -EntityLogicalName 'foobar' -Id $record.foobarid
          $counter++
      }
  }
  </code></pre>
  
  <p>This is the code I use to execute my jobs:</p>
  
  <pre><code>foreach($p in $packages) {
  
      $jobname = $jobName =  ('Del_Data_Pak_{0}' -f $packageNumber)
      Start-job  -Name $jobname -ScriptBlock $packageCmd -ArgumentList $jobName, $crmConnection, $p
  
      $packageNumber++
  }
  </code></pre>
  
  <p>When I execute my code the following error message is thrown inside the jobs:</p>
  
  <pre><code>Der aktuelle Windows PowerShell-Host ist: "ServerRemoteHost" (Version 1.0.0.0). Zum Ausführen 
  des Moduls "C:\Users\foobar\Documents\WindowsPowerShell\Modules\Microsoft.Xrm.Data.Powershell\Micro
  soft.Xrm.Data.Powershell.psd1" ist mindestens Version 4.0 des Windows PowerShell-Hosts 
  erforderlich.
      + CategoryInfo          : ResourceUnavailable: (C:\Users\foobar\Do...Powershell.psd1:String) [ 
     Import-Module], InvalidOperationException
      + FullyQualifiedErrorId : Modules_InsufficientPowerShellHostVersion,Microsoft.PowerShell.Co 
     mmands.ImportModuleCommand
      + PSComputerName        : localhost
  </code></pre>
  
  <p>The error message says that the module "Microsoft.Xrm.Data.Powershell" requires version 4.0 of PowerShell, but that the current host is using version 1.0.</p>
  
  <p>Based on the <a href="https://technet.microsoft.com/en-gb/library/2bc04935-0deb-4ec0-b856-d7290cca6442(v=wps.640).aspx" rel="nofollow">online documentation for Start-Job</a> can I pass the parameter -PSVersion but only with the values 2.0 or 3.0.</p>
  
  <p>Does this mean that it is simply not possible to execute an job that uses a module that requires PowerShell 4.0 /5.0? </p>
  
  <p><strong>Update 2016-02-04:</strong> I commented out the following line in the file "Microsoft.Xrm.Data.PowerShell.psd1"..</p>
  
  <pre><code># Minimum version of the Windows PowerShell host required by this module
  #PowerShellHostVersion = '4.0'
  </code></pre>
  
  <p>... but now I receive this error inside the jobs:</p>
  
  <pre><code>Die Argumenttransformation für den Parameter "conn" kann nicht verarbeitet werden. 
  Der Wert "Microsoft.Xrm.Tooling.Connector.CrmServiceClient" vom Typ 
  "Deserialized.Microsoft.Xrm.Tooling.Connector.CrmServiceClient" kann nicht in den 
  Typ "Microsoft.Xrm.Tooling.Connector.CrmServiceClient" konvertiert werden.
      + CategoryInfo          : InvalidData: (:) [Remove-CrmRecord], ParameterBindin. 
     ..mationException
      + FullyQualifiedErrorId : ParameterArgumentTransformationError,Remove-CrmRecord
      + PSComputerName        : localhost
  </code></pre>
  
  <p>I do not understand why I have now "Deserialized.Microsoft.Xrm.Tooling.Connector.CrmServiceClient" and "Microsoft.Xrm.Tooling.Connector.CrmServiceClient"</p>