This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
program_lang:powershell_powercli_misc [2022/01/07 18:33] manu created |
program_lang:powershell_powercli_misc [2025/10/13 22:55] (current) manu [List VMFS] |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Powercli misc commands ====== | ====== Powercli misc commands ====== | ||
| + | |||
| + | Converted to PowerCLI that looks like: | ||
| + | |||
| + | Get-VMHost | Set-VMHostAdvancedConfiguration -Name LVM.EnableResignature -Value 1 | ||
| + | Get-VMHost | Get-VMHostStorage -RescanAllHBA -RescanAllVMFS | ||
| + | Get-VMHost | Set-VMHostAdvancedConfiguration -Name LVM.EnableResignature -Value 0 | ||
| + | |||
| + | |||
| + | |||
| + | https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Assign-a-new-signature-via-Powercli/td-p/1852376 | ||
| + | |||
| + | https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Resignature-a-VMFS-Datastore-Copy/m-p/462238 | ||
| + | |||
| + | https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Creating-datastore-from-mounted-VMFS-Disk-LUN-producing/td-p/1263946 | ||
| + | |||
| + | https://github.com/voletri/PowerCLI-1/blob/master/Attach-SCSILun.ps1 | ||
| + | |||
| + | |||
| + | Get-VMhost | Select -first 1 | ||
| + | |||
| + | ===== get_vm_list.ps1 ===== | ||
| + | |||
| + | <cli prompt='>'> | ||
| + | PS /inventory/scripts> cat ./get_vm_list.ps1 | ||
| + | #!/usr/bin/pwsh | ||
| + | |||
| + | $VMvCenterName = 'vcenterprod.test.lu' | ||
| + | $VMvCenterUser = 'user_RO' | ||
| + | $VMvCenterPass = 'ThisIsavceneter01' | ||
| + | |||
| + | |||
| + | ### | ||
| + | ### Connect to vCenter | ||
| + | ### | ||
| + | |||
| + | Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -WarningAction SilentlyContinue -ParticipateInCeip $false -DisplayDeprecationWarnings $false -confirm:$false | ||
| + | $VCSession = Connect-VIServer -Server $VMvCenterName -User $VMvCenterUser -Password $VMvCenterPass | ||
| + | |||
| + | Get-VM | Select Name,PowerState,@{Name=’Cluster’;Expression={$_.VMHost.Parent}},NumCpu,MemoryGB,CreateDate,@{N="Configured_OS";E={$_.ExtensionData.Config.GuestFullname}},@{N="Running_OS";E={$_.Guest.OsFullName}},@{N = "IPAdress"; E = {$_.Guest.IpAddress}} | export-csv /inventory/list_vm.csv | ||
| + | |||
| + | Write-Host "##### Collect Vcenter Finished" | ||
| + | |||
| + | ### | ||
| + | ### Disconnect from vCenter | ||
| + | ### | ||
| + | |||
| + | Disconnect-VIServer -Server $VMvCenterName -Confirm:$false | ||
| + | |||
| + | exit $RC | ||
| + | </cli> | ||
| + | <cli prompt='>'> | ||
| + | PS /inventory/scripts> cat /inventory/list_vm.csv | ||
| + | "Name","PowerState","Cluster","NumCpu","MemoryGB","CreateDate","Configured_OS","Running_OS","IPAdress" | ||
| + | "Win1100","PoweredOn","WIN","4","16","10/10/2025 09:01:16","Microsoft Windows 11 (64-bit)",,"" | ||
| + | "deb001","PoweredOn","LNX","1","2","01/01/1970 00:00:00","Debian GNU/Linux 10 (64-bit)","Debian GNU/Linux 9 (64-bit)","10.10.10.10 fe80::223:56ff:fe9a:a535" | ||
| + | </cli> | ||
| + | |||
| ===== get ALL VM snapshots ===== | ===== get ALL VM snapshots ===== | ||
| Line 15: | Line 72: | ||
| ... | ... | ||
| </cli> | </cli> | ||
| + | |||
| + | ===== List VMFS ===== | ||
| + | |||
| + | <cli prompt='>'> | ||
| + | PS /usr/cmd/fcm/old> $esxcli = Get-EsxCli -VMhost $myhost -V2 | ||
| + | PS /usr/cmd/fcm/old> $esxcli.storage.filesystem.list.Invoke() | ||
| + | |||
| + | Free : 46794088448 | ||
| + | MountPoint : /vmfs/volumes/xxxxxxx-8bcefe5c | ||
| + | Mounted : true | ||
| + | Size : 356072996864 | ||
| + | Type : NFS | ||
| + | UUID : xxxxxxx-8bcefe5c | ||
| + | VolumeName : DataStore1 | ||
| + | |||
| + | Free : 9521070080 | ||
| + | MountPoint : /vmfs/volumes/5e15fd7b-xxxxxxx-03d5-3863bb3ec358 | ||
| + | Mounted : true | ||
| + | Size : 15837691904 | ||
| + | Type : VMFS-5 | ||
| + | UUID : 5e15fd7b-xxxxxxx-03d5-3863bb3ec358 | ||
| + | VolumeName : DataStore2 | ||
| + | ... | ||
| + | </cli> | ||
| + | |||
| + | ===== Misc commands ===== | ||
| + | |||
| + | get-vm | Select Name, UsedSpaceGB, ProvisionedSpaceGB | ||
| + | |||