This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
powershell [2018/06/19 17:54] – external edit 127.0.0.1 | powershell [2021/04/01 11:24] (current) – [Alle VMs eines Datastores im Inventory registrieren] mschubi | ||
---|---|---|---|
Line 50: | Line 50: | ||
PowerCLI ist die CMDlet Erweiterung der Powershell von VMware um eine VMware ESX/ | PowerCLI ist die CMDlet Erweiterung der Powershell von VMware um eine VMware ESX/ | ||
+ | |||
+ | ===== Alle VMs eines Datastores im Inventory registrieren ===== | ||
+ | |||
+ | <code powershell> | ||
+ | $VMFolder = " | ||
+ | $vmhost = " | ||
+ | $DatastoreName = get-vmhost $vmhost | Get-Datastore | where {$_.Name -like " | ||
+ | |||
+ | ForEach($regDS in $DatastoreName){ | ||
+ | |||
+ | $ds = Get-Datastore -Name $regDS | %{Get-View $_.Id} | ||
+ | $SearchSpec = New-Object VMware.Vim.HostDatastoreBrowserSearchSpec | ||
+ | $SearchSpec.matchpattern = " | ||
+ | $dsBrowser = Get-View $ds.browser | ||
+ | $DatastorePath = " | ||
+ | |||
+ | #Find all .VMX file paths in datastore, filtering out ones with .snapshot (useful for NetApp NFS) | ||
+ | $SearchResult = $dsBrowser.SearchDatastoreSubFolders($DatastorePath, | ||
+ | |||
+ | #Register all .vmx files as VMs on the datastore | ||
+ | foreach($VMXFile in $SearchResult) { New-VM -VMFilePath $VMXFile -ResourcePool $vmhost -Location $VMFolder -RunAsync }} | ||
+ | |||
+ | </ | ||
==== Was sind primary HA Nodes? ==== | ==== Was sind primary HA Nodes? ==== |