Sending a script file into the VM using PowerShell Direct

Okay, PowerShell Direct is cool – but sometimes you just want to copy a script (or set of scripts) into the virtual machine and run them there.  How can you do that?  Fortunately – PowerShell Direct comes to the rescue.  Here is a simple snippet that will send any text file from the host to the virtual machine over PowerShell Direct:
# Pass in script file – array trick from copyTextFileIntoVM([string]$VMName, $cred, [string]$sourceFilePath, [string]$destinationFilePath){   $content = Get-Content $sourceFilePath   icm -VMName $VMName  -Credential $cred {param($Script, $file)         $script | set-content $file} -ArgumentList (,$content), $destinationFilePath}
Once this is done – you can then use PowerShell Direct to kick off any processes you want.