NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Microsoft Virtualization Discussions

HowTo test if Volume exists

skellner
4,331 Views

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
4,331 Views

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
4,332 Views

Here's one way...

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

No such volume

Public