Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $vmhost = 'esxi-01.domain.local'
- $vcenter = 'vcenter.domain.local'
- $vcenter_user = 'administrator@vsphere.local'
- # Save encrypted password to a file
- # Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File vcenter-password.txt
- $vcenter_password = Get-Content vcenter-password.txt | ConvertTo-SecureString
- $nimble_mgmt_address = '10.1.1.1'
- $nimble_user = 'admin'
- # Save encrypted password to a file
- # Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File nimble-password.txt
- $nimble_password = Get-Content nimble-password.txt | ConvertTo-SecureString
- $datastores = Import-Csv 'Nimble Datastores.csv'
- $initiator_group = 'VMware-ESXi-Hosts'
- $performance_policy = 'VMware ESX 5'
- $volumes = @()
- # Connect to Nimble
- $nimble_creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $nimble_user, $nimble_password
- Connect-NSGroup -Group $nimble_mgmt_address -credential $nimble_creds | Out-Null
- # Connect to vCenter
- if ($global:defaultviservers -eq $null) {
- $vcenter_creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $vcenter_user, $vcenter_password
- Write-Host "Connecting to $vcenter"
- Connect-VIServer -Server $vcenter -Credential $vcenter_creds
- }
- # Create new volumes
- $initiator_group_id = Get-NSInitiatorGroup -Name $initiator_group | Select-Object -ExpandProperty Id
- $performance_policy_id = Get-NSPerformancePolicy -Name $performance_policy | Select-Object -ExpandProperty Id
- foreach ($ds in $datastores) {
- $volume = New-NSVolume -Name $ds.Name -Size $ds.Size -Multi_Initiator:$true -PerfPolicy_Id $performance_policy_id
- # Set access control record
- New-NSAccessControlRecord -Vol_Id $volume.id -Initiator_Group_Id $initiator_group_id | Out-Null
- $volumes += $volume
- }
- # Create new datastores
- Get-VMHostStorage -VMHost $vmhost -RescanAllHba
- foreach ($v in $volumes) {
- $canonical_name = "eui.$($v.serial_number)"
- New-Datastore -Name $v.Name -Path $canonical_name -Vmfs -VMHost $vmhost
- }
Add Comment
Please, Sign In to add comment