VMware Cloud Community
frased
Enthusiast
Enthusiast

PowerCLI in vSphere 7 Detach + Unmount multiple LUNs, multiple hosts ?

The closest article I have found is the following...  https://communities.vmware.com/t5/VMware-PowerCLI-Documents/Datastore-Mount-Unmount-Detach-Attach-fu...

But someone reported this fails on vSphere 7.  Anyone had successful scripts that work for targeting a Datacenter or cluster?

I don't mind splitting them up. 

  1. Unmount
  2. Detach (from each host in the same script) 
Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership

What errors do you get when it fails?


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

Reply
0 Kudos
frased
Enthusiast
Enthusiast

I was going to test and saw the latest comment it doesn't work in vSphere 7.  

I'm going to test myself and report back to you.  

Reply
0 Kudos
frased
Enthusiast
Enthusiast

Here is the error... 

Get-DatastoreMountInfo : The term 'Get-DatastoreMountInfo' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:47
+ ... acenter -name London | Get-Datastore | Get-DatastoreMountInfo | Sort ...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-DatastoreMountInfo:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Reply
0 Kudos
LucD
Leadership
Leadership

You need to include or dot-source that function before calling it.
How did you run that call?


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

Reply
0 Kudos
frased
Enthusiast
Enthusiast

Ah ok its coming back to me now.  I have a datastorefunctions.ps1 that sets this up I believe?  Attaching ps1 file for your review.  

Reply
0 Kudos
LucD
Leadership
Leadership

Yes, these are the functions that you first need to dot-source or include in your script


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

Tags (2)
Reply
0 Kudos
frased
Enthusiast
Enthusiast

Thanks again this worked great!  Thanks again LucD!!!

 

At some point when I decomm another SAN in the future I'd like to work on looping this.  That way it runs down my list with pauses.  The detach takes about 3-5 seconds per host.  Then the unmount takes 3-5 seconds.  Times that by 45 LUNs x 14 hosts...  it was a few hours of running them 1 LUN at a time.  

Reply
0 Kudos
LucD
Leadership
Leadership

Do you have the Perennially Reserved set to True on those LUNs?
If not, rescans might take a lot longer for these LUNs.


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

Reply
0 Kudos
frased
Enthusiast
Enthusiast

Negative no reserves. 

They are using the Nimble PSP policy though.  

Reply
0 Kudos