Detaching a datastore using vSphere PowerCLI
You can also use vSphere PowerCLI to unmount and detach the datastore in your infrastructure with the following steps:
Download the community-supported script available from the VMware community at http://goo.gl/ER30YK. Review and accept the VMware contributed sample code agreement.
If the script is in a text file, save it as a
.ps1
file.Open vSphere PowerCLI as an administrator and run the following command:
Import-Module C:\DataStoreFunctions.ps1
If the preceding command complains that the script is not digitally signed in the PowerCLI shell, you can use the following command to bypass it for the current PowerCLI session:
Set-ExecutionPolicy –Scope Process –ExectuionPolicy Bypass
Connect with the vCenter Server by typing the following command and replace the user name and password with your credentials:
Connect-VIServer –Server crimv1vcs001.linxsol.com –Protocol https –User linxsol\zeeshan –Password yourpassword
Use the
Get-DatastoreMountInfo
...