- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this
Connect-VIServer -Server $vcenter -Credential $AdminCredential | Out-Null
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$accessMgr = Get-View -Id $esx.ExtensionData.ConfigManager.hostAccessManager
if ($accessMgr.LockdownMode -in [VMware.Vim.HostLockdownMode]::lockdownNormal,[VMware.Vim.HostLockdownMode]::lockdownStrict) {
$accessMgr.ChangeLockdownMode([VMware.Vim.HostLockdownMode]::lockdownDisabled)
}
}
Disconnect-VIServer -Server $vcenter -Force -confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks LucD,
Please can you narrow this down to cluster level. For example, enter details like vcenter = VCSA01 and Cluster= Clus01 Username = admin@local password = Password01.
Thanks in Advance
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change
Get-VMHost -PipelineVariable esx |
to
Get-Cluster -Name Clus01 | Get-VMHost -PipelineVariable esx |
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Like this
$vcenter = 'VCSA01'
$Cluster= 'Clus01'
$Username = 'admin@local'
$password = 'Password01'
$AdminCredential = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, (ConvertTo-SecureString -String $password -AsPlainText -Force)
Connect-VIServer -Server $vcenter -Credential $AdminCredential | Out-Null
Get-Cluster -Name $Cluster | Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$accessMgr = Get-View -Id $esx.ExtensionData.ConfigManager.hostAccessManager
if ($accessMgr.LockdownMode -in [VMware.Vim.HostLockdownMode]::lockdownNormal,[VMware.Vim.HostLockdownMode]::lockdownStrict) {
$accessMgr.ChangeLockdownMode([VMware.Vim.HostLockdownMode]::lockdownDisabled)
}
}
Disconnect-VIServer -Server $vcenter -Force -confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks LucD....GENIUS..!
That works perfectly, disabled the hosts within the cluster. What do I need to change to enable lockdown (Normal).
Thanks in advance
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Change
if ($accessMgr.LockdownMode -in [VMware.Vim.HostLockdownMode]::lockdownNormal,[VMware.Vim.HostLockdownMode]::lockdownStrict) {
$accessMgr.ChangeLockdownMode([VMware.Vim.HostLockdownMode]::lockdownDisabled)
}
to
if ($accessMgr.LockdownMode -eq [VMware.Vim.HostLockdownMode]::lockdownDisabled) {
$accessMgr.ChangeLockdownMode([VMware.Vim.HostLockdownMode]::lockdownNormal)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Works like a dreammmmmmmm....!!!!
Thank you for all your help and answering all my queries.
One last question, some of our environments require the domainname\username e.g. (Prod\testuser01). The script returns an error 'user name or password has an invalid format'. But I can manually add the user with the domain in front successfully.
Is a parameter/variable required to the script to allow this.
Thanks
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error seems to indicate the provided password does not meet the complexity requirements.
I don't see anything about an invalid format
The format "domain\user" is correct.
You can also try passing "user@domain", that should work as well.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks LucD,
I have used a complex password and tried '\' and '@' and get the attached error.
Create User
Key
haTask-ha-folder-root-vim.host.LocalAccountManager.createUser-3465424481
Description
Creates a local user account
Folder:
State
Failed - A specified parameter was not correct: id
Errors
Please advise.
Thanks in Advance.
Mo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you switching back to this tread?
My last reply is in the other thread
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Isn't that what the New-VIpermission cmdlet is doing?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks LucD,
The requirement for one of the environments is to add domain\username as per the attachment and I have done this manually via right click manage ---> permissions... Add user and select the role. So like to amend the script to do this.
If i try to add a domain\username via security & users --> users --> add user I get the error 'Invalid characters found in user name. Please use only alpha-numeric characters. As discussed previously.
I hope that helps.
Please advise thanks
Many Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Adding Permissions is not the same as adding a user account.
For permissions use the New-VIPermission cmdlet, for adding a user, while connected to an ESXi node, use the New-VMHostAccount cmdlet. This adds a new account on the ESXi node.
The latter only creates local accounts, not AD accounts.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks LucD,
What do I need to do to achieve the following in the script:
The requirement for one of the environments is to add domain\username as per the attachment and I have done this manually via right click manage ---> permissions... Add user and select the role. So like to amend the script to do this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure what more can I tell you.
Use the New-VIPermission cmdlet, on the Principal parameter, use the domain/user notation.
The snippet I gave earlier already contains such a New-VIPermssion line.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference