VMware Cloud Community
MRoushdy
Hot Shot
Hot Shot

Appending Datastore Name

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"

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership

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

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot

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

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
MRoushdy
Hot Shot
Hot Shot

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

pastedImage_0.png

vEXPERT - VCAP-DCV - Blog: arabitnetwork.com | YouTube: youtube.com/c/MohamedRoushdy
Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos