VMware Cloud Community
Ranger_rkm
Contributor
Contributor
Jump to solution

Have trouble getting this script to run on 1 cluster and not the others

Hello,

I'm trying to get this to run only on one Cluster, currently I have it running on a single host, but would like to get it to work on a specific Cluster.

get-vmhost host1.lab.local | get-view).EnterLockdownMode() | get-vmhost | select Name,@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}} | ft -auto Name LockDown

I have tried this but getting this error message:

(Get-Cluster "Local" | get-view).EnterLockdownMode() | get-vmhost | select Name,@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}} | ft -auto Name LockDown

Error Message

Method invocation failed because [VMware.Vim.ClusterComputeResource] doesn't contain a method named 'EnterLockdownMode'.

At line:1 char:51

+ (Get-Cluster "Local" | get-view).EnterLockdownMode <<<< () | get-vmhost | sel

ect Name,@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}} | ft -auto N

ame LockDown

    + CategoryInfo          : InvalidOperation: (EnterLockdownMode:String) [],

    RuntimeException

    + FullyQualifiedErrorId : MethodNotFound

How can I run this for only one cluster and not the other clusters.

Thanks,

Mike

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-Cluster local | Get-VMHost | %{
    (
get-view $_).EnterLockdownMode()
   
$_ | select Name,@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}}
}
| ft -auto


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-Cluster local | Get-VMHost | %{
    (
get-view $_).EnterLockdownMode()
   
$_ | select Name,@{N="LockDown";E={$_.Extensiondata.Config.adminDisabled}}
}
| ft -auto


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

0 Kudos
Ranger_rkm
Contributor
Contributor
Jump to solution

Thanks LucD, I was able to get it to work perrfect.

Take Care,

-Mike

0 Kudos