UNSOLVED

dell_LarryBoy

updated

14 years ago

0

10403

May 10th, 2013 14:00

Command returning "bad data"

I am working on a script to automate the clean up of a volume folder and it is returning some "bad data" when the commands are performed using a .ps1 script, but when I do the same commands at the command line, it works...

Here is the code that fails:

    $conn = Get-SCConnection -Name $connectionname -Default -DestinationDefault
    Write-Host "Deleting unmapped Restore volumes from $connectionname..." -ForegroundColor "yellow"
    $restorevols = Get-SCVolume -ParentFolder Restores
    Write-Host ""
    Write-Host $restorevols
    Write-Host ""
    ForEach ($restorevol in $restorevols)
    {
        $volmapping = Get-SCVolumeMap -VolumeIndex $restorevol.Index
        If ($volmapping.Index -eq "")
        {
            Remove-SCVolume -SCVolume $restorevol -SkipRecycleBin -WhatIf -Confirm:$false
        }
        Else
        {
            Write-Host "The volume - $restorevol.Name - was not deleted because it is still mapped!" -ForegroundColor "red"
        }
    }
Here is the output from running the script:

Deleting unmapped Restore volumes from COMPELLENT1...
SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.S
CVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCO
bjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCComman
dSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume SCCommandSet.SCObjects.SCVolume
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!
The volume - SCCommandSet.SCObjects.SCVolume.Name - was not deleted because it is still mapped!

Thanks in advance!

  • 637

    0

    Posted May 27th, 2013 11:00

    The reason your script is not removing the volumes is because when it checks whether the volume is mapped the answer is always true. I made on change to your script to fix this: $volmapping.Index -eq $null

    Now if there is no mapping the volume will be removed. I still do not know why you see the command set objects output. I will look a little further in to this.