GabCava
Enthusiast
Enthusiast

[vCheck] Single storage VMs plugin script and exclusions of DS

Jump to solution

Hello, in the Single storage VMs plugin script I need to exclude certain datastores which contain characters "ucs". So I modified the line:

$unSharedDatastore = $storageviews | Where-Object {-Not $_.summary.multiplehostaccess} | Select-Object -Expand Name

with

$unSharedDatastore = $storageviews | Where-Object {-Not $_.summary.multiplehostaccess -and $_.Name -notmatch "ucs"} | Select-Object -Expand Name

or

$unSharedDatastore = $storageviews | Where-Object {-Not $_.summary.multiplehostaccess} | Where-Object {$_.Name -notmatch "ucs"} | Select-Object -Expand Name

and that works but it removes also lines that do not contain those characters. What am I doing wrong? I´ve checked and the  sequence ucs is not  contained in the lines that are removed too

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

The datastorename "S-001-DC3-PDC-DEVCLUSTER" does not match "ucs", there must be something else going wrong.

Are these missing datastores present in $storageviews?

Try showing the content of $storageviews before the Where-clause is executed.

Perhaps these datastores are "shared" and the first test doesn't pass?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership

That should work.

Can you give us some examples of these datastore names that are removed but shouldn't have been?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
GabCava
Enthusiast
Enthusiast

Hi Luc

here it is

[S-001-DC3-PDC-DEVCLUSTER] F5-UNITT-SDC-LAB/F5-UNITT-SDC-LAB.vmx

0 Kudos
LucD
Leadership
Leadership

The datastorename "S-001-DC3-PDC-DEVCLUSTER" does not match "ucs", there must be something else going wrong.

Are these missing datastores present in $storageviews?

Try showing the content of $storageviews before the Where-clause is executed.

Perhaps these datastores are "shared" and the first test doesn't pass?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
GabCava
Enthusiast
Enthusiast

many thanks Luc,, in fact a temporary storage issue made that DS single hosted!! Fixing the issue it fixed the script output... sorry for wasting time

0 Kudos