Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| windows:hyper-v:powershell-direct [2026/04/14 13:57] – [File Transfer from VM] chris | windows: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=" |
| 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> | ||
| } | } | ||
| - | </code> | + | </codeprism> |
| ===== File Transfer to VM===== | ===== File Transfer to VM===== | ||
| <code powershell> | <code powershell> | ||
| - | # Open a PSSession to the virtual machine | + | # Open a PSSession to the Virtual Machine |
| $Session = New-PSSession -VMName <VM> -Credential (Get-Credential) | $Session = New-PSSession -VMName <VM> -Credential (Get-Credential) | ||
| - | # Copy the File to the VM | + | # Copy the File to the Virtual Machine |
| Copy-Item -ToSession $Session -Path < | Copy-Item -ToSession $Session -Path < | ||
| # Close the PSSession | # Close the PSSession | ||
| Line 20: | Line 20: | ||
| ===== File Transfer from VM===== | ===== File Transfer from VM===== | ||
| <code powershell> | <code powershell> | ||
| - | # Open a PSSession to the virtual machine | + | # Open a PSSession to the Virtual Machine |
| $Session = New-PSSession -VMName <VM> -Credential (Get-Credential) | $Session = New-PSSession -VMName <VM> -Credential (Get-Credential) | ||
| - | # Copy the File from the VM | + | # Copy the File from the Virtual Machine |
| Copy-Item -FromSession $Session -Path < | Copy-Item -FromSession $Session -Path < | ||
| # Close the PSSession | # Close the PSSession | ||
| Remove-PSSession -Session $Session | Remove-PSSession -Session $Session | ||
| </ | </ | ||
| + | |||