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:

  1. Download the community-supported script available from the VMware community at http://goo.gl/ER30YK. Review and accept the VMware contributed sample code agreement.
  2. If the script is in a text file, save it as a .ps1 file.
  3. Open vSphere PowerCLI as an administrator and run the following command:
    Import-Module C:\DataStoreFunctions.ps1
    
  4. 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
    
  5. Connect with the vCenter ...

Get VMware vSphere Troubleshooting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.