{"id":17,"date":"2020-05-13T19:08:00","date_gmt":"2020-05-13T17:08:00","guid":{"rendered":"http:\/\/www.meikom.de\/?p=17"},"modified":"2020-05-16T09:12:42","modified_gmt":"2020-05-16T07:12:42","slug":"erstellen-mehrerer-iscsi-disks-mit-powershell-creating-several-iscsi-disk-with-powershell-windows-server","status":"publish","type":"post","link":"https:\/\/www.meikom.de\/?p=17","title":{"rendered":"Erstellen mehrerer iSCSI Disks mit PowerShell \/ Creating several iSCSI Disk with PowerShell [Windows Server]"},"content":{"rendered":"<p>#Yet to be improved, but works<\/p>\n<p>$SystemErrorActionPreference = $ErrorActionPreference;<\/p>\n<p>$ErrorActionPreference = &#8218;Stop&#8216;;<\/p>\n<p># if needed add this<\/p>\n<p>#[PSCredential]$cred = Get-Credential -UserName Adatum\\Administrator -Message &#8218;Supply an Administrator login, please.&#8216;;<\/p>\n<p>$iSCSI_TargetName= &#8218;lon-svr1&#8216;;<\/p>\n<p>$iSCSI_TargetInitiatorIds =@(&#8218;IPAddress:172.16.0.22&#8216;, &#8218;IPAddress:172.16.0.23&#8216;)<\/p>\n<p>$iSCSI_Target = New-IscsiServerTarget -TargetName $iSCSI_TargetName -InitiatorIds $iSCSI_TargetInitiatorIds;<\/p>\n<p>foreach($num in 1..3)<\/p>\n<p>{<\/p>\n<p>&nbsp;&nbsp;&nbsp;$iPath = &#8218;C:\\iSCSIVirtualDisks\\iSCSIDisk&#8216; + $num + &#8218;.vhdx&#8216;;<\/p>\n<p>&nbsp;&nbsp;&nbsp;try<\/p>\n<p>&nbsp;&nbsp;&nbsp;{<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get-ChildItem $iPath | Out-Null;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Host $iPath already exists;<\/p>\n<p>&nbsp;&nbsp;&nbsp;}<\/p>\n<p>&nbsp;&nbsp;&nbsp;catch [System.Management.Automation.ItemNotFoundException]<\/p>\n<p>&nbsp;&nbsp;&nbsp;{<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;New-IscsiVirtualDisk -SizeBytes 5GB -Path $iPath | Add-IscsiVirtualDiskTargetMapping -TargetName $iSCSI_TargetName;<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Host Created $iPath;<\/p>\n<p>&nbsp;&nbsp;&nbsp;}<\/p>\n<p>}<\/p>\n<p>$ErrorActionPreference = $SystemErrorActionPreference;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#Yet to be improved, but works $SystemErrorActionPreference = $ErrorActionPreference; $ErrorActionPreference = &#8218;Stop&#8216;; # if needed add this #[PSCredential]$cred = Get-Credential -UserName Adatum\\Administrator -Message &#8218;Supply an Administrator login, please.&#8216;; $iSCSI_TargetName= &#8218;lon-svr1&#8216;; $iSCSI_TargetInitiatorIds =@(&#8218;IPAddress:172.16.0.22&#8216;, &#8218;IPAddress:172.16.0.23&#8216;) $iSCSI_Target = New-IscsiServerTarget -TargetName $iSCSI_TargetName -InitiatorIds $iSCSI_TargetInitiatorIds; &hellip; <a href=\"https:\/\/www.meikom.de\/?p=17\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"https:\/\/www.meikom.de\/index.php?rest_route=\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.meikom.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.meikom.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.meikom.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.meikom.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":5,"href":"https:\/\/www.meikom.de\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":24,"href":"https:\/\/www.meikom.de\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/24"}],"wp:attachment":[{"href":"https:\/\/www.meikom.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.meikom.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.meikom.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}