$E01 = get-esxcli -vmhost test01
$ED01 = $e01.storage.core.device.detached.list() # I have 10 devices here
$e01.storage.core.device.detached.remove($ED01) error as follows
PowerCLI C:\scripts> $e01.storage.core.device.detached.remove($ed01)
A specified parameter was not correct.
method
At line:1 char:41
+ $e01.storage.core.device.detached.remove <<<< ($ed01)
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodInvocationException
how to loop the list of devices in detached list that needs to be removed,
That works got the property using select*, i am improving the property was DeviceUID ( instead of devices ).
the small script passed with removing first 5 and last 5 and random ones. for all the esxi in the cluster.
But still no progress on removing all the device - any clue please.
Do you mean this script ?
$luns = Get-Content luns.txt
$luns | %{
$e01.storage.core.device.detached.remove($_)
}
If yes, what exactly is in the fle ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
referring to
$e = get-cluster -name test | get-vmhost | get-esxcli
foreach ($esx in $e)
{
$esx.storage.core.device.detached.list() | select -expandproperty deviceuid | select -first 2 | %{$esx.storage.core.device.detached.remove($_)}
}
Another one.
$e = get-cluster -name test | get-vmhost | get-esxcli
$lun = get-content lun.txt
foreach ($esx in $e)
{
$lun | %{$esx.storage.core.device.detached.remove($_)}
}
both the above works, thanks for your help.
To remove all the luns in the detached list is the one that is pending, using $ed1 |%{$esx.storage.core.device.detached.remove($_)} doesn't works. this one runs with out error, but dont remove the luns in detached list.
You should extract the DeviceUid property and feed that as a parameter to the method.
Something like this
$ed1 | select -expandproperty deviceuid | %{$esx.storage.core.device.detached.remove($_)}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
I use some of these scripts for long time in version 5.01 and 5.02 but after install Update 3 all of them (type detached.remove) was stopped working with next error in all cases-
Message: A specified parameter was not correct.
argument[0];
InnerText: argument[0]
At line:1 char:54
+ $lun2 | %{$esxcli.storage.core.device.detached.remove <<<< ($_)}
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodInvocationException
I check sintax of command.. this change?, parameter "boolean all" is new and mandatory? i was check in documentation and appear as $esxcli.storage.core.device.detached.remove(string device) with only 1 parameter.
$esxcli.storage.core.device.detached.remove
TypeNameOfValue : VMware.VimAutomation.ViCore.Util10Ps.EsxCliExtensionMetho
d
OverloadDefinitions : {void remove(boolean all, string device)}
MemberType : CodeMethod
Value : void remove(boolean all, string device)
Name : remove
IsInstance : True
-I was tried manual without "$_" variable but same result
-check manually host SSH command -D and works correctly
Thanks
Regards
Never saw that Boolean parameter before, must be a 5.0.3 thing.
Did you try as
$lun2 | %{$esxcli.storage.core.device.detached.remove($false,$_)}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes,, works.. you know function of this new parameter? 😕
Thanks
I'm afraid not, couldn't find any reference to that parameter.
That's why I set it to $false :smileygrin:
Must be specific for 5.0.3, couldn't find it in 5.1 or 5.5
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Strange if that is not in 5.1, 5.5 .. I adapted all of my routines
I'll keep that in mind if I update
Thank you
H guys,
facing here also strange Condition.
i used in former Days the Removal Script too
- Unmount Filesystem
- Detach Device
- Remove Perma
But if i like to remove them now, they getting re/attached again. without any Error etc,.... Commands passed through and i tested them also manually.
tried 5.8 and latest 6.0 Version on 5.5 Hosts.
known Bug here?
Anybody could confirm with which Version of Powercli it's still working?
best regards
Max
Ah need to extend Info. Seems it's not related to Powercli. it's avoided from Host Level. Seems there is a Bug.
If doing detach i see in vmkernel "has been turned off administratively".
if i do the "esxcli storage core device detached remove -d xxx". it's giving me "has been turned on administratively".
interesting. ;(
Best regards
Max
Things have changed a bit in PowerCLI 6.5 R1. I got things working with a few tweaks. Note the "invoke" and everything after.
Thank you to everyone in this post for getting me pointed down the right path.
Remove LUNs from list luns.txt
$EsxiHosts = Get-VMHost
$luns = get-content luns.txt
foreach ($esx in $EsxiHosts){
$esxcli = Get-EsxCli -VMHost $esx -V2
$luns | %{$esxcli.storage.core.device.detached.remove.invoke(@{device = ($_)})}
}
Remove First 5 LUNs
$EsxiHosts = Get-VMHost
foreach ($esx in $EsxiHosts){
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.core.device.detached.list.invoke() | Select -ExpandProperty DeviceUID | Select -First 5 | %{$esxcli.storage.core.device.detached.remove.invoke(@{device = ($_)})}
}