Microsoft Virtualization Discussions

HowTo test if Volume exists

skellner

Hi,

I'd like to test if a volume exists. I use if (get-navol $volume). If the volume not exists I get an error message even if I use a variable ($volexist = get-navol $volume). How can I test the volume without getting an error message on the console? Thanks in advance.

Stefan

1 ACCEPTED SOLUTION

cknight

Here's one way...

PS C:\> if ( (Get-NaVol noSuchVol -ErrorAction SilentlyContinue) -eq $null ) { Write-Host "No such volume" }

No such volume

View solution in original post

1 REPLY 1

cknight

Here's one way...

PS C:\> if ( (Get-NaVol noSuchVol -ErrorAction SilentlyContinue) -eq $null ) { Write-Host "No such volume" }

No such volume

View solution in original post

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public