Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
windows:hyper-v:powershell-direct [2026/04/14 13:27] – [Command Invokation] chriswindows:hyper-v:powershell-direct [2026/04/22 16:38] (current) – [Command Invokation] chris
Line 2: Line 2:
  
 ===== Command Invokation ===== ===== Command Invokation =====
-<code powershell+<codeprism lang="ps1"
 Invoke-Command -VMName <VM> -Credential (Get-Credential) -ScriptBlock {  Invoke-Command -VMName <VM> -Credential (Get-Credential) -ScriptBlock { 
     <Any PowerShell commands to run inside the VM>     <Any PowerShell commands to run inside the VM>
 } }
 +</codeprism>
 +
 +===== File Transfer to VM=====
 +<code powershell> 
 +# Open a PSSession to the Virtual Machine
 +$Session = New-PSSession -VMName <VM> -Credential (Get-Credential) 
 +# Copy the File to the Virtual Machine
 +Copy-Item -ToSession $Session -Path <SourcePath> -Destination <DestinationPath>
 +# Close the PSSession
 +Remove-PSSession -Session $Session
 +</code>
 +
 +===== File Transfer from VM=====
 +<code powershell> 
 +# Open a PSSession to the Virtual Machine
 +$Session = New-PSSession -VMName <VM> -Credential (Get-Credential) 
 +# Copy the File from the Virtual Machine
 +Copy-Item -FromSession $Session -Path <SourcePath> -Destination <DestinationPath>
 +# Close the PSSession
 +Remove-PSSession -Session $Session
 </code> </code>
 +