Automation

 View Only
  • 1.  Appending Datastore Name

    Posted Dec 05, 2019 08:45 AM

    Hello, appending a single datastore works fine, but, appending a list from CSV didn't work fine with me. I used this example:

    Get-Content ".\rename-ds.csv" | ConvertFrom-Csv -header nfsname  | %{get-datastore $_.nfsname }  | Set-Datas

    tore -Name $nfsname"-DONTUSE"



  • 2.  RE: Appending Datastore Name

    Posted Dec 05, 2019 08:56 AM

    Try something like this

    Import-Csv -Path '.\rename-ds.csv' -UseCulture |

    ForEach-Object -Process {

        Get-Datastore -Name $_.nfsname |

        Set-Datastore -Name "$($_.Name)-DONTUSE" -Confirm:$false

    }



  • 3.  RE: Appending Datastore Name

    Posted Dec 05, 2019 09:26 AM

    Thanks, but, where should I declare the var "$_.nfsname" ?



  • 4.  RE: Appending Datastore Name

    Posted Dec 05, 2019 09:43 AM

    That should come from your CSV file.
    I assumed from your sample snippet, that the CSV had the following layout.

    nfsname

    datastore1

    datastore2

    The Import-Csv reads the file line-by-line, and the line ($_) contains the nfsname property



  • 5.  RE: Appending Datastore Name

    Posted Dec 05, 2019 10:29 AM

    Okay, though, not working at all :smileysad: I've verified the names an they are still the same.



  • 6.  RE: Appending Datastore Name

    Posted Dec 05, 2019 10:37 AM

    Can you show the script and the CSV file?
    That line in the output, with the datastore info, should not be there.