Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET Coming Soon: GET:IT Endpoint Management 1-Day Conference on September 28th at 9:30 AM ET

Using Powershell to add iSCSI Targetname and IP from CSV file..

Home Forums Scripting PowerShell Using Powershell to add iSCSI Targetname and IP from CSV file..

Tagged: 

Viewing 1 post (of 1 total)
  • Author
    Posts

  • huud
    Member
    #624060

    I have the following script which retrieves IP addresses from a CSV file but does not add them to the -InitiatorId.

    $csvFile = Import-CSV -Path C:\Users\Administrator\Desktop\esxiHostsDeployment.csv

    foreach ($NFSRow in $csvFile)
    {
    $virtualSwitch = $NFSRow.Switch
    $vmK = $NFSRow.VMK
    $ipa = $csvFile | Where {“iSCSI1″,”iSCSI2″ -contains $_.VMK} | Select -Property @{N=”IPAddress:”;E={$_.IP}}
    }

    When I check the variable value with $ipa I get :

    IPAddress:
    ———-
    192.168.4.24
    192.168.4.25
    192.168.4.34
    192.168.4.35

    If I use write-host $ipa I get

    write-host $ipa
    @{IPAddress:=192.168.4.24} @{IPAddress:=192.168.4.25} @{IPAddress:=192.168.4.34} @{IPAddress:=192.168.4.35}

    And when this is passed to the -InitiatorId I get the following error:

    Set-IscsiServerTarget : Cannot bind parameter ‘InitiatorIds’. Cannot convert the “@{IPAddress:=192.168.4.24}” value of type
    “Selected.System.Management.Automation.PSCustomObject” to type “Microsoft.Iscsi.Target.Commands.InitiatorId”.
    At line:1 char:61
    + Set-IscsiServerTarget -TargetName “esxiHosts1” -InitiatorId $ipa
    + ~~~~
    + CategoryInfo : InvalidArgument: (:) [Set-IscsiServerTarget], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Iscsi.Target.Commands.SetIscsiServerTargetCommand

    Any suggestions how I can get the results in the format : IPAddress:192.168.4.24, IPAddress:192.168.4.25 in the results.

    Thank You

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: