{"id":165,"date":"2019-11-19T20:33:10","date_gmt":"2019-11-19T20:33:10","guid":{"rendered":"http:\/\/192.168.8.14\/?p=165"},"modified":"2019-11-23T18:31:31","modified_gmt":"2019-11-23T18:31:31","slug":"powercli-one-liners","status":"publish","type":"post","link":"https:\/\/www.jasonstreet.com\/?p=165","title":{"rendered":"PowerCli One-liners"},"content":{"rendered":"\n<p> Here is a page of One liners I have written\/collected over the years. I will add more over time. <br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Select Hostname, PortGroupName, IP, MTU\n<\/pre><\/div>\n\n\n<p><em># Lists eachs hosts VMKernal interfaces with there PortGroup, IP and MTU.<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nGet-VMhost | Get-SCSILun | Where {$_.Vendor \u2013match \u201cNETAPP\u201d} | Set-SCSILun \u2013MultipathPolicy \u201cRoundRobin\u201d\n<\/pre><\/div>\n\n\n<p>#&nbsp;<em>Set all NetApp LUNs to RoundRobin<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VMHost | Sort Name | Select Name, @{N=\u201dNTPServer\u201d;E={Get-VMHostNtpServer $_}}\n<\/pre><\/div>\n\n\n<p><em># get all hosts NTP servers.<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\n-vmhost | Get-VMHostAdvancedConfiguration -Name scratch*\n<\/pre><\/div>\n\n\n<p><em># Get current and configured scratch location.<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VMHost | Get-VMHostNetwork | Select Hostname, VMKernelGateway -ExpandProperty VirtualNic | Where {$_.vMotionEnabled} | Select Hostname, PortGroupName, IP, SubnetMask\n<\/pre><\/div>\n\n\n<p><em># get PortGroup, IP and subnet of all hosts.<\/em><a href=\"http:\/\/192.168.8.14\/?p=247#\">?<\/a><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VMHost | Get-VMHostService | Where { $_.Key -eq &quot;TSM-SSH&quot; } | select VMHost, Label, Running\n<\/pre><\/div>\n\n\n<p><em># Select SSH service running status on each host.<\/em><br><\/p>\n\n\n\n<p><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VM | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$false\n<\/pre><\/div>\n\n\n<p><em># remove ISO images from all VMs.<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VM | Get-Snapshot | Select VM, Name, Description, Created, SizeMb\n<\/pre><\/div>\n\n\n<p><em># List all snapshots, listing VM name, snapshot name, discription and created time.<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VM | Get-Snapshot | Select VM, Name, Created, sizemb | Where {$_.Created -lt ((Get-Date).AddDays(-2))}\n<\/pre><\/div>\n\n\n<p><em># List all snapshots older then 2 days<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nget-vm | Get-NetworkAdapter | Format-Table parent, networkname, type, MACaddress\n<\/pre><\/div>\n\n\n<p><em># get VM name, PortGroup, NIC type and MAC address<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-VM | Get-HardDisk | ft Parent, Name, CapacityGB \u2013AutoSize\n<\/pre><\/div>\n\n\n<p><em># get VM name, HD name and size.<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nGet-Log hostd -VMHost (Get-VMHost &quot;HostToGetLog&quot;) | Select -Expand Entries | Select-String warning\n<\/pre><\/div>\n\n\n<p><em># Get lines from the Hostd log fro host \u201cHostToGetLog\u201d containing \u201cWarning\u201d<\/em><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nLogtype hostd -VMHost (Get-VMHost &quot;HostToGetLog&quot;)\n<\/pre><\/div>\n\n\n<p><em># list server logs (normally hostd, vmkernal, epxa<\/em><a href=\"http:\/\/192.168.8.14\/?p=247#\">)<\/a><br><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\nget-VM | Get-VIEvent -Start (get-date).adddays(-3) | Where {$_.fullFormattedMessage -like &quot;*Power*&quot;}\n<\/pre><\/div>\n\n\n<p><em># List all VM power events for the last 3 days<\/em><br><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is a page of One liners I have written\/collected over the years. I will add more over time. # Lists eachs hosts VMKernal interfaces with there PortGroup, IP and MTU. #&nbsp;Set all NetApp LUNs to RoundRobin # get all hosts NTP servers. # Get current and configured scratch location. # get PortGroup, IP and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5,4],"tags":[32],"class_list":["post-165","post","type-post","status-publish","format-standard","hentry","category-powercli","category-powershell","tag-one-liners"],"_links":{"self":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts\/165","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165"}],"version-history":[{"count":2,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts\/165\/revisions"}],"predecessor-version":[{"id":216,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=\/wp\/v2\/posts\/165\/revisions\/216"}],"wp:attachment":[{"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasonstreet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}