Powershell - VMs auswählen
Hallo zusammen,
ich möchte für einen Export nur bestimmte VMs auswählen. Leider funktioniert das mit -like nicht.
Umgekehrt, wenn ich die nicht zu exportierenden VMs mit -notlike angebe, funktioniert es.
Wie muss ich vorgehen, wenn ich nur VM1 und zwei für den Export auswählen möchte?
Vielen Dank für Eure Unterstützung!
Chris
ich möchte für einen Export nur bestimmte VMs auswählen. Leider funktioniert das mit -like nicht.
Get-VM | Where-Object { $_.Name -like 'VM1' -and $_.Name -like 'VM2' } | foreach {
$ExportJob = Export-VM -Name $_.Name -Path x: -AsJob}
Umgekehrt, wenn ich die nicht zu exportierenden VMs mit -notlike angebe, funktioniert es.
Get-VM | Where-Object { $_.Name -notlike 'VM3' -and $_.Name -notlike 'VM4' } | foreach {
$ExportJob = Export-VM -Name $_.Name -Path x: -AsJob}
Wie muss ich vorgehen, wenn ich nur VM1 und zwei für den Export auswählen möchte?
Vielen Dank für Eure Unterstützung!
Chris
Please also mark the comments that contributed to the solution of the article
Content-Key: 665246
Url: https://administrator.de/contentid/665246
Printed on: April 26, 2024 at 16:04 o'clock
2 Comments
Latest comment
Moin Chris,
Gruß Thomas
Zitat von @chris123:
Leider funktioniert das mit -like nicht.
funktioniert schon, nur musst du natürlich -or statt -and verwenden.Leider funktioniert das mit -like nicht.
Get-VM | Where-Object { $_.Name -like 'VM1' -and $_.Name -like 'VM2' }
Gruß Thomas