{"id":721,"date":"2020-05-19T10:38:59","date_gmt":"2020-05-19T10:38:59","guid":{"rendered":"http:\/\/michaelstoica.com\/?p=721"},"modified":"2020-05-26T10:56:22","modified_gmt":"2020-05-26T10:56:22","slug":"configure-esxi-path-selection-and-iscsi-software-adapter-with-powercli","status":"publish","type":"post","link":"https:\/\/michaelstoica.com\/site\/configure-esxi-path-selection-and-iscsi-software-adapter-with-powercli\/","title":{"rendered":"Configure ESXi Path Selection and iSCSI software adapter with PowerCLI"},"content":{"rendered":"<p>In the past few weeks I&#8217;ve worked more with PowerCLI because I wanted to automate some of the settings and configuration of newly installed ESXi hosts. One of the things was to set the\u00a0<a href=\"https:\/\/docs.vmware.com\/en\/VMware-vSphere\/6.0\/com.vmware.vsphere.storage.doc\/GUID-37F97D1C-4E4F-460B-ACF9-04D1347959CC.html\">Path Selection Policy <\/a>to Round Robin and set iSCSI vmk qDepth to 32.<\/p>\n<p>So, this script will change the default PSP to RR, change the iscsivmk qDepth and in the end it will enable the iSCSI software adapter.<\/p>\n<p>I parameterised\u00a0 vCenter and cluster name so it would be easier when running the script, and after that set the arguments for the <em>defaultpsp<\/em>, <em>SATP<\/em> and <em>iscsivmk<\/em> settings. You can change the arguments values based on your storage provider recommendation.<\/p>\n<pre class=\"powershell\" style=\"font-family:monospace;\"> <span style=\"color: #0000FF;\">param<\/span><span style=\"color: #000000;\">&#40;<\/span>\r\n<span style=\"color: #800080;\">$vcenter<\/span><span style=\"color: pink;\">,<\/span>\r\n<span style=\"color: #800080;\">$clustername<\/span>\r\n<span style=\"color: #000000;\">&#41;<\/span>\r\nConnect<span style=\"color: pink;\">-<\/span>VIServer <span style=\"color: #800080;\">$vcenter<\/span>\r\n<span style=\"color: #800080;\">$Cluster<\/span> <span style=\"color: pink;\">=<\/span> Get<span style=\"color: pink;\">-<\/span>Cluster <span style=\"color: #008080; font-style: italic;\">-Name<\/span> <span style=\"color: #800080;\">$clustername<\/span> <span style=\"color: pink;\">|<\/span> Get<span style=\"color: pink;\">-<\/span>VMhost\r\n<span style=\"color: #800080;\">$args1<\/span> <span style=\"color: pink;\">=<\/span> <span style=\"color: pink;\">@<\/span><span style=\"color: #000000;\">&#123;<\/span>\r\n    defaultpsp <span style=\"color: pink;\">=<\/span> <span style=\"color: #800000;\">'VMW_PSP_RR'<\/span>\r\n    satp <span style=\"color: pink;\">=<\/span> <span style=\"color: #800000;\">'VMW_SATP_ALUA'<\/span>\r\n<span style=\"color: #000000;\">&#125;<\/span>\r\n&nbsp;\r\n<span style=\"color: #800080;\">$qDepth<\/span> <span style=\"color: pink;\">=<\/span> <span style=\"color: pink;\">@<\/span><span style=\"color: #000000;\">&#123;<\/span>\r\n   module <span style=\"color: pink;\">=<\/span> <span style=\"color: #800000;\">'iscsi_vmk'<\/span>\r\n   parameterstring <span style=\"color: pink;\">=<\/span> <span style=\"color: #800000;\">'iscsivmk_LunQDepth=32'<\/span>\r\n<span style=\"color: #000000;\">&#125;<\/span>\r\n&nbsp;\r\n<span style=\"color: #0000FF;\">foreach<\/span> <span style=\"color: #000000;\">&#40;<\/span><span style=\"color: #800080;\">$ESXHost<\/span> <span style=\"color: #0000FF;\">in<\/span> <span style=\"color: #800080;\">$Cluster<\/span><span style=\"color: #000000;\">&#41;<\/span> <span style=\"color: #000000;\">&#123;<\/span>\r\n<span style=\"color: #800080;\">$esxcli<\/span> <span style=\"color: pink;\">=<\/span> <span style=\"color: #800080;\">$ESXHost<\/span> <span style=\"color: pink;\">|<\/span> Get<span style=\"color: pink;\">-<\/span>EsxCli <span style=\"color: pink;\">-<\/span>v2\r\n&nbsp;\r\n<span style=\"color: #800080;\">$esxcli<\/span>.storage.nmp.satp.<span style=\"color: #008080; font-weight: bold;\">set<\/span>.invoke<span style=\"color: #000000;\">&#40;<\/span><span style=\"color: #800080;\">$args1<\/span><span style=\"color: #000000;\">&#41;<\/span>\r\n&nbsp;\r\n<span style=\"color: #800080;\">$esxcli<\/span>.system.module.parameters.list.Invoke<span style=\"color: #000000;\">&#40;<\/span><span style=\"color: pink;\">@<\/span><span style=\"color: #000000;\">&#123;<\/span>module<span style=\"color: pink;\">=<\/span><span style=\"color: #800000;\">'iscsi_vmk'<\/span><span style=\"color: #000000;\">&#125;<\/span><span style=\"color: #000000;\">&#41;<\/span>\r\n<span style=\"color: #800080;\">$esxcli<\/span>.system.module.parameters.<span style=\"color: #008080; font-weight: bold;\">set<\/span>.Invoke<span style=\"color: #000000;\">&#40;<\/span><span style=\"color: #800080;\">$qDepth<\/span><span style=\"color: #000000;\">&#41;<\/span>\r\n<span style=\"color: #800080;\">$esxcli<\/span>.system.module.parameters.list.Invoke<span style=\"color: #000000;\">&#40;<\/span><span style=\"color: pink;\">@<\/span><span style=\"color: #000000;\">&#123;<\/span>module<span style=\"color: pink;\">=<\/span><span style=\"color: #800000;\">'iscsi_vmk'<\/span><span style=\"color: #000000;\">&#125;<\/span><span style=\"color: #000000;\">&#41;<\/span>\r\n&nbsp;\r\nGet<span style=\"color: pink;\">-<\/span>VMHostStorage <span style=\"color: pink;\">-<\/span>VMHost <span style=\"color: #800080;\">$ESXHost<\/span> <span style=\"color: pink;\">|<\/span> Set<span style=\"color: pink;\">-<\/span>VMHostStorage <span style=\"color: pink;\">-<\/span>SoftwareIScsiEnabled <span style=\"color: #800080;\">$True<\/span>\r\n<span style=\"color: #000000;\">&#125;<\/span> \r\n&nbsp;<\/pre>\n<p>Thanks <a href=\"https:\/\/www.lucd.info\/\">Luc Dekens <\/a>for the help provided\u00a0with this script.<\/p>\n<p>The next blogpost will be about how to set the iSCSI Targets using PowerCLI.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past few weeks I&#8217;ve worked more with PowerCLI because I wanted to automate some of the settings and configuration of newly installed ESXi&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/michaelstoica.com\/site\/configure-esxi-path-selection-and-iscsi-software-adapter-with-powercli\/\">Continue reading<span class=\"screen-reader-text\">Configure ESXi Path Selection and iSCSI software adapter with PowerCLI<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[11,10,51,13,12,42],"class_list":["post-721","post","type-post","status-publish","format-standard","hentry","category-general","tag-powercli","tag-powershell","tag-vexpert","tag-vmware","tag-vsphere","tag-vsphere-6-7","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p63Lge-bD","_links":{"self":[{"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/posts\/721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/comments?post=721"}],"version-history":[{"count":4,"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/posts\/721\/revisions"}],"predecessor-version":[{"id":732,"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/posts\/721\/revisions\/732"}],"wp:attachment":[{"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/media?parent=721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/categories?post=721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelstoica.com\/site\/wp-json\/wp\/v2\/tags?post=721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}