Merge remote-tracking branch 'upstream/master'
This commit is contained in:
0
.gitattributes
vendored
Normal file
0
.gitattributes
vendored
Normal file
51
.gitignore
vendored
Normal file
51
.gitignore
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# PowerShell Studio Files
|
||||||
|
*.temppoint.*
|
||||||
|
*.psproj.psbuild
|
||||||
|
*.psbuild
|
||||||
|
|
||||||
|
#VS Code Files
|
||||||
|
*.vscode
|
||||||
|
|
||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Operating System Files
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear on external disk
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
$BackupJob = $BackupAPI.create($CreateSpec)
|
$BackupJob = $BackupAPI.create($CreateSpec)
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Error $Error[0].exception.Message
|
throw $_.Exception.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,6 +84,7 @@
|
|||||||
start-sleep -seconds 5
|
start-sleep -seconds 5
|
||||||
} until ($BackupAPI.get("$($BackupJob.ID)").progress -eq 100 -or $BackupAPI.get("$($BackupJob.ID)").state -ne "INPROGRESS")
|
} until ($BackupAPI.get("$($BackupJob.ID)").progress -eq 100 -or $BackupAPI.get("$($BackupJob.ID)").state -ne "INPROGRESS")
|
||||||
|
|
||||||
|
Write-Progress -Activity "Backing up VCSA" -Completed
|
||||||
$BackupAPI.get("$($BackupJob.ID)") | select id, progress, state
|
$BackupAPI.get("$($BackupJob.ID)") | select id, progress, state
|
||||||
}
|
}
|
||||||
Else {
|
Else {
|
||||||
197
Modules/ContentLibrary/ContentLibrary.psm1
Normal file
197
Modules/ContentLibrary/ContentLibrary.psm1
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
Function Get-ContentLibrary {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: William Lam
|
||||||
|
Organization: VMware
|
||||||
|
Blog: www.virtuallyghetto.com
|
||||||
|
Twitter: @lamw
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
This function lists all available vSphere Content Libaries
|
||||||
|
.PARAMETER LibraryName
|
||||||
|
The name of a vSphere Content Library
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ContentLibrary
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ContentLibrary -LibraryName Test
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$false)][String]$LibraryName
|
||||||
|
)
|
||||||
|
|
||||||
|
$contentLibaryService = Get-CisService com.vmware.content.library
|
||||||
|
$libaryIDs = $contentLibaryService.list()
|
||||||
|
|
||||||
|
$results = @()
|
||||||
|
foreach($libraryID in $libaryIDs) {
|
||||||
|
$library = $contentLibaryService.get($libraryId)
|
||||||
|
|
||||||
|
# Use vCenter REST API to retrieve name of Datastore that is backing the Content Library
|
||||||
|
$datastoreService = Get-CisService com.vmware.vcenter.datastore
|
||||||
|
$datastore = $datastoreService.get($library.storage_backings.datastore_id)
|
||||||
|
|
||||||
|
if(!$LibraryName) {
|
||||||
|
$libraryResult = [pscustomobject] @{
|
||||||
|
Id = $library.Id;
|
||||||
|
Name = $library.Name;
|
||||||
|
Type = $library.Type;
|
||||||
|
Description = $library.Description;
|
||||||
|
Datastore = $datastore.name;
|
||||||
|
CreationTime = $library.Creation_Time;
|
||||||
|
}
|
||||||
|
$results+=$libraryResult
|
||||||
|
} else {
|
||||||
|
if($LibraryName -eq $library.name) {
|
||||||
|
$libraryResult = [pscustomobject] @{
|
||||||
|
Name = $library.Name;
|
||||||
|
Id = $library.Id;
|
||||||
|
Type = $library.Type;
|
||||||
|
Description = $library.Description;
|
||||||
|
Datastore = $datastore.name;
|
||||||
|
CreationTime = $library.Creation_Time;
|
||||||
|
}
|
||||||
|
$results+=$libraryResult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$results
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-ContentLibraryItems {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: William Lam
|
||||||
|
Organization: VMware
|
||||||
|
Blog: www.virtuallyghetto.com
|
||||||
|
Twitter: @lamw
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
This function lists all items within a given vSphere Content Library
|
||||||
|
.PARAMETER LibraryName
|
||||||
|
The name of a vSphere Content Library
|
||||||
|
.PARAMETER LibraryItemName
|
||||||
|
The name of a vSphere Content Library Item
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ContentLibraryItems -LibraryName Test
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ContentLibraryItems -LibraryName Test -LibraryItemName TinyPhotonVM
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][String]$LibraryName,
|
||||||
|
[Parameter(Mandatory=$false)][String]$LibraryItemName
|
||||||
|
)
|
||||||
|
|
||||||
|
$contentLibaryService = Get-CisService com.vmware.content.library
|
||||||
|
$libaryIDs = $contentLibaryService.list()
|
||||||
|
|
||||||
|
$results = @()
|
||||||
|
foreach($libraryID in $libaryIDs) {
|
||||||
|
$library = $contentLibaryService.get($libraryId)
|
||||||
|
if($library.name -eq $LibraryName) {
|
||||||
|
$contentLibaryItemService = Get-CisService com.vmware.content.library.item
|
||||||
|
$itemIds = $contentLibaryItemService.list($libraryID)
|
||||||
|
|
||||||
|
foreach($itemId in $itemIds) {
|
||||||
|
$item = $contentLibaryItemService.get($itemId)
|
||||||
|
|
||||||
|
if(!$LibraryItemName) {
|
||||||
|
$itemResult = [pscustomobject] @{
|
||||||
|
Name = $item.name;
|
||||||
|
Id = $item.id;
|
||||||
|
Description = $item.description;
|
||||||
|
Size = $item.size
|
||||||
|
Type = $item.type;
|
||||||
|
Version = $item.version;
|
||||||
|
MetadataVersion = $item.metadata_version;
|
||||||
|
ContentVersion = $item.content_version;
|
||||||
|
}
|
||||||
|
$results+=$itemResult
|
||||||
|
} else {
|
||||||
|
if($LibraryItemName -eq $item.name) {
|
||||||
|
$itemResult = [pscustomobject] @{
|
||||||
|
Name = $item.name;
|
||||||
|
Id = $item.id;
|
||||||
|
Description = $item.description;
|
||||||
|
Size = $item.size
|
||||||
|
Type = $item.type;
|
||||||
|
Version = $item.version;
|
||||||
|
MetadataVersion = $item.metadata_version;
|
||||||
|
ContentVersion = $item.content_version;
|
||||||
|
}
|
||||||
|
$results+=$itemResult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$results
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-ContentLibraryItemFiles {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: William Lam
|
||||||
|
Organization: VMware
|
||||||
|
Blog: www.virtuallyghetto.com
|
||||||
|
Twitter: @lamw
|
||||||
|
===========================================================================
|
||||||
|
.DESCRIPTION
|
||||||
|
This function lists all item files within a given vSphere Content Library
|
||||||
|
.PARAMETER LibraryName
|
||||||
|
The name of a vSphere Content Library
|
||||||
|
.PARAMETER LibraryItemName
|
||||||
|
The name of a vSphere Content Library Item
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ContentLibraryItemFiles -LibraryName Test
|
||||||
|
.EXAMPLE
|
||||||
|
Get-ContentLibraryItemFiles -LibraryName Test -LibraryItemName TinyPhotonVM
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)][String]$LibraryName,
|
||||||
|
[Parameter(Mandatory=$false)][String]$LibraryItemName
|
||||||
|
)
|
||||||
|
|
||||||
|
$contentLibaryService = Get-CisService com.vmware.content.library
|
||||||
|
$libaryIDs = $contentLibaryService.list()
|
||||||
|
|
||||||
|
$results = @()
|
||||||
|
foreach($libraryID in $libaryIDs) {
|
||||||
|
$library = $contentLibaryService.get($libraryId)
|
||||||
|
if($library.name -eq $LibraryName) {
|
||||||
|
$contentLibaryItemService = Get-CisService com.vmware.content.library.item
|
||||||
|
$itemIds = $contentLibaryItemService.list($libraryID)
|
||||||
|
|
||||||
|
foreach($itemId in $itemIds) {
|
||||||
|
$itemName = ($contentLibaryItemService.get($itemId)).name
|
||||||
|
$contenLibraryItemFileSerice = Get-CisService com.vmware.content.library.item.file
|
||||||
|
$files = $contenLibraryItemFileSerice.list($itemId)
|
||||||
|
|
||||||
|
foreach($file in $files) {
|
||||||
|
if(!$LibraryItemName) {
|
||||||
|
$fileResult = [pscustomobject] @{
|
||||||
|
Name = $file.name;
|
||||||
|
Version = $file.version;
|
||||||
|
Size = $file.size;
|
||||||
|
Stored = $file.cached;
|
||||||
|
}
|
||||||
|
$results+=$fileResult
|
||||||
|
} else {
|
||||||
|
if($itemName -eq $LibraryItemName) {
|
||||||
|
$fileResult = [pscustomobject] @{
|
||||||
|
Name = $file.name;
|
||||||
|
Version = $file.version;
|
||||||
|
Size = $file.size;
|
||||||
|
Stored = $file.cached;
|
||||||
|
}
|
||||||
|
$results+=$fileResult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$results
|
||||||
|
}
|
||||||
245
Modules/DatastoreFunctions/DatastoreFunctions.psm1
Normal file
245
Modules/DatastoreFunctions/DatastoreFunctions.psm1
Normal file
@@ -0,0 +1,245 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS Datastore Functions
|
||||||
|
.DESCRIPTION A collection of functions to manipulate datastore Mount + Attach status
|
||||||
|
.EXAMPLE Get-Datastore | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT -AutoSize
|
||||||
|
.EXAMPLE Get-Datastore IX2ISCSI01 | Unmount-Datastore
|
||||||
|
.EXAMPLE Get-Datastore IX2ISCSI01 | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT -AutoSize
|
||||||
|
.EXAMPLE Get-Datastore IX2iSCSI01 | Mount-Datastore
|
||||||
|
.EXAMPLE Get-Datastore IX2iSCSI01 | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT -AutoSize
|
||||||
|
.EXAMPLE Get-Datastore IX2iSCSI01 | Detach-Datastore
|
||||||
|
.EXAMPLE Get-Datastore IX2iSCSI01 | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT -AutoSize
|
||||||
|
.EXAMPLE Get-Datastore IX2iSCSI01 | Attach-datastore
|
||||||
|
.EXAMPLE Get-Datastore IX2iSCSI01 | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT -AutoSize
|
||||||
|
.NOTES Written by Alan Renouf, originally published at https://blogs.vmware.com/vsphere/2012/01/automating-datastore-storage-device-detachment-in-vsphere-5.html
|
||||||
|
.NOTES May 2017: Modified by Jason Coleman (virtuallyjason.blogspot.com), to improve performance when dealing with a large number of hosts and datastores
|
||||||
|
#>
|
||||||
|
Function Get-HostViews {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
$Datastore
|
||||||
|
)
|
||||||
|
Begin{
|
||||||
|
$allDatastores = @()
|
||||||
|
}
|
||||||
|
Process {
|
||||||
|
$allDatastores += $Datastore
|
||||||
|
}
|
||||||
|
End {
|
||||||
|
#Build the array of Datastore Objects
|
||||||
|
if (-not $Datastore) {
|
||||||
|
$allDatastores = Get-Datastore
|
||||||
|
}
|
||||||
|
$allDatastores = $allDatastores | ? {$_.pstypenames -contains "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl"}
|
||||||
|
if (-not $allDatastores){
|
||||||
|
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
|
||||||
|
}
|
||||||
|
$allHosts = @()
|
||||||
|
$DShostsKeys = $allDatastores.extensiondata.host.key.value | sort | get-unique -asstring
|
||||||
|
$DShosts = foreach ($thisKey in $DShostsKeys) {($allDatastores.extensiondata.host | ? {$_.key.value -eq $thisKey})[0]}
|
||||||
|
$i = 1
|
||||||
|
foreach ($DSHost in $DSHosts){
|
||||||
|
write-progress -activity "Collecting ESXi Host Views" -status "Querying $($dshost.key)..." -percentComplete ($i++/$DSHosts.count*100)
|
||||||
|
$hostObj = "" | select keyValue,hostView,storageSys
|
||||||
|
$hostObj.hostView = get-view $DSHost.key
|
||||||
|
$hostObj.keyValue = $DSHost.key.value
|
||||||
|
$hostObj.storageSys = Get-View $hostObj.hostView.ConfigManager.StorageSystem
|
||||||
|
$allHosts += $hostObj
|
||||||
|
}
|
||||||
|
write-progress -activity "Collecting ESXi Host Views" -completed
|
||||||
|
$allHosts
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-DatastoreMountInfo {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(ValueFromPipeline=$true)]
|
||||||
|
$Datastore
|
||||||
|
)
|
||||||
|
#Roll back up an unrolled array from a pipeline
|
||||||
|
Begin{
|
||||||
|
$allDatastores = @()
|
||||||
|
}
|
||||||
|
Process {
|
||||||
|
$allDatastores += $Datastore
|
||||||
|
}
|
||||||
|
End {
|
||||||
|
$AllInfo = @()
|
||||||
|
#Build the array of Datastore Objects
|
||||||
|
if (-not $Datastore) {
|
||||||
|
$allDatastores = Get-Datastore
|
||||||
|
}
|
||||||
|
$allDatastores = $allDatastores | ? {$_.pstypenames -contains "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl"}
|
||||||
|
if (-not $allDatastores){
|
||||||
|
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
|
||||||
|
}
|
||||||
|
$allDatastoreNAAs = foreach ($ds in $allDatastores) {$ds.ExtensionData.Info.vmfs.extent[0].diskname}
|
||||||
|
|
||||||
|
#Build the array of custom Host Objects
|
||||||
|
$allHosts = Get-HostViews -datastore $allDatastores
|
||||||
|
$output = @()
|
||||||
|
$i = 1
|
||||||
|
foreach ($dsHost in $allHosts){
|
||||||
|
write-progress -activity "Checking Datastore access" -status "Checking $($dshost.hostview.name)..." -percentComplete ($i++ / $allHosts.count * 100)
|
||||||
|
#Get all devices on the host that match the list of $allDatastoreNAAs
|
||||||
|
$devices = $dsHost.storagesys.StorageDeviceInfo.ScsiLun
|
||||||
|
foreach ($device in $devices){
|
||||||
|
if ($allDatastoreNAAs -contains $device.canonicalName){
|
||||||
|
#Record information about this device/host combo
|
||||||
|
$thisDatastore = $alldatastores | ? {$_.ExtensionData.Info.vmfs.extent[0].diskname -eq $device.canonicalName}
|
||||||
|
$hostviewDSAttachState = ""
|
||||||
|
if ($device.operationalState[0] -eq "ok") {
|
||||||
|
$hostviewDSAttachState = "Attached"
|
||||||
|
} elseif ($device.operationalState[0] -eq "off") {
|
||||||
|
$hostviewDSAttachState = "Detached"
|
||||||
|
} else {
|
||||||
|
$hostviewDSAttachState = $device.operationalstate[0]
|
||||||
|
}
|
||||||
|
$Info = "" | Select Datastore, VMHost, Lun, Mounted, State
|
||||||
|
$Info.VMHost = $dsHost.hostview.name
|
||||||
|
$Info.Datastore = $thisDatastore.name
|
||||||
|
$Info.Lun = $device.canonicalName
|
||||||
|
$Info.mounted = ($thisDatastore.extensiondata.host | ? {$_.key.value -eq $dshost.keyvalue}).mountinfo.mounted
|
||||||
|
$Info.state = $hostviewDSAttachState
|
||||||
|
$output += $info
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write-progress -activity "Checking Datastore access" -completed
|
||||||
|
$output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Detach-Datastore {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(ValueFromPipeline=$true)]
|
||||||
|
$Datastore
|
||||||
|
)
|
||||||
|
Begin{
|
||||||
|
$allDatastores = @()
|
||||||
|
}
|
||||||
|
Process {
|
||||||
|
$allDatastores += $Datastore
|
||||||
|
}
|
||||||
|
End {
|
||||||
|
$allDatastores = $allDatastores | ? {$_.pstypenames -contains "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl"}
|
||||||
|
if (-not $allDatastores){
|
||||||
|
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
|
||||||
|
}
|
||||||
|
$allDatastoreNAAs = foreach ($ds in $allDatastores) {$ds.ExtensionData.Info.vmfs.extent[0].diskname}
|
||||||
|
$allHosts = Get-HostViews -datastore $allDatastores
|
||||||
|
$j = 1
|
||||||
|
foreach ($dsHost in $allHosts){
|
||||||
|
#Get all devices on the host that match the list of $allDatastoreNAAs
|
||||||
|
write-progress -id 1 -activity "Detaching Datastores" -status "Removing device(s) from $($dsHost.hostview.name)" -percentComplete ($j++ / $allHosts.count * 100)
|
||||||
|
$devices = $dsHost.storagesys.StorageDeviceInfo.ScsiLun | ? {$allDatastoreNAAs -contains $_.canonicalName}
|
||||||
|
$i = 1
|
||||||
|
foreach ($device in $devices){
|
||||||
|
write-progress -parentid 1 -activity "Detaching Datastores" -status "Removing device: $(($allDatastores | ? {$_.ExtensionData.Info.vmfs.extent[0].diskname -eq $device.canonicalName}).name)" -percentComplete ($i++ / $allDatastoreNAAs.count * 100)
|
||||||
|
$LunUUID = $Device.Uuid
|
||||||
|
$dsHost.storageSys.DetachScsiLun($LunUUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write-progress -activity "Detaching Datastores" -completed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Attach-Datastore {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(ValueFromPipeline=$true)]
|
||||||
|
$Datastore
|
||||||
|
)
|
||||||
|
Begin{
|
||||||
|
$allDatastores = @()
|
||||||
|
}
|
||||||
|
Process {
|
||||||
|
$allDatastores += $Datastore
|
||||||
|
}
|
||||||
|
End {
|
||||||
|
$allDatastores = $allDatastores | ? {$_.pstypenames -contains "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl"}
|
||||||
|
if (-not $allDatastores){
|
||||||
|
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
|
||||||
|
}
|
||||||
|
$allDatastoreNAAs = foreach ($ds in $allDatastores) {$ds.ExtensionData.Info.vmfs.extent[0].diskname}
|
||||||
|
$allHosts = Get-HostViews -datastore $allDatastores
|
||||||
|
$j = 1
|
||||||
|
foreach ($dsHost in $allHosts){
|
||||||
|
#Get all devices on the host that match the list of $allDatastoreNAAs
|
||||||
|
write-progress -id 1 -activity "Attaching Datastores" -status "Attaching devices to $($dsHost.hostview.name)" -percentComplete ($j++ / $allHosts.count * 100)
|
||||||
|
$devices = $dsHost.storagesys.StorageDeviceInfo.ScsiLun
|
||||||
|
$i = 1
|
||||||
|
foreach ($device in $devices){
|
||||||
|
write-progress -parentid 1 -activity "Attaching Datastores" -status "Attaching device: $($Device.Uuid)" -percentComplete ($i++ / $devices.count * 100)
|
||||||
|
if ($allDatastoreNAAs -contains $device.canonicalName){
|
||||||
|
$LunUUID = $Device.Uuid
|
||||||
|
$dsHost.storageSys.AttachScsiLun($LunUUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write-progress -activity "Attaching Datastores" -completed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Unmount-Datastore {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(ValueFromPipeline=$true)]
|
||||||
|
$Datastore
|
||||||
|
)
|
||||||
|
Begin{
|
||||||
|
$allDatastores = @()
|
||||||
|
}
|
||||||
|
Process {
|
||||||
|
$allDatastores += $Datastore
|
||||||
|
}
|
||||||
|
End {
|
||||||
|
$allDatastores = $allDatastores | ? {$_.pstypenames -contains "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl"}
|
||||||
|
if (-not $allDatastores){
|
||||||
|
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
|
||||||
|
}
|
||||||
|
$allHosts = Get-HostViews -datastore $allDatastores
|
||||||
|
$j = 1
|
||||||
|
foreach ($dsHost in $allHosts){
|
||||||
|
write-progress -id 1 -activity "Unmounting Datastores" -status "Unmounting devices from $($dsHost.hostview.name)" -percentComplete ($j++ / $allHosts.count * 100)
|
||||||
|
$i = 1
|
||||||
|
foreach ($ds in $allDatastores){
|
||||||
|
write-progress -parentid 1 -activity "Unmounting Datastores" -status "Unmounting device: $($ds.name)" -percentComplete ($i++ / $allDatastores.count * 100)
|
||||||
|
$dsHost.storageSys.UnmountVmfsVolume($DS.ExtensionData.Info.vmfs.uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write-progress -activity "Unmounting Datastores" -completed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Mount-Datastore {
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param (
|
||||||
|
[Parameter(ValueFromPipeline=$true)]
|
||||||
|
$Datastore
|
||||||
|
)
|
||||||
|
Begin{
|
||||||
|
$allDatastores = @()
|
||||||
|
}
|
||||||
|
Process {
|
||||||
|
$allDatastores += $Datastore
|
||||||
|
}
|
||||||
|
End {
|
||||||
|
$allDatastores = $allDatastores | ? {$_.pstypenames -contains "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.DatastoreImpl"}
|
||||||
|
if (-not $allDatastores){
|
||||||
|
Throw "No Datastores found.`nIs ""$Datastore"" a Datastore Object?"
|
||||||
|
}
|
||||||
|
$allHosts = Get-HostViews -datastore $allDatastores
|
||||||
|
$j = 0
|
||||||
|
foreach ($dsHost in $allHosts){
|
||||||
|
write-progress -activity "Mounting Datastores" -status "Mounting devices to $($dsHost.hostview.name)" -percentComplete ($j++ / $allHosts.count * 100)
|
||||||
|
$i = 1
|
||||||
|
foreach ($ds in $allDatastores){
|
||||||
|
write-progress -activity "Mounting Datastores" -status "Mounting device: $($DS.ExtensionData.Info.vmfs.uuid)" -percentComplete ($i++ / $allDatastores.count * 100)
|
||||||
|
$dsHost.storageSys.MountVmfsVolume($DS.ExtensionData.Info.vmfs.uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write-progress -activity "Mounting Datastores" -completed
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Modules/VMware-vCD-Module/README.md
Normal file
23
Modules/VMware-vCD-Module/README.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
VMware-vCD-Module PowerShell Module
|
||||||
|
===================================
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# About
|
||||||
|
|
||||||
|
## Project Owner:
|
||||||
|
|
||||||
|
Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K)
|
||||||
|
|
||||||
|
## Project WebSite:
|
||||||
|
[mycloudrevolution.com](http://mycloudrevolution.com/)
|
||||||
|
|
||||||
|
## Project Documentation:
|
||||||
|
|
||||||
|
[Read the Docs](http://vmware-vcd-module.readthedocs.io/)
|
||||||
|
|
||||||
|
## Project Description:
|
||||||
|
|
||||||
|
The 'VMware-vCD-Module' PowerShell Module is focused on the initial craation of VMware vCloud Director Objects like Org, Org User, Org VDC.
|
||||||
|
|
||||||
|
|
||||||
126
Modules/VMware-vCD-Module/VMware-vCD-Module.psd1
Normal file
126
Modules/VMware-vCD-Module/VMware-vCD-Module.psd1
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
#
|
||||||
|
# Modulmanifest für das Modul "PSGet_VMware-vCD-Module"
|
||||||
|
#
|
||||||
|
# Generiert von: Markus
|
||||||
|
#
|
||||||
|
# Generiert am: 6/11/2017
|
||||||
|
#
|
||||||
|
|
||||||
|
@{
|
||||||
|
|
||||||
|
# Die diesem Manifest zugeordnete Skript- oder Binärmoduldatei.
|
||||||
|
# RootModule = ''
|
||||||
|
|
||||||
|
# Die Versionsnummer dieses Moduls
|
||||||
|
ModuleVersion = '0.2.0'
|
||||||
|
|
||||||
|
# ID zur eindeutigen Kennzeichnung dieses Moduls
|
||||||
|
GUID = '1ef8a2de-ca22-4c88-8cdb-e00f35007d2a'
|
||||||
|
|
||||||
|
# Autor dieses Moduls
|
||||||
|
Author = 'Markus'
|
||||||
|
|
||||||
|
# Unternehmen oder Hersteller dieses Moduls
|
||||||
|
CompanyName = 'Unbekannt'
|
||||||
|
|
||||||
|
# Urheberrechtserklärung für dieses Modul
|
||||||
|
Copyright = '(c) 2017 Markus. Alle Rechte vorbehalten.'
|
||||||
|
|
||||||
|
# Beschreibung der von diesem Modul bereitgestellten Funktionen
|
||||||
|
# Description = ''
|
||||||
|
|
||||||
|
# Die für dieses Modul mindestens erforderliche Version des Windows PowerShell-Moduls
|
||||||
|
# PowerShellVersion = ''
|
||||||
|
|
||||||
|
# Der Name des für dieses Modul erforderlichen Windows PowerShell-Hosts
|
||||||
|
# PowerShellHostName = ''
|
||||||
|
|
||||||
|
# Die für dieses Modul mindestens erforderliche Version des Windows PowerShell-Hosts
|
||||||
|
# PowerShellHostVersion = ''
|
||||||
|
|
||||||
|
# Die für dieses Modul mindestens erforderliche Microsoft .NET Framework-Version
|
||||||
|
# DotNetFrameworkVersion = ''
|
||||||
|
|
||||||
|
# Die für dieses Modul mindestens erforderliche Version der CLR (Common Language Runtime)
|
||||||
|
# CLRVersion = ''
|
||||||
|
|
||||||
|
# Die für dieses Modul erforderliche Prozessorarchitektur ("Keine", "X86", "Amd64").
|
||||||
|
# ProcessorArchitecture = ''
|
||||||
|
|
||||||
|
# Die Module, die vor dem Importieren dieses Moduls in die globale Umgebung geladen werden müssen
|
||||||
|
# RequiredModules = @()
|
||||||
|
|
||||||
|
# Die Assemblys, die vor dem Importieren dieses Moduls geladen werden müssen
|
||||||
|
# RequiredAssemblies = @()
|
||||||
|
|
||||||
|
# Die Skriptdateien (PS1-Dateien), die vor dem Importieren dieses Moduls in der Umgebung des Aufrufers ausgeführt werden.
|
||||||
|
# ScriptsToProcess = @()
|
||||||
|
|
||||||
|
# Die Typdateien (.ps1xml), die beim Importieren dieses Moduls geladen werden sollen
|
||||||
|
# TypesToProcess = @()
|
||||||
|
|
||||||
|
# Die Formatdateien (.ps1xml), die beim Importieren dieses Moduls geladen werden sollen
|
||||||
|
# FormatsToProcess = @()
|
||||||
|
|
||||||
|
# Die Module, die als geschachtelte Module des in "RootModule/ModuleToProcess" angegebenen Moduls importiert werden sollen.
|
||||||
|
NestedModules = @('functions\Invoke-MyOnBoarding.psm1',
|
||||||
|
'functions\New-MyOrg.psm1',
|
||||||
|
'functions\New-MyOrgAdmin.psm1',
|
||||||
|
'functions\New-MyOrgVdc.psm1')
|
||||||
|
|
||||||
|
# Aus diesem Modul zu exportierende Funktionen
|
||||||
|
FunctionsToExport = 'Invoke-MyOnBoarding', 'New-MyOrg', 'New-MyOrgAdmin', 'New-MyOrgVdc'
|
||||||
|
|
||||||
|
# Aus diesem Modul zu exportierende Cmdlets
|
||||||
|
CmdletsToExport = '*'
|
||||||
|
|
||||||
|
# Die aus diesem Modul zu exportierenden Variablen
|
||||||
|
VariablesToExport = '*'
|
||||||
|
|
||||||
|
# Aus diesem Modul zu exportierende Aliase
|
||||||
|
AliasesToExport = '*'
|
||||||
|
|
||||||
|
# Aus diesem Modul zu exportierende DSC-Ressourcen
|
||||||
|
# DscResourcesToExport = @()
|
||||||
|
|
||||||
|
# Liste aller Module in diesem Modulpaket
|
||||||
|
# ModuleList = @()
|
||||||
|
|
||||||
|
# Liste aller Dateien in diesem Modulpaket
|
||||||
|
# FileList = @()
|
||||||
|
|
||||||
|
# Die privaten Daten, die an das in "RootModule/ModuleToProcess" angegebene Modul übergeben werden sollen. Diese können auch eine PSData-Hashtabelle mit zusätzlichen von PowerShell verwendeten Modulmetadaten enthalten.
|
||||||
|
PrivateData = @{
|
||||||
|
|
||||||
|
PSData = @{
|
||||||
|
|
||||||
|
# Tags applied to this module. These help with module discovery in online galleries.
|
||||||
|
# Tags = @()
|
||||||
|
|
||||||
|
# A URL to the license for this module.
|
||||||
|
# LicenseUri = ''
|
||||||
|
|
||||||
|
# A URL to the main website for this project.
|
||||||
|
# ProjectUri = ''
|
||||||
|
|
||||||
|
# A URL to an icon representing this module.
|
||||||
|
# IconUri = ''
|
||||||
|
|
||||||
|
# ReleaseNotes of this module
|
||||||
|
# ReleaseNotes = ''
|
||||||
|
|
||||||
|
# External dependent modules of this module
|
||||||
|
# ExternalModuleDependencies = ''
|
||||||
|
|
||||||
|
} # End of PSData hashtable
|
||||||
|
|
||||||
|
} # End of PrivateData hashtable
|
||||||
|
|
||||||
|
# HelpInfo-URI dieses Moduls
|
||||||
|
# HelpInfoURI = ''
|
||||||
|
|
||||||
|
# Standardpräfix für Befehle, die aus diesem Modul exportiert werden. Das Standardpräfix kann mit "Import-Module -Prefix" überschrieben werden.
|
||||||
|
# DefaultCommandPrefix = ''
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
24
Modules/VMware-vCD-Module/examples/OnBoarding.json
Normal file
24
Modules/VMware-vCD-Module/examples/OnBoarding.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"Org": {
|
||||||
|
"Name":"TestOrg",
|
||||||
|
"FullName": "Test Org",
|
||||||
|
"Description":"Automation Test Org"
|
||||||
|
},
|
||||||
|
"OrgAdmin": {
|
||||||
|
"Name":"TestOrgAdmin",
|
||||||
|
"Pasword": "myPassword1!",
|
||||||
|
"FullName":"Test OrgAdmin",
|
||||||
|
"EmailAddress":"test@admin.org"
|
||||||
|
},
|
||||||
|
"OrgVdc": {
|
||||||
|
"Name":"TestOrgVdc",
|
||||||
|
"FixedSize": "M",
|
||||||
|
"CPULimit": "1000",
|
||||||
|
"MEMLimit":"1024",
|
||||||
|
"StorageLimit":"1024",
|
||||||
|
"StorageProfile":"Standard-DC01",
|
||||||
|
"ProviderVDC":"Provider-VDC-DC01",
|
||||||
|
"NetworkPool":"Provider-VDC-DC01-NetPool",
|
||||||
|
"ExternalNetwork": "External-OrgVdcNet"
|
||||||
|
}
|
||||||
|
}
|
||||||
172
Modules/VMware-vCD-Module/functions/Invoke-MyOnBoarding.psm1
Normal file
172
Modules/VMware-vCD-Module/functions/Invoke-MyOnBoarding.psm1
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
#Requires -Version 4
|
||||||
|
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
|
||||||
|
Function Invoke-MyOnBoarding {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Creates all vCD Objecst for a new IAAS Customer
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates all vCD Objects for a new IAAS Customer
|
||||||
|
|
||||||
|
All Objects are:
|
||||||
|
* Org
|
||||||
|
* Default Org Admin
|
||||||
|
* Org VDC
|
||||||
|
** Private Catalog
|
||||||
|
** Optional Bridged Network
|
||||||
|
|
||||||
|
JSON Config Example:
|
||||||
|
|
||||||
|
{
|
||||||
|
"Org": {
|
||||||
|
"Name":"TestOrg",
|
||||||
|
"FullName": "Test Org",
|
||||||
|
"Description":"Automation Test Org"
|
||||||
|
},
|
||||||
|
"OrgAdmin": {
|
||||||
|
"Name":"TestOrgAdmin",
|
||||||
|
"Pasword": "myPassword1!",
|
||||||
|
"FullName":"Test OrgAdmin",
|
||||||
|
"EmailAddress":"test@admin.org"
|
||||||
|
},
|
||||||
|
"OrgVdc": {
|
||||||
|
"Name":"TestOrgVdc",
|
||||||
|
"FixedSize": "M",
|
||||||
|
"CPULimit": "1000",
|
||||||
|
"MEMLimit":"1000",
|
||||||
|
"StorageLimit":"1000",
|
||||||
|
"StorageProfile":"Standard-DC01",
|
||||||
|
"ProviderVDC":"Provider-VDC-DC01",
|
||||||
|
"NetworkPool":"Provider-VDC-DC01-NetPool",
|
||||||
|
"ExternalNetwork": "External_OrgVdcNet"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
File Name : Invoke-MyOnBoarding.ps1
|
||||||
|
Author : Markus Kraus
|
||||||
|
Version : 1.2
|
||||||
|
State : Ready
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://mycloudrevolution.com/
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$true
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Invoke-MyOnBoarding -ConfigFile ".\OnBoarding.json" -Enabled:$false
|
||||||
|
|
||||||
|
.PARAMETER ConfigFile
|
||||||
|
Full Path to the JSON Config File
|
||||||
|
|
||||||
|
.PARAMETER Enabled
|
||||||
|
Should the Customer be enabled after creation
|
||||||
|
|
||||||
|
Default: $False
|
||||||
|
|
||||||
|
#>
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Path to the JSON Config File")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $ConfigFile,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the Customer be enabled after creation")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[Switch]$Enabled
|
||||||
|
)
|
||||||
|
Process {
|
||||||
|
|
||||||
|
$Valid = $true
|
||||||
|
|
||||||
|
Write-Verbose "## Import JSON Config"
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config...`n"
|
||||||
|
$Configs = Get-Content -Raw -Path $ConfigFile -ErrorAction Continue | ConvertFrom-Json -ErrorAction Continue
|
||||||
|
|
||||||
|
if (!($Configs)) {
|
||||||
|
$Valid = $false
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config Failed" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Importing JSON Config OK" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Valid) {
|
||||||
|
try{
|
||||||
|
Write-Verbose "## Create Org"
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org...`n" -ForegroundColor Yellow
|
||||||
|
$Trash = New-MyOrg -Name $Configs.Org.Name -FullName $Configs.Org.Fullname -Description $Configs.Org.Description -Enabled:$Enabled
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org OK" -ForegroundColor Green
|
||||||
|
Get-Org -Name $Configs.Org.Name | Select-Object Name, FullName, Enabled | Format-Table -AutoSize
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$Valid = $false
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new Org Failed" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Valid) {
|
||||||
|
try{
|
||||||
|
Write-Verbose "## Create OrgAdmin"
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin...`n" -ForegroundColor Yellow
|
||||||
|
$Trash = New-MyOrgAdmin -Name $Configs.OrgAdmin.Name -Pasword $Configs.OrgAdmin.Pasword -FullName $Configs.OrgAdmin.FullName -EmailAddress $Configs.OrgAdmin.EmailAddress -Org $Configs.Org.Name -Enabled:$Enabled
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin OK" -ForegroundColor Green
|
||||||
|
Get-CIUser -Org $Configs.Org.Name -Name $Configs.OrgAdmin.Name | Select-Object Name, FullName, Email | Format-Table -AutoSize
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$Valid = $false
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgAdmin Failed" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($Valid) {
|
||||||
|
try{
|
||||||
|
Write-Verbose "## Create OrgVdc"
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc...`n" -ForegroundColor Yellow
|
||||||
|
|
||||||
|
if ($Configs.OrgVdc.FixedSize){
|
||||||
|
|
||||||
|
Write-Host "Fixed Size (T-Shirt Size) '$($Configs.OrgVdc.FixedSize)' Org VDC Requested!"
|
||||||
|
|
||||||
|
switch ($Configs.OrgVdc.FixedSize) {
|
||||||
|
M {
|
||||||
|
[String]$CPULimit = 36000
|
||||||
|
[String]$MEMLimit = 122880
|
||||||
|
[String]$StorageLimit = 1048576
|
||||||
|
}
|
||||||
|
L {
|
||||||
|
[String]$CPULimit = 36000
|
||||||
|
[String]$MEMLimit = 245760
|
||||||
|
[String]$StorageLimit = 1048576
|
||||||
|
}
|
||||||
|
default {throw "Invalid T-Shirt Size!"}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Write-Host "Custom Org VDC Size Requested!"
|
||||||
|
|
||||||
|
$CPULimit = $Configs.OrgVdc.CPULimit
|
||||||
|
$MEMLimit = $Configs.OrgVdc.MEMLimit
|
||||||
|
$StorageLimit = $Configs.OrgVdc.StorageLimit
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Configs.OrgVdc.ExternalNetwork){
|
||||||
|
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool -StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -ExternalNetwork $Configs.OrgVdc.ExternalNetwork -Org $Configs.Org.Name -Enabled:$Enabled
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Trash = New-MyOrgVdc -Name $Configs.OrgVdc.Name -CPULimit $CPULimit -MEMLimit $MEMLimit -StorageLimit $StorageLimit -Networkpool $Configs.OrgVdc.NetworkPool -StorageProfile $Configs.OrgVdc.StorageProfile -ProviderVDC $Configs.OrgVdc.ProviderVDC -Org $Configs.Org.Name -Enabled:$Enabled
|
||||||
|
}
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc OK" -ForegroundColor Green
|
||||||
|
Get-OrgVdc -Org $Configs.Org.Name -Name $Configs.OrgVdc.Name | Select-Object Name, Enabled, CpuAllocationGhz, MemoryLimitGB, StorageLimitGB, AllocationModel, ThinProvisioned, UseFastProvisioning, `
|
||||||
|
@{N="StorageProfile";E={$_.ExtensionData.VdcStorageProfiles.VdcStorageProfile.Name}}, `
|
||||||
|
@{N='VCpuInMhz';E={$_.ExtensionData.VCpuInMhz}} | Format-Table -AutoSize
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$Valid = $false
|
||||||
|
Write-Host "$(Get-Date -Format "yyyy-MM-dd HH:mm:ss") Creating new OrgVdc Failed" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output "Overall Execution was Valid: $Valid"
|
||||||
|
}
|
||||||
|
}
|
||||||
107
Modules/VMware-vCD-Module/functions/New-MyOrg.psm1
Normal file
107
Modules/VMware-vCD-Module/functions/New-MyOrg.psm1
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
#Requires -Version 4
|
||||||
|
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
|
||||||
|
Function New-MyOrg {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Creates a new vCD Org with Default Parameters
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new vCD Org with Default Parameters.
|
||||||
|
|
||||||
|
Default Parameters are:
|
||||||
|
* Catalog Publishing
|
||||||
|
* Catalog Subscription
|
||||||
|
* VM Quota
|
||||||
|
* Stored VM Quota
|
||||||
|
* VM Lease Time
|
||||||
|
* Stored VM Lease Time
|
||||||
|
* Password Policy Settings
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
File Name : New-MyOrg.ps1
|
||||||
|
Author : Markus Kraus
|
||||||
|
Version : 1.1
|
||||||
|
State : Ready
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://mycloudrevolution.com/
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-MyOrg -Name "TestOrg" -FullName "Test Org" -Description "PowerCLI Test Org"
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
Name of the New Org as String
|
||||||
|
|
||||||
|
.PARAMETER FullName
|
||||||
|
Full Name of the New Org as String
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Description of the New Org as String
|
||||||
|
|
||||||
|
.PARAMETER Enabled
|
||||||
|
Should the New Org be enabled after creation
|
||||||
|
|
||||||
|
Default:$false
|
||||||
|
|
||||||
|
#>
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Org as string")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Name,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Name of the New Org as string")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $FullName,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Description of the New Org as string")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Description,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the New Org be enabled after creation")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[Switch]$Enabled
|
||||||
|
)
|
||||||
|
Process {
|
||||||
|
$vcloud = $DefaultCIServers[0].ExtensionData
|
||||||
|
|
||||||
|
## Create Objects
|
||||||
|
$AdminOrg = New-Object VMware.VimAutomation.Cloud.Views.AdminOrg
|
||||||
|
$orgGeneralSettings = New-Object VMware.VimAutomation.Cloud.Views.OrgGeneralSettings
|
||||||
|
$orgOrgLeaseSettings = New-Object VMware.VimAutomation.Cloud.Views.OrgLeaseSettings
|
||||||
|
$orgOrgVAppTemplateLeaseSettings = New-Object VMware.VimAutomation.Cloud.Views.OrgVAppTemplateLeaseSettings
|
||||||
|
$orgOrgPasswordPolicySettings = New-Object VMware.VimAutomation.Cloud.Views.OrgPasswordPolicySettings
|
||||||
|
$orgSettings = New-Object VMware.VimAutomation.Cloud.Views.OrgSettings
|
||||||
|
|
||||||
|
## Admin Settings
|
||||||
|
$adminOrg.Name = $name
|
||||||
|
$adminOrg.FullName = $FullName
|
||||||
|
$adminOrg.Description = $description
|
||||||
|
$adminOrg.IsEnabled = $Enabled
|
||||||
|
|
||||||
|
## Org Setting
|
||||||
|
### General Org Settings
|
||||||
|
$orgGeneralSettings.CanPublishCatalogs = $False
|
||||||
|
$orgGeneralSettings.CanPublishExternally = $False
|
||||||
|
$orgGeneralSettings.CanSubscribe = $True
|
||||||
|
$orgGeneralSettings.DeployedVMQuota = 0
|
||||||
|
$orgGeneralSettings.StoredVmQuota = 0
|
||||||
|
$orgSettings.OrgGeneralSettings = $orgGeneralSettings
|
||||||
|
### vApp Org Setting
|
||||||
|
$orgOrgLeaseSettings.DeleteOnStorageLeaseExpiration = $false
|
||||||
|
$orgOrgLeaseSettings.DeploymentLeaseSeconds = 0
|
||||||
|
$orgOrgLeaseSettings.StorageLeaseSeconds = 0
|
||||||
|
$orgSettings.VAppLeaseSettings = $orgOrgLeaseSettings
|
||||||
|
### vApp Template Org Setting
|
||||||
|
$orgOrgVAppTemplateLeaseSettings.DeleteOnStorageLeaseExpiration = $false
|
||||||
|
$orgOrgVAppTemplateLeaseSettings.StorageLeaseSeconds = 0
|
||||||
|
$orgSettings.VAppTemplateLeaseSettings = $orgOrgVAppTemplateLeaseSettings
|
||||||
|
### PasswordPolicySettings Org Setting
|
||||||
|
$orgOrgPasswordPolicySettings.AccountLockoutEnabled = $True
|
||||||
|
$orgOrgPasswordPolicySettings.InvalidLoginsBeforeLockout = 5
|
||||||
|
$orgOrgPasswordPolicySettings.AccountLockoutIntervalMinutes = 30
|
||||||
|
$orgSettings.OrgPasswordPolicySettings = $orgOrgPasswordPolicySettings
|
||||||
|
|
||||||
|
$adminOrg.Settings = $orgSettings
|
||||||
|
|
||||||
|
$CreateOrg = $vcloud.CreateOrg($adminOrg)
|
||||||
|
|
||||||
|
Get-Org -Name $name | Format-Table -AutoSize
|
||||||
|
}
|
||||||
|
}
|
||||||
91
Modules/VMware-vCD-Module/functions/New-MyOrgAdmin.psm1
Normal file
91
Modules/VMware-vCD-Module/functions/New-MyOrgAdmin.psm1
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
#Requires -Version 4
|
||||||
|
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
|
||||||
|
Function New-MyOrgAdmin {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Creates a new vCD Org Admin with Default Parameters
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new vCD Org Admin with Default Parameters
|
||||||
|
|
||||||
|
Default Parameters are:
|
||||||
|
* User Role
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
File Name : New-MyOrgAdmin.ps1
|
||||||
|
Author : Markus Kraus
|
||||||
|
Version : 1.1
|
||||||
|
State : Ready
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://mycloudrevolution.com/
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-MyOrgAdmin -Name "OrgAdmin" -Pasword "Anfang!!" -FullName "Org Admin" -EmailAddress "OrgAdmin@TestOrg.local" -Org "TestOrg"
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
Name of the New Org Admin as String
|
||||||
|
|
||||||
|
.PARAMETER FullName
|
||||||
|
Full Name of the New Org Admin as String
|
||||||
|
|
||||||
|
.PARAMETER Password
|
||||||
|
Password of the New Org Admin as String
|
||||||
|
|
||||||
|
.PARAMETER EmailAddress
|
||||||
|
EmailAddress of the New Org Admin as String
|
||||||
|
|
||||||
|
.PARAMETER Enabled
|
||||||
|
Should the New Org be enabled after creation
|
||||||
|
|
||||||
|
Default:$false
|
||||||
|
|
||||||
|
.PARAMETER Org
|
||||||
|
Org where the new Org Admin should be created as string
|
||||||
|
|
||||||
|
#>
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Org Admin as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Name,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Password of the New Org Admin as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Pasword,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Full Name of the New Org Admin as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $FullName,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="EmailAddress of the New Org Admin as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $EmailAddress,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Org Admin should be created as string")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Org,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the New Org be enabled after creation")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[Switch]$Enabled
|
||||||
|
)
|
||||||
|
Process {
|
||||||
|
|
||||||
|
## Create Objects
|
||||||
|
$OrgED = (Get-Org $Org).ExtensionData
|
||||||
|
$orgAdminUser = New-Object VMware.VimAutomation.Cloud.Views.User
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
$orgAdminUser.Name = $Name
|
||||||
|
$orgAdminUser.FullName = $FullName
|
||||||
|
$orgAdminUser.EmailAddress = $EmailAddress
|
||||||
|
$orgAdminUser.Password = $Pasword
|
||||||
|
$orgAdminUser.IsEnabled = $Enabled
|
||||||
|
|
||||||
|
$vcloud = $DefaultCIServers[0].ExtensionData
|
||||||
|
|
||||||
|
## Find Role
|
||||||
|
$orgAdminRole = $vcloud.RoleReferences.RoleReference | Where-Object {$_.Name -eq "Organization Administrator"}
|
||||||
|
$orgAdminUser.Role = $orgAdminRole
|
||||||
|
|
||||||
|
## Create User
|
||||||
|
$user = $orgED.CreateUser($orgAdminUser)
|
||||||
|
|
||||||
|
Get-CIUser -Org $Org -Name $Name | Format-Table -AutoSize
|
||||||
|
}
|
||||||
|
}
|
||||||
252
Modules/VMware-vCD-Module/functions/New-MyOrgVdc.psm1
Normal file
252
Modules/VMware-vCD-Module/functions/New-MyOrgVdc.psm1
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
#Requires -Version 4
|
||||||
|
#Requires -Modules VMware.VimAutomation.Cloud, @{ModuleName="VMware.VimAutomation.Cloud";ModuleVersion="6.3.0.0"}
|
||||||
|
Function New-MyOrgVdc {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Creates a new vCD Org VDC with Default Parameters
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new vCD Org VDC with Default Parameters
|
||||||
|
|
||||||
|
Default Parameters are:
|
||||||
|
* Allocation Model
|
||||||
|
* Network Quota
|
||||||
|
* VM Quota
|
||||||
|
* 'vCpu In Mhz'
|
||||||
|
* Fast Provisioning
|
||||||
|
* Thin Provisioning
|
||||||
|
* private Catalog
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
File Name : New-MyOrgVdc.ps1
|
||||||
|
Author : Markus Kraus
|
||||||
|
Version : 1.2
|
||||||
|
State : Ready
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://mycloudrevolution.com/
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-MyOrgVdc -Name "TestVdc" -CPULimit 1000 -MEMLimit 1000 -StorageLimit 1000 -StorageProfile "Standard-DC01" -NetworkPool "NetworkPool-DC01" -ProviderVDC "Provider-VDC-DC01" -Org "TestOrg" -ExternalNetwork "External_OrgVdcNet"
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
New-MyOrgVdc -Name "TestVdc" -CPULimit 1000 -MEMLimit 1000 -StorageLimit 1000 -StorageProfile "Standard-DC01" -NetworkPool "NetworkPool-DC01" -ProviderVDC "Provider-VDC-DC01" -Org "TestOrg"
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
Name of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER CPULimit
|
||||||
|
CPU Limit (MHz) of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER MEMLimit
|
||||||
|
Memory Limit (MB) of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER StorageLimit
|
||||||
|
Storage Limit (MB) of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER StorageProfile
|
||||||
|
Storage Profile of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER NetworkPool
|
||||||
|
Network Pool of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER ExternalNetwork
|
||||||
|
Optional External Network of the New Org VDC as String
|
||||||
|
|
||||||
|
.PARAMETER Enabled
|
||||||
|
Should the New Org VDC be enabled after creation
|
||||||
|
|
||||||
|
Default:$false
|
||||||
|
|
||||||
|
Note: If an External Network is requested the Org VDC will be enabled during External Network Configuration
|
||||||
|
|
||||||
|
.PARAMETER ProviderVDC
|
||||||
|
ProviderVDC where the new Org VDC should be created as string
|
||||||
|
|
||||||
|
.PARAMETER Org
|
||||||
|
Org where the new Org VDC should be created as string
|
||||||
|
|
||||||
|
.PARAMETER Timeout
|
||||||
|
Timeout for teh Org VDC to get Ready
|
||||||
|
|
||||||
|
Default: 120s
|
||||||
|
|
||||||
|
#>
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Name,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="CPU Limit (MHz) of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[int] $CPULimit,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Memory Limit (MB) of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[int] $MEMLimit,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Storage Limit (MB) of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[int] $StorageLimit,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Storage Profile of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $StorageProfile,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Network Pool of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $NetworkPool,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Optional External Network of the New Org VDC as String")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $ExternalNetwork,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Should the New Org VDC be enabled after creation")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[Switch]$Enabled,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="ProviderVDC where the new Org VDC should be created as string")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $ProviderVDC,
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Org where the new Org VDC should be created as string")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String] $Org,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False,HelpMessage="Timeout for teh Org VDC to get Ready")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[int] $Timeout = 120
|
||||||
|
)
|
||||||
|
Process {
|
||||||
|
## Create Objects and all Settings
|
||||||
|
Write-Verbose "Create Objects and all Settings"
|
||||||
|
$adminVdc = New-Object VMware.VimAutomation.Cloud.Views.AdminVdc
|
||||||
|
$adminVdc.Name = $name
|
||||||
|
$adminVdc.IsEnabled = $Enabled
|
||||||
|
$OrgVdcproviderVdc = Get-ProviderVdc $ProviderVDC
|
||||||
|
$providerVdcRef = New-Object VMware.VimAutomation.Cloud.Views.Reference
|
||||||
|
$providerVdcRef.Href = $OrgVdcproviderVdc.Href
|
||||||
|
$adminVdc.ProviderVdcReference = $providerVdcRef
|
||||||
|
$adminVdc.AllocationModel = "AllocationPool"
|
||||||
|
$adminVdc.ComputeCapacity = New-Object VMware.VimAutomation.Cloud.Views.ComputeCapacity
|
||||||
|
$adminVdc.ComputeCapacity.Cpu = New-Object VMware.VimAutomation.Cloud.Views.CapacityWithUsage
|
||||||
|
$adminVdc.ComputeCapacity.Cpu.Units = "MHz"
|
||||||
|
$adminVdc.ComputeCapacity.Cpu.Limit = $CPULimit
|
||||||
|
$adminVdc.ComputeCapacity.Cpu.Allocated = $CPULimit
|
||||||
|
$adminVdc.ComputeCapacity.Memory = New-Object VMware.VimAutomation.Cloud.Views.CapacityWithUsage
|
||||||
|
$adminVdc.ComputeCapacity.Memory.Units = "MB"
|
||||||
|
$adminVdc.ComputeCapacity.Memory.Limit = $MEMLimit
|
||||||
|
$adminVdc.ComputeCapacity.Memory.Allocated = $MEMLimit
|
||||||
|
$adminVdc.StorageCapacity = New-Object VMware.VimAutomation.Cloud.Views.CapacityWithUsage
|
||||||
|
$adminVdc.StorageCapacity.Units = "MB"
|
||||||
|
$adminVdc.StorageCapacity.Limit = $StorageLimit
|
||||||
|
$adminVdc.NetworkQuota = 10
|
||||||
|
$adminVdc.VmQuota = 0
|
||||||
|
$adminVdc.VCpuInMhz = 1000
|
||||||
|
$adminVdc.VCpuInMhz2 = 1000
|
||||||
|
$adminVdc.UsesFastProvisioning = $false
|
||||||
|
$adminVdc.IsThinProvision = $true
|
||||||
|
|
||||||
|
## Create Org vDC
|
||||||
|
Write-Verbose "Create Org vDC"
|
||||||
|
$OrgED = (Get-Org $Org).ExtensionData
|
||||||
|
$orgVdc = $orgED.CreateVdc($adminVdc)
|
||||||
|
|
||||||
|
## Wait for getting Ready
|
||||||
|
Write-Verbose "Wait for getting Ready"
|
||||||
|
$i = 0
|
||||||
|
while(($orgVdc = Get-OrgVdc -Name $Name).Status -eq "NotReady"){
|
||||||
|
$i++
|
||||||
|
Start-Sleep 2
|
||||||
|
if($i -gt $Timeout) { Write-Error "Creating Org Failed."; break}
|
||||||
|
Write-Progress -Activity "Creating Org" -Status "Wait for Org to become Ready..."
|
||||||
|
}
|
||||||
|
Write-Progress -Activity "Creating Org" -Completed
|
||||||
|
Start-Sleep 2
|
||||||
|
|
||||||
|
## Search given Storage Profile
|
||||||
|
Write-Verbose "Search given Storage Profile"
|
||||||
|
$ProVdcStorageProfile = search-cloud -QueryType ProviderVdcStorageProfile -Name $StorageProfile | Get-CIView
|
||||||
|
|
||||||
|
## Create Storage Profile Object with Settings
|
||||||
|
Write-Verbose "Create Storage Profile Object with Settings"
|
||||||
|
$spParams = new-object VMware.VimAutomation.Cloud.Views.VdcStorageProfileParams
|
||||||
|
$spParams.Limit = $StorageLimit
|
||||||
|
$spParams.Units = "MB"
|
||||||
|
$spParams.ProviderVdcStorageProfile = $ProVdcStorageProfile.href
|
||||||
|
$spParams.Enabled = $true
|
||||||
|
$spParams.Default = $true
|
||||||
|
$UpdateParams = new-object VMware.VimAutomation.Cloud.Views.UpdateVdcStorageProfiles
|
||||||
|
$UpdateParams.AddStorageProfile = $spParams
|
||||||
|
|
||||||
|
## Update Org vDC
|
||||||
|
$orgVdc = Get-OrgVdc -Name $name
|
||||||
|
$orgVdc.ExtensionData.CreateVdcStorageProfile($UpdateParams)
|
||||||
|
|
||||||
|
## Wait for getting Ready
|
||||||
|
Write-Verbose "Wait for getting Ready"
|
||||||
|
while(($orgVdc = Get-OrgVdc -Name $name).Status -eq "NotReady"){
|
||||||
|
$i++
|
||||||
|
Start-Sleep 1
|
||||||
|
if($i -gt $Timeout) { Write-Error "Update Org Failed."; break}
|
||||||
|
Write-Progress -Activity "Updating Org" -Status "Wait for Org to become Ready..."
|
||||||
|
}
|
||||||
|
Write-Progress -Activity "Updating Org" -Completed
|
||||||
|
Start-Sleep 1
|
||||||
|
|
||||||
|
## Search Any-StorageProfile
|
||||||
|
Write-Verbose "Search Any-StorageProfile"
|
||||||
|
$orgvDCAnyProfile = search-cloud -querytype AdminOrgVdcStorageProfile | Where-Object {($_.Name -match '\*') -and ($_.VdcName -eq $orgVdc.Name)} | Get-CIView
|
||||||
|
|
||||||
|
## Disable Any-StorageProfile
|
||||||
|
Write-Verbose "Disable Any-StorageProfile"
|
||||||
|
$orgvDCAnyProfile.Enabled = $False
|
||||||
|
$return = $orgvDCAnyProfile.UpdateServerData()
|
||||||
|
|
||||||
|
## Remove Any-StorageProfile
|
||||||
|
Write-Verbose "Remove Any-StorageProfile"
|
||||||
|
$ProfileUpdateParams = new-object VMware.VimAutomation.Cloud.Views.UpdateVdcStorageProfiles
|
||||||
|
$ProfileUpdateParams.RemoveStorageProfile = $orgvDCAnyProfile.href
|
||||||
|
$remove = $orgvdc.extensiondata.CreatevDCStorageProfile($ProfileUpdateParams)
|
||||||
|
|
||||||
|
## Wait for getting Ready
|
||||||
|
Write-Verbose "Wait for getting Ready"
|
||||||
|
while(($orgVdc = Get-OrgVdc -Name $name).Status -eq "NotReady"){
|
||||||
|
$i++
|
||||||
|
Start-Sleep 1
|
||||||
|
if($i -gt $Timeout) { Write-Error "Update Org Failed."; break}
|
||||||
|
Write-Progress -Activity "Updating Org" -Status "Wait for Org to become Ready..."
|
||||||
|
}
|
||||||
|
Write-Progress -Activity "Updating Org" -Completed
|
||||||
|
Start-Sleep 1
|
||||||
|
|
||||||
|
## Set NetworkPool for correct location
|
||||||
|
Write-Verbose "Set NetworkPool for correct location"
|
||||||
|
$orgVdc = Get-OrgVdc -Name $name
|
||||||
|
$ProVdcNetworkPool = Get-NetworkPool -ProviderVdc $ProviderVDC -Name $NetworkPool
|
||||||
|
$set = Set-OrgVdc -OrgVdc $orgVdc -NetworkPool $ProVdcNetworkPool -NetworkMaxCount "10"
|
||||||
|
|
||||||
|
## Create private Catalog
|
||||||
|
Write-Verbose "Create private Catalog Object"
|
||||||
|
$OrgCatalog = New-Object VMware.VimAutomation.Cloud.Views.AdminCatalog
|
||||||
|
$OrgCatalog.name = "$Org Private Catalog"
|
||||||
|
if (!(Get-Org $org | Get-Catalog -Name $OrgCatalog.name -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Verbose "Create private Catalog"
|
||||||
|
$CreateCatalog = (Get-Org $org | Get-CIView).CreateCatalog($OrgCatalog)
|
||||||
|
$AccessControlRule = New-CIAccessControlRule -Entity $CreateCatalog.name -EveryoneInOrg -AccessLevel ReadWrite -Confirm:$False
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Output "Catalog '$($OrgCatalog.name)' aleady exists!"
|
||||||
|
}
|
||||||
|
|
||||||
|
## Create a direct connect network
|
||||||
|
if ($ExternalNetwork) {
|
||||||
|
Write-Verbose "Create a direct connect network"
|
||||||
|
Write-Output "Org VDC '$Name' needs to be enabled to add an external Network!"
|
||||||
|
$EnableOrgVdc = Set-OrgVdc -OrgVdc $Name -Enabled:$True
|
||||||
|
$orgVdcView = Get-OrgVdc $Name | Get-CIView
|
||||||
|
$extNetwork = $_.externalnetwork
|
||||||
|
$extNetwork = Get-ExternalNetwork | Get-CIView | Where-Object {$_.name -eq $ExternalNetwork}
|
||||||
|
$orgNetwork = new-object vmware.vimautomation.cloud.views.orgvdcnetwork
|
||||||
|
$orgNetwork.name = $ExternalNetwork
|
||||||
|
$orgNetwork.Configuration = New-Object VMware.VimAutomation.Cloud.Views.NetworkConfiguration
|
||||||
|
$orgNetwork.Configuration.FenceMode = 'bridged'
|
||||||
|
$orgNetwork.configuration.ParentNetwork = New-Object vmware.vimautomation.cloud.views.reference
|
||||||
|
$orgNetwork.configuration.ParentNetwork.href = $extNetwork.href
|
||||||
|
|
||||||
|
$result = $orgVdcView.CreateNetwork($orgNetwork)
|
||||||
|
}
|
||||||
|
|
||||||
|
Get-OrgVdc -Name $name | Format-Table -AutoSize
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png
Normal file
BIN
Modules/VMware-vCD-Module/media/Invoke-MyOnBoarding.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
BIN
Modules/VMware-vCD-Module/media/VSCode-Pester-Tests.png
Normal file
BIN
Modules/VMware-vCD-Module/media/VSCode-Pester-Tests.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 79 KiB |
35
Modules/VMware-vCD-Module/tests/VMware-vCD-Module.Tests.ps1
Normal file
35
Modules/VMware-vCD-Module/tests/VMware-vCD-Module.Tests.ps1
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
$moduleRoot = Resolve-Path "$PSScriptRoot\.."
|
||||||
|
$moduleName = "VMware-vCD-Module"
|
||||||
|
$ConfigFile = "$moduleRoot\examples\OnBoarding.json"
|
||||||
|
|
||||||
|
Describe "General project validation: $moduleName" {
|
||||||
|
|
||||||
|
$scripts = Get-ChildItem $moduleRoot -Include *.ps1, *.psm1, *.psd1 -Recurse
|
||||||
|
|
||||||
|
# TestCases are splatted to the script so we need hashtables
|
||||||
|
$testCase = $scripts | Foreach-Object {@{file = $_}}
|
||||||
|
It "Script <file> should be valid powershell" -TestCases $testCase {
|
||||||
|
param($file)
|
||||||
|
|
||||||
|
$file.fullname | Should Exist
|
||||||
|
|
||||||
|
$contents = Get-Content -Path $file.fullname -ErrorAction Stop
|
||||||
|
$errors = $null
|
||||||
|
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||||
|
$errors.Count | Should Be 0
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Module '$moduleName' prerequirements are met" {
|
||||||
|
{Import-Module VMware.VimAutomation.Cloud -Force} | Should Not Throw
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Module '$moduleName' can import cleanly" {
|
||||||
|
{Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -force } | Should Not Throw
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Module '$moduleName' JSON example is valid" {
|
||||||
|
{Get-Content -Raw -Path $ConfigFile | ConvertFrom-Json} | Should Not Throw
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
{
|
||||||
|
"Type": "AUTOMATED",
|
||||||
|
"Data": {
|
||||||
|
"Name": "ICFarmJson",
|
||||||
|
"DisplayName": "FarmJsonTest",
|
||||||
|
"AccessGroup": "Root",
|
||||||
|
"Description": "created IC Farm from PS via JSON",
|
||||||
|
"Enabled": null,
|
||||||
|
"Deleting": false,
|
||||||
|
"Settings": {
|
||||||
|
"DisconnectedSessionTimeoutPolicy" : "NEVER",
|
||||||
|
"DisconnectedSessionTimeoutMinutes" : 1,
|
||||||
|
"EmptySessionTimeoutPolicy" : "AFTER",
|
||||||
|
"EmptySessionTimeoutMinutes" : 1,
|
||||||
|
"LogoffAfterTimeout" : false
|
||||||
|
},
|
||||||
|
"Desktop": null,
|
||||||
|
"DisplayProtocolSettings": {
|
||||||
|
"DefaultDisplayProtocol" : "PCOIP",
|
||||||
|
"AllowDisplayProtocolOverride" : false,
|
||||||
|
"EnableHTMLAccess" : false
|
||||||
|
},
|
||||||
|
"ServerErrorThreshold": null,
|
||||||
|
"MirageConfigurationOverrides": {
|
||||||
|
"OverrideGlobalSetting" : false,
|
||||||
|
"Enabled" : false,
|
||||||
|
"Url" : null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AutomatedFarmSpec": {
|
||||||
|
"ProvisioningType": "INSTANT_CLONE_ENGINE",
|
||||||
|
"VirtualCenter": null,
|
||||||
|
"RdsServerNamingSpec": {
|
||||||
|
"NamingMethod": "PATTERN",
|
||||||
|
"PatternNamingSettings": {
|
||||||
|
"NamingPattern": "ICFarmVMPS",
|
||||||
|
"MaxNumberOfRDSServers": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VirtualCenterProvisioningSettings": {
|
||||||
|
"EnableProvisioning": true,
|
||||||
|
"StopProvisioningOnError": true,
|
||||||
|
"MinReadyVMsOnVComposerMaintenance": 0,
|
||||||
|
"VirtualCenterProvisioningData": {
|
||||||
|
"ParentVm": "vm-rdsh-ic",
|
||||||
|
"Snapshot": "snap_5",
|
||||||
|
"Datacenter": null,
|
||||||
|
"VmFolder": "Instant_Clone_VMs",
|
||||||
|
"HostOrCluster": "vimal-cluster",
|
||||||
|
"ResourcePool": "vimal-cluster"
|
||||||
|
},
|
||||||
|
"VirtualCenterStorageSettings": {
|
||||||
|
"Datastores": [
|
||||||
|
{
|
||||||
|
"Datastore": "Datastore1",
|
||||||
|
"StorageOvercommit": "UNBOUNDED"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UseVSan": false,
|
||||||
|
"ViewComposerStorageSettings": {
|
||||||
|
"UseSeparateDatastoresReplicaAndOSDisks": false,
|
||||||
|
"ReplicaDiskDatastore": null,
|
||||||
|
"UseNativeSnapshots": false,
|
||||||
|
"SpaceReclamationSettings": {
|
||||||
|
"ReclaimVmDiskSpace": false,
|
||||||
|
"ReclamationThresholdGB": null,
|
||||||
|
"BlackoutTimes": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VirtualCenterNetworkingSettings": {
|
||||||
|
"Nics": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"VirtualCenterManagedCommonSettings": {
|
||||||
|
"TransparentPageSharingScope": "VM"
|
||||||
|
},
|
||||||
|
"CustomizationSettings": {
|
||||||
|
"CustomizationType": "CLONE_PREP",
|
||||||
|
"DomainAdministrator": null,
|
||||||
|
"AdContainer": "CN=Computers",
|
||||||
|
"ReusePreExistingAccounts": false,
|
||||||
|
"ClonePrepCustomizationSettings": {
|
||||||
|
"InstantCloneEngineDomainAdministrator": null,
|
||||||
|
"PowerOffScriptName": null,
|
||||||
|
"PowerOffScriptParameters": null,
|
||||||
|
"PostSynchronizationScriptName": null,
|
||||||
|
"PostSynchronizationScriptParameters": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"RdsServerMaxSessionsData": {
|
||||||
|
"MaxSessionsType": "UNLIMITED",
|
||||||
|
"MaxSessions": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ManualFarmSpec": null,
|
||||||
|
"NetBiosName" : "ad-vimalg"
|
||||||
|
}
|
||||||
@@ -1,17 +1,31 @@
|
|||||||
{
|
{
|
||||||
"Type": "AUTOMATED",
|
"Type": "AUTOMATED",
|
||||||
"Data": {
|
"Data": {
|
||||||
"Name": "LCFarmTest",
|
"Name": "LCFarmJson",
|
||||||
"DisplayName": "Ankit LC Farm Test",
|
"DisplayName": "FarmJsonTest",
|
||||||
"AccessGroup": "Root",
|
"AccessGroup": "Root",
|
||||||
"Description": "created LC Farm from PS",
|
"Description": "created LC Farm from PS via JSON",
|
||||||
"Enabled": null,
|
"Enabled": null,
|
||||||
"Deleting": false,
|
"Deleting": false,
|
||||||
"Settings": null,
|
"Settings": {
|
||||||
|
"DisconnectedSessionTimeoutPolicy" : "NEVER",
|
||||||
|
"DisconnectedSessionTimeoutMinutes" : 1,
|
||||||
|
"EmptySessionTimeoutPolicy" : "AFTER",
|
||||||
|
"EmptySessionTimeoutMinutes" : 1,
|
||||||
|
"LogoffAfterTimeout" : false
|
||||||
|
},
|
||||||
"Desktop": null,
|
"Desktop": null,
|
||||||
"DisplayProtocolSettings": null,
|
"DisplayProtocolSettings": {
|
||||||
|
"DefaultDisplayProtocol" : "PCOIP",
|
||||||
|
"AllowDisplayProtocolOverride" : false,
|
||||||
|
"EnableHTMLAccess" : false
|
||||||
|
},
|
||||||
"ServerErrorThreshold": null,
|
"ServerErrorThreshold": null,
|
||||||
"MirageConfigurationOverrides": null
|
"MirageConfigurationOverrides": {
|
||||||
|
"OverrideGlobalSetting" : false,
|
||||||
|
"Enabled" : false,
|
||||||
|
"Url" : null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"AutomatedFarmSpec": {
|
"AutomatedFarmSpec": {
|
||||||
"ProvisioningType": "VIEW_COMPOSER",
|
"ProvisioningType": "VIEW_COMPOSER",
|
||||||
@@ -19,7 +33,7 @@
|
|||||||
"RdsServerNamingSpec": {
|
"RdsServerNamingSpec": {
|
||||||
"NamingMethod": "PATTERN",
|
"NamingMethod": "PATTERN",
|
||||||
"PatternNamingSettings": {
|
"PatternNamingSettings": {
|
||||||
"NamingPattern": "LCFarmVM_PS",
|
"NamingPattern": "LCFarmVMPS",
|
||||||
"MaxNumberOfRDSServers": 1
|
"MaxNumberOfRDSServers": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -28,17 +42,17 @@
|
|||||||
"StopProvisioningOnError": true,
|
"StopProvisioningOnError": true,
|
||||||
"MinReadyVMsOnVComposerMaintenance": 0,
|
"MinReadyVMsOnVComposerMaintenance": 0,
|
||||||
"VirtualCenterProvisioningData": {
|
"VirtualCenterProvisioningData": {
|
||||||
"ParentVm": "Win_Server_2012_R2",
|
"ParentVm": "RDSServer",
|
||||||
"Snapshot": "Snap_RDS",
|
"Snapshot": "RDS_SNAP1",
|
||||||
"Datacenter": null,
|
"Datacenter": null,
|
||||||
"VmFolder": "AnkitPoolVM",
|
"VmFolder": "Praveen",
|
||||||
"HostOrCluster": "cls",
|
"HostOrCluster": "CS-1",
|
||||||
"ResourcePool": "cls"
|
"ResourcePool": "CS-1"
|
||||||
},
|
},
|
||||||
"VirtualCenterStorageSettings": {
|
"VirtualCenterStorageSettings": {
|
||||||
"Datastores": [
|
"Datastores": [
|
||||||
{
|
{
|
||||||
"Datastore": "datastore1 (5)",
|
"Datastore": "Datastore1",
|
||||||
"StorageOvercommit": "UNBOUNDED"
|
"StorageOvercommit": "UNBOUNDED"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -67,7 +81,7 @@
|
|||||||
"AdContainer": "CN=Computers",
|
"AdContainer": "CN=Computers",
|
||||||
"ReusePreExistingAccounts": false,
|
"ReusePreExistingAccounts": false,
|
||||||
"SysprepCustomizationSettings": {
|
"SysprepCustomizationSettings": {
|
||||||
"CustomizationSpec": "RDSH_Cust2"
|
"CustomizationSpec": "PraveenCust"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"RdsServerMaxSessionsData": {
|
"RdsServerMaxSessionsData": {
|
||||||
@@ -76,5 +90,5 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ManualFarmSpec": null,
|
"ManualFarmSpec": null,
|
||||||
"NetBiosName" : "adankit"
|
"NetBiosName" : "adviewdev"
|
||||||
}
|
}
|
||||||
@@ -7,17 +7,31 @@
|
|||||||
"Description": "Manual PS Test",
|
"Description": "Manual PS Test",
|
||||||
"Enabled": null,
|
"Enabled": null,
|
||||||
"Deleting": false,
|
"Deleting": false,
|
||||||
"Settings": null,
|
"Settings": {
|
||||||
|
"DisconnectedSessionTimeoutPolicy" : "NEVER",
|
||||||
|
"DisconnectedSessionTimeoutMinutes" : 1,
|
||||||
|
"EmptySessionTimeoutPolicy" : "AFTER",
|
||||||
|
"EmptySessionTimeoutMinutes" : 1,
|
||||||
|
"LogoffAfterTimeout" : false
|
||||||
|
},
|
||||||
"Desktop": null,
|
"Desktop": null,
|
||||||
"DisplayProtocolSettings": null,
|
"DisplayProtocolSettings": {
|
||||||
|
"DefaultDisplayProtocol" : "PCOIP",
|
||||||
|
"AllowDisplayProtocolOverride" : false,
|
||||||
|
"EnableHTMLAccess" : false
|
||||||
|
},
|
||||||
"ServerErrorThreshold": null,
|
"ServerErrorThreshold": null,
|
||||||
"MirageConfigurationOverrides": null
|
"MirageConfigurationOverrides": {
|
||||||
|
"OverrideGlobalSetting" : false,
|
||||||
|
"Enabled" : false,
|
||||||
|
"Url" : null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"AutomatedFarmSpec": null,
|
"AutomatedFarmSpec": null,
|
||||||
"ManualFarmSpec": {
|
"ManualFarmSpec": {
|
||||||
"RdsServers": [
|
"RdsServers": [
|
||||||
{
|
{
|
||||||
"rdsServer": "WIN-ORKA1Q8B0P7"
|
"rdsServer": "RDSServer.adviewdev.eng.vmware.com"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,44 @@
|
|||||||
"AccessGroup": "Root",
|
"AccessGroup": "Root",
|
||||||
"Description": "create full clone via JSON"
|
"Description": "create full clone via JSON"
|
||||||
},
|
},
|
||||||
"DesktopSettings": null,
|
"DesktopSettings": {
|
||||||
|
"enabled": true,
|
||||||
|
"deleting": false,
|
||||||
|
"connectionServerRestrictions": null,
|
||||||
|
"logoffSettings": {
|
||||||
|
"powerPolicy": "TAKE_NO_POWER_ACTION",
|
||||||
|
"automaticLogoffPolicy": "NEVER",
|
||||||
|
"automaticLogoffMinutes": 120,
|
||||||
|
"allowUsersToResetMachines": false,
|
||||||
|
"allowMultipleSessionsPerUser": false,
|
||||||
|
"deleteOrRefreshMachineAfterLogoff": "NEVER",
|
||||||
|
"refreshOsDiskAfterLogoff": "NEVER",
|
||||||
|
"refreshPeriodDaysForReplicaOsDisk": 5,
|
||||||
|
"refreshThresholdPercentageForReplicaOsDisk": 10
|
||||||
|
},
|
||||||
|
"displayProtocolSettings": {
|
||||||
|
"supportedDisplayProtocols": ["PCOIP", "BLAST" ],
|
||||||
|
"defaultDisplayProtocol": "BLAST",
|
||||||
|
"allowUsersToChooseProtocol": true,
|
||||||
|
"pcoipDisplaySettings": {
|
||||||
|
"renderer3D": "DISABLED",
|
||||||
|
"enableGRIDvGPUs": false,
|
||||||
|
"vRamSizeMB": 96,
|
||||||
|
"maxNumberOfMonitors": 3,
|
||||||
|
"maxResolutionOfAnyOneMonitor": "WSXGA_PLUS"
|
||||||
|
},
|
||||||
|
"enableHTMLAccess": true
|
||||||
|
},
|
||||||
|
"flashSettings": {
|
||||||
|
"quality": "NO_CONTROL",
|
||||||
|
"throttling": "DISABLED"
|
||||||
|
},
|
||||||
|
"mirageConfigurationOverrides": {
|
||||||
|
"overrideGlobalSetting": false,
|
||||||
|
"enabled": false,
|
||||||
|
"url": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"Type": "AUTOMATED",
|
"Type": "AUTOMATED",
|
||||||
"AutomatedDesktopSpec": {
|
"AutomatedDesktopSpec": {
|
||||||
"ProvisioningType": "VIRTUAL_CENTER",
|
"ProvisioningType": "VIRTUAL_CENTER",
|
||||||
@@ -69,7 +106,7 @@
|
|||||||
"NoCustomizationSettings": {
|
"NoCustomizationSettings": {
|
||||||
"DoNotPowerOnVMsAfterCreation": false
|
"DoNotPowerOnVMsAfterCreation": false
|
||||||
},
|
},
|
||||||
"SysprepCustomizationSettings": null,
|
"SysprepCustomizationSettings": {"customizationSpec" : "praveencust"},
|
||||||
"QuickprepCustomizationSettings": null,
|
"QuickprepCustomizationSettings": null,
|
||||||
"CloneprepCustomizationSettings": null
|
"CloneprepCustomizationSettings": null
|
||||||
}
|
}
|
||||||
@@ -77,6 +114,5 @@
|
|||||||
"ManualDesktopSpec": null,
|
"ManualDesktopSpec": null,
|
||||||
"RdsDesktopSpec": null,
|
"RdsDesktopSpec": null,
|
||||||
"GlobalEntitlementData": null,
|
"GlobalEntitlementData": null,
|
||||||
"NetBiosName" : "adviewdev",
|
"NetBiosName" : "adviewdev"
|
||||||
"SysPrepName" : "praveencust"
|
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,44 @@
|
|||||||
"AccessGroup": "ROOT",
|
"AccessGroup": "ROOT",
|
||||||
"Description": "create instant pool"
|
"Description": "create instant pool"
|
||||||
},
|
},
|
||||||
"DesktopSettings": null,
|
"DesktopSettings": {
|
||||||
|
"enabled": true,
|
||||||
|
"deleting": false,
|
||||||
|
"connectionServerRestrictions": null,
|
||||||
|
"logoffSettings": {
|
||||||
|
"powerPolicy": "ALWAYS_POWERED_ON",
|
||||||
|
"automaticLogoffPolicy": "NEVER",
|
||||||
|
"automaticLogoffMinutes": 120,
|
||||||
|
"allowUsersToResetMachines": false,
|
||||||
|
"allowMultipleSessionsPerUser": false,
|
||||||
|
"deleteOrRefreshMachineAfterLogoff": "DELETE",
|
||||||
|
"refreshOsDiskAfterLogoff": "NEVER",
|
||||||
|
"refreshPeriodDaysForReplicaOsDisk": 5,
|
||||||
|
"refreshThresholdPercentageForReplicaOsDisk": 10
|
||||||
|
},
|
||||||
|
"displayProtocolSettings": {
|
||||||
|
"supportedDisplayProtocols": ["PCOIP", "BLAST" ],
|
||||||
|
"defaultDisplayProtocol": "BLAST",
|
||||||
|
"allowUsersToChooseProtocol": true,
|
||||||
|
"pcoipDisplaySettings": {
|
||||||
|
"renderer3D": "DISABLED",
|
||||||
|
"enableGRIDvGPUs": false,
|
||||||
|
"vRamSizeMB": 96,
|
||||||
|
"maxNumberOfMonitors": 3,
|
||||||
|
"maxResolutionOfAnyOneMonitor": "WSXGA_PLUS"
|
||||||
|
},
|
||||||
|
"enableHTMLAccess": true
|
||||||
|
},
|
||||||
|
"flashSettings": {
|
||||||
|
"quality": "NO_CONTROL",
|
||||||
|
"throttling": "DISABLED"
|
||||||
|
},
|
||||||
|
"mirageConfigurationOverrides": {
|
||||||
|
"overrideGlobalSetting": false,
|
||||||
|
"enabled": false,
|
||||||
|
"url": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"Type": "AUTOMATED",
|
"Type": "AUTOMATED",
|
||||||
"AutomatedDesktopSpec": {
|
"AutomatedDesktopSpec": {
|
||||||
"ProvisioningType": "INSTANT_CLONE_ENGINE",
|
"ProvisioningType": "INSTANT_CLONE_ENGINE",
|
||||||
@@ -5,7 +5,44 @@
|
|||||||
"AccessGroup": "Root",
|
"AccessGroup": "Root",
|
||||||
"Description": "created linkedclone pool from ps"
|
"Description": "created linkedclone pool from ps"
|
||||||
},
|
},
|
||||||
"DesktopSettings": null,
|
"DesktopSettings": {
|
||||||
|
"enabled": true,
|
||||||
|
"deleting": false,
|
||||||
|
"connectionServerRestrictions": null,
|
||||||
|
"logoffSettings": {
|
||||||
|
"powerPolicy": "TAKE_NO_POWER_ACTION",
|
||||||
|
"automaticLogoffPolicy": "NEVER",
|
||||||
|
"automaticLogoffMinutes": 120,
|
||||||
|
"allowUsersToResetMachines": false,
|
||||||
|
"allowMultipleSessionsPerUser": false,
|
||||||
|
"deleteOrRefreshMachineAfterLogoff": "NEVER",
|
||||||
|
"refreshOsDiskAfterLogoff": "NEVER",
|
||||||
|
"refreshPeriodDaysForReplicaOsDisk": 5,
|
||||||
|
"refreshThresholdPercentageForReplicaOsDisk": 10
|
||||||
|
},
|
||||||
|
"displayProtocolSettings": {
|
||||||
|
"supportedDisplayProtocols": ["RDP","PCOIP", "BLAST" ],
|
||||||
|
"defaultDisplayProtocol": "PCOIP",
|
||||||
|
"allowUsersToChooseProtocol": true,
|
||||||
|
"pcoipDisplaySettings": {
|
||||||
|
"renderer3D": "DISABLED",
|
||||||
|
"enableGRIDvGPUs": false,
|
||||||
|
"vRamSizeMB": 96,
|
||||||
|
"maxNumberOfMonitors": 3,
|
||||||
|
"maxResolutionOfAnyOneMonitor": "WSXGA_PLUS"
|
||||||
|
},
|
||||||
|
"enableHTMLAccess": true
|
||||||
|
},
|
||||||
|
"flashSettings": {
|
||||||
|
"quality": "NO_CONTROL",
|
||||||
|
"throttling": "DISABLED"
|
||||||
|
},
|
||||||
|
"mirageConfigurationOverrides": {
|
||||||
|
"overrideGlobalSetting": false,
|
||||||
|
"enabled": false,
|
||||||
|
"url": null
|
||||||
|
}
|
||||||
|
},
|
||||||
"Type": "AUTOMATED",
|
"Type": "AUTOMATED",
|
||||||
"AutomatedDesktopSpec": {
|
"AutomatedDesktopSpec": {
|
||||||
"ProvisioningType": "VIEW_COMPOSER",
|
"ProvisioningType": "VIEW_COMPOSER",
|
||||||
@@ -33,7 +70,7 @@
|
|||||||
"Template": null,
|
"Template": null,
|
||||||
"ParentVm": "Agent_pra",
|
"ParentVm": "Agent_pra",
|
||||||
"Snapshot": "kb-hotfix",
|
"Snapshot": "kb-hotfix",
|
||||||
"Datacenter": null,
|
"Datacenter": "Dev-Dc",
|
||||||
"VmFolder": "Praveen",
|
"VmFolder": "Praveen",
|
||||||
"HostOrCluster": "CS-1",
|
"HostOrCluster": "CS-1",
|
||||||
"ResourcePool": "CS-1"
|
"ResourcePool": "CS-1"
|
||||||
@@ -52,7 +89,8 @@
|
|||||||
"UseNativeSnapshots": false,
|
"UseNativeSnapshots": false,
|
||||||
"SpaceReclamationSettings": {
|
"SpaceReclamationSettings": {
|
||||||
"ReclaimVmDiskSpace": false,
|
"ReclaimVmDiskSpace": false,
|
||||||
"ReclamationThresholdGB": null
|
"ReclamationThresholdGB": null,
|
||||||
|
"BlackoutTimes" : null
|
||||||
},
|
},
|
||||||
"PersistentDiskSettings": {
|
"PersistentDiskSettings": {
|
||||||
"RedirectWindowsProfile": false,
|
"RedirectWindowsProfile": false,
|
||||||
@@ -75,19 +113,31 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"VirtualCenterNetworkingSettings": {
|
"VirtualCenterNetworkingSettings": {
|
||||||
"Nics": null
|
"Nics": [
|
||||||
|
{
|
||||||
|
"Nic": "nicName",
|
||||||
|
"NetworkLabelAssignmentSpecs": [
|
||||||
|
{
|
||||||
|
"Enabled" : false,
|
||||||
|
"networkLabel" : null,
|
||||||
|
"maxLabelType" : null,
|
||||||
|
"maxLabel" : null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"VirtualCenterManagedCommonSettings": {
|
"VirtualCenterManagedCommonSettings": {
|
||||||
"TransparentPageSharingScope": "VM"
|
"TransparentPageSharingScope": "VM"
|
||||||
},
|
},
|
||||||
"CustomizationSettings": {
|
"CustomizationSettings": {
|
||||||
"CustomizationType": "QUICK_PREP",
|
"CustomizationType": "SYS_PREP",
|
||||||
"DomainAdministrator": null,
|
"DomainAdministrator": "administrator",
|
||||||
"AdContainer": "CN=Computers",
|
"AdContainer": "CN=Computers",
|
||||||
"ReusePreExistingAccounts": false,
|
"ReusePreExistingAccounts": false,
|
||||||
"NoCustomizationSettings": null,
|
"NoCustomizationSettings": null,
|
||||||
"SysprepCustomizationSettings": null,
|
"SysprepCustomizationSettings": {"customizationSpec" : "praveencust"},
|
||||||
"QuickprepCustomizationSettings": {
|
"QuickprepCustomizationSettings": {
|
||||||
"PowerOffScriptName": null,
|
"PowerOffScriptName": null,
|
||||||
"PowerOffScriptParameters": null,
|
"PowerOffScriptParameters": null,
|
||||||
@@ -100,6 +150,5 @@
|
|||||||
"ManualDesktopSpec": null,
|
"ManualDesktopSpec": null,
|
||||||
"RdsDesktopSpec": null,
|
"RdsDesktopSpec": null,
|
||||||
"GlobalEntitlementData": null,
|
"GlobalEntitlementData": null,
|
||||||
"NetBiosName" : "adviewdev",
|
"NetBiosName" : "adviewdev"
|
||||||
"SysPrepName" : "praveencust"
|
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,44 @@
|
|||||||
"AccessGroup": "ROOT",
|
"AccessGroup": "ROOT",
|
||||||
"Description": "Manual pool creation"
|
"Description": "Manual pool creation"
|
||||||
},
|
},
|
||||||
"DesktopSettings": null,
|
"DesktopSettings": {
|
||||||
|
"enabled": true,
|
||||||
|
"deleting": false,
|
||||||
|
"connectionServerRestrictions": null,
|
||||||
|
"logoffSettings": {
|
||||||
|
"powerPolicy": "TAKE_NO_POWER_ACTION",
|
||||||
|
"automaticLogoffPolicy": "NEVER",
|
||||||
|
"automaticLogoffMinutes": 120,
|
||||||
|
"allowUsersToResetMachines": false,
|
||||||
|
"allowMultipleSessionsPerUser": false,
|
||||||
|
"deleteOrRefreshMachineAfterLogoff": "NEVER",
|
||||||
|
"refreshOsDiskAfterLogoff": "NEVER",
|
||||||
|
"refreshPeriodDaysForReplicaOsDisk": 5,
|
||||||
|
"refreshThresholdPercentageForReplicaOsDisk": 10
|
||||||
|
},
|
||||||
|
"displayProtocolSettings": {
|
||||||
|
"supportedDisplayProtocols": ["PCOIP", "BLAST" ],
|
||||||
|
"defaultDisplayProtocol": "BLAST",
|
||||||
|
"allowUsersToChooseProtocol": true,
|
||||||
|
"pcoipDisplaySettings": {
|
||||||
|
"renderer3D": "DISABLED",
|
||||||
|
"enableGRIDvGPUs": false,
|
||||||
|
"vRamSizeMB": 96,
|
||||||
|
"maxNumberOfMonitors": 3,
|
||||||
|
"maxResolutionOfAnyOneMonitor": "WSXGA_PLUS"
|
||||||
|
},
|
||||||
|
"enableHTMLAccess": true
|
||||||
|
},
|
||||||
|
"flashSettings": {
|
||||||
|
"quality": "NO_CONTROL",
|
||||||
|
"throttling": "DISABLED"
|
||||||
|
},
|
||||||
|
"mirageConfigurationOverrides": {
|
||||||
|
"overrideGlobalSetting": false,
|
||||||
|
"enabled": false,
|
||||||
|
"url": false
|
||||||
|
}
|
||||||
|
},
|
||||||
"Type": "MANUAL",
|
"Type": "MANUAL",
|
||||||
"AutomatedDesktopSpec": null,
|
"AutomatedDesktopSpec": null,
|
||||||
"ManualDesktopSpec": {
|
"ManualDesktopSpec": {
|
||||||
@@ -16,7 +53,7 @@
|
|||||||
"Source": "VIRTUAL_CENTER",
|
"Source": "VIRTUAL_CENTER",
|
||||||
"Machines": [
|
"Machines": [
|
||||||
{
|
{
|
||||||
"Machine" : "PowerCLI-VM"
|
"Machine" : "Praveen_Agent"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"VirtualCenter": null,
|
"VirtualCenter": null,
|
||||||
@@ -32,4 +69,5 @@
|
|||||||
},
|
},
|
||||||
"RdsDesktopSpec": null,
|
"RdsDesktopSpec": null,
|
||||||
"GlobalEntitlementData": null
|
"GlobalEntitlementData": null
|
||||||
|
|
||||||
}
|
}
|
||||||
27
Modules/VMware.Hv.Helper/Json/Pool/RdsSpec.json
Normal file
27
Modules/VMware.Hv.Helper/Json/Pool/RdsSpec.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"Base": {
|
||||||
|
"Name" : "RdsJson",
|
||||||
|
"DisplayName": "TestRDSPS",
|
||||||
|
"AccessGroup": "Root",
|
||||||
|
"Description": "Testing PS"
|
||||||
|
},
|
||||||
|
"DesktopSettings": {
|
||||||
|
"enabled": true,
|
||||||
|
"deleting": false,
|
||||||
|
"connectionServerRestrictions": null,
|
||||||
|
"logoffSettings": null,
|
||||||
|
"displayProtocolSettings": null,
|
||||||
|
"flashSettings": {
|
||||||
|
"quality": "NO_CONTROL",
|
||||||
|
"throttling": "DISABLED"
|
||||||
|
},
|
||||||
|
"mirageConfigurationOverrides": null
|
||||||
|
},
|
||||||
|
"Type": "RDS",
|
||||||
|
"AutomatedDesktopSpec": null,
|
||||||
|
"ManualDesktopSpec": null,
|
||||||
|
"RdsDesktopSpec": {
|
||||||
|
"Farm": "test1"
|
||||||
|
},
|
||||||
|
"GlobalEntitlementData": null
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"Base": {
|
|
||||||
"Name" : "RdsJson",
|
|
||||||
"DisplayName": "TestRDSPS",
|
|
||||||
"AccessGroup": "Root",
|
|
||||||
"Description": "Testing PS"
|
|
||||||
},
|
|
||||||
"DesktopSettings": null,
|
|
||||||
"Type": "RDS",
|
|
||||||
"AutomatedDesktopSpec": null,
|
|
||||||
"ManualDesktopSpec": null,
|
|
||||||
"RdsDesktopSpec": {
|
|
||||||
"Farm": "Farm2"
|
|
||||||
},
|
|
||||||
"GlobalEntitlementData": null
|
|
||||||
}
|
|
||||||
20
Modules/VMware.Hv.Helper/README.md
Normal file
20
Modules/VMware.Hv.Helper/README.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Prerequisites/Steps to use this module:
|
||||||
|
|
||||||
|
1. This module only works for Horizon product E.g. Horizon 7.0.2 and later.
|
||||||
|
2. Install the latest version of Powershell, PowerCLI(6.5) or (later version via psgallery).
|
||||||
|
3. Import HorizonView module by running: Import-Module VMware.VimAutomation.HorizonView.
|
||||||
|
4. Import "VMware.Hv.Helper" module by running: Import-Module -Name "location of this module" or Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module.
|
||||||
|
5. Get-Command -Module "This module Name" to list all available functions or Get-Command -Module 'VMware.Hv.Helper'.
|
||||||
|
|
||||||
|
# Example script to connect view API service of Connection Server:
|
||||||
|
|
||||||
|
Import-Module VMware.VimAutomation.HorizonView
|
||||||
|
# Connection to view API service
|
||||||
|
$hvServer = Connect-HVServer -server <connection server IP/FQDN>
|
||||||
|
$hvServices = $hvserver.ExtensionData
|
||||||
|
$csList = $hvServices.ConnectionServer.ConnectionServer_List()
|
||||||
|
# Load this module
|
||||||
|
Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module
|
||||||
|
Get-Command -Module 'VMware.Hv.Helper'
|
||||||
|
# Use advanced functions of this module
|
||||||
|
New-HVPool -spec 'path to InstantClone.json file'
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"generalData.clientMaxSessionTimePolicy": "TIMEOUT_AFTER",
|
||||||
|
"generalData.clientMaxSessionTimeMinutes": 600,
|
||||||
|
"generalData.clientIdleSessionTimeoutPolicy": "NEVER",
|
||||||
|
"generalData.clientIdleSessionTimeoutMinutes": null,
|
||||||
|
"generalData.clientSessionTimeoutMinutes": 1200,
|
||||||
|
"generalData.desktopSSOTimeoutPolicy": "DISABLE_AFTER",
|
||||||
|
"generalData.desktopSSOTimeoutMinutes": 15,
|
||||||
|
"generalData.applicationSSOTimeoutPolicy": "ALWAYS_ENABLED",
|
||||||
|
"generalData.applicationSSOTimeoutMinutes": null,
|
||||||
|
"generalData.viewAPISessionTimeoutMinutes": 10,
|
||||||
|
"generalData.preLoginMessage": null,
|
||||||
|
"generalData.displayWarningBeforeForcedLogoff": true,
|
||||||
|
"generalData.forcedLogoffTimeoutMinutes": 5,
|
||||||
|
"generalData.forcedLogoffMessage": "Your desktop is scheduled for an important update and will shut down in 5 minutes. Please save any unsaved work now",
|
||||||
|
"generalData.enableServerInSingleUserMode": false,
|
||||||
|
"generalData.storeCALOnBroker": false,
|
||||||
|
"generalData.storeCALOnClient": false,
|
||||||
|
"securityData.reauthSecureTunnelAfterInterruption": true,
|
||||||
|
"securityData.messageSecurityMode": "ENHANCED",
|
||||||
|
"securityData.enableIPSecForSecurityServerPairing": true
|
||||||
|
}
|
||||||
@@ -27,6 +27,10 @@
|
|||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>16</Width>
|
<Width>16</Width>
|
||||||
<Label>User Assignment</Label>
|
<Label>User Assignment</Label>
|
||||||
|
</TableColumnHeader>
|
||||||
|
<TableColumnHeader>
|
||||||
|
<Width>8</Width>
|
||||||
|
<Label>Entitled</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>7</Width>
|
<Width>7</Width>
|
||||||
@@ -55,6 +59,19 @@
|
|||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.desktopSummaryData.userAssignment</ScriptBlock>
|
<ScriptBlock>$_.desktopSummaryData.userAssignment</ScriptBlock>
|
||||||
|
</TableColumnItem>
|
||||||
|
<TableColumnItem>
|
||||||
|
<ScriptBlock>
|
||||||
|
$filterContains = Get-HVQueryFilter localData.desktops -contains ([VMware.Hv.DesktopId[]]$_.id)
|
||||||
|
$GlobalfilterContains = Get-HVQueryFilter localData.desktops -contains ([VMware.Hv.DesktopId[]]$_.id)
|
||||||
|
Try {
|
||||||
|
$results += Get-HVQueryResult -EntityType EntitledUserOrGroupLocalSummaryView -Filter $filterContains
|
||||||
|
$results += Get-HVQueryResult -EntityType EntitledUserOrGroupGlobalSummaryView -Filter $GlobalfilterContains
|
||||||
|
} Catch {
|
||||||
|
#Do nothing
|
||||||
|
}
|
||||||
|
$results.length
|
||||||
|
</ScriptBlock>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.desktopSummaryData.enabled</ScriptBlock>
|
<ScriptBlock>$_.desktopSummaryData.enabled</ScriptBlock>
|
||||||
@@ -97,6 +114,20 @@
|
|||||||
<ScriptBlock>$_.desktopSummaryData.userAssignment</ScriptBlock>
|
<ScriptBlock>$_.desktopSummaryData.userAssignment</ScriptBlock>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
|
<Label>Entitled</Label>
|
||||||
|
<ScriptBlock>
|
||||||
|
$filterContains = Get-HVQueryFilter localData.desktops -contains ([VMware.Hv.DesktopId[]]$_.id)
|
||||||
|
$GlobalfilterContains = Get-HVQueryFilter localData.desktops -contains ([VMware.Hv.DesktopId[]]$_.id)
|
||||||
|
Try {
|
||||||
|
$results += Get-HVQueryResult -EntityType EntitledUserOrGroupLocalSummaryView -Filter $filterContains
|
||||||
|
$results += Get-HVQueryResult -EntityType EntitledUserOrGroupGlobalSummaryView -Filter $GlobalfilterContains
|
||||||
|
} Catch {
|
||||||
|
#Do nothing
|
||||||
|
}
|
||||||
|
$results.length
|
||||||
|
</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
<Label>Enabled</Label>
|
<Label>Enabled</Label>
|
||||||
<ScriptBlock>$_.desktopSummaryData.enabled</ScriptBlock>
|
<ScriptBlock>$_.desktopSummaryData.enabled</ScriptBlock>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# RootModule = ''
|
# RootModule = ''
|
||||||
|
|
||||||
# Version number of this module.
|
# Version number of this module.
|
||||||
ModuleVersion = '1.0'
|
ModuleVersion = '1.1'
|
||||||
|
|
||||||
# ID used to uniquely identify this module
|
# ID used to uniquely identify this module
|
||||||
GUID = '6d3f7fb5-4e52-43d8-91e1-f65f72532a1d'
|
GUID = '6d3f7fb5-4e52-43d8-91e1-f65f72532a1d'
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
97
Scripts/esxi-image-comparator.ps1
Normal file
97
Scripts/esxi-image-comparator.ps1
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<#
|
||||||
|
Script name: esxi-image-comparator.ps1
|
||||||
|
Last update: 24 May 2017
|
||||||
|
Author: Eric Gray, @eric_gray
|
||||||
|
Description: Compare contents (VIBs) of multiple VMware ESXi image profiles.
|
||||||
|
Dependencies: PowerCLI Image Builder (VMware.ImageBuilder,VMware.VimAutomation.Core)
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[switch]$ShowAllVIBs=$false,
|
||||||
|
[switch]$HideDates=$false,
|
||||||
|
[switch]$Interactive=$false,
|
||||||
|
[switch]$Grid=$false,
|
||||||
|
[string]$ProfileInclude,
|
||||||
|
[string]$ProfileExclude
|
||||||
|
)
|
||||||
|
|
||||||
|
$profileList = Get-EsxImageProfile | sort -Property Name
|
||||||
|
|
||||||
|
if ($ProfileInclude) {
|
||||||
|
$profileList = $profileList | ? Name -Match $ProfileInclude
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ProfileExclude) {
|
||||||
|
$profileList = $profileList | ? Name -NotMatch $ProfileExclude
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($profileList.Count -eq 0) {
|
||||||
|
Write-Host "No ESXi image profiles available in current session."
|
||||||
|
Write-Host "Use Add-EsxSoftwareDepot for each depot zip bundle you would like to compare."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Interactive) {
|
||||||
|
$keep = @()
|
||||||
|
Write-Host "Found the following profiles:" -ForegroundColor Yellow
|
||||||
|
$profileList | % { write-host $_.Name }
|
||||||
|
|
||||||
|
if ($profileList.Count -gt 7) {
|
||||||
|
Write-Host "Found $($profileList.Count) profiles!" -ForegroundColor Yellow
|
||||||
|
Write-Host "Note: List filtering is possible through -ProfileInclude / -ProfileExclude" -ForegroundColor DarkGreen
|
||||||
|
}
|
||||||
|
|
||||||
|
write-host "`nType 'y' next to each profile to compare..." -ForegroundColor Yellow
|
||||||
|
|
||||||
|
foreach ($profile in $profileList) {
|
||||||
|
$want = Read-Host -Prompt $profile.Name
|
||||||
|
if ($want.StartsWith("y") ) {
|
||||||
|
$keep += $profile
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$profileList = $keep
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# go thru each profile and build a hash of the vib name and hash of profile name + version
|
||||||
|
$diffResults = @{}
|
||||||
|
foreach ($profile in $profileList ) {
|
||||||
|
foreach ($vib in $profile.VibList) {
|
||||||
|
$vibValue = $vib.Version
|
||||||
|
if (! $HideDates) {
|
||||||
|
$vibValue += " "+ $vib.CreationDate.ToShortDateString()
|
||||||
|
}
|
||||||
|
$diffResults.($vib.name) += @{$profile.name = $vibValue}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# create an object that will neatly output as CSV or table
|
||||||
|
$outputTable=@()
|
||||||
|
foreach ($row in $diffResults.keys | sort) {
|
||||||
|
$vibRow = new-object PSObject
|
||||||
|
$vibRow | add-member -membertype NoteProperty -name "VIB" -Value $row
|
||||||
|
$valueCounter = @{}
|
||||||
|
|
||||||
|
foreach ($profileName in $profileList.name) {
|
||||||
|
#populate this hash to decide if all profiles have same version of VIB
|
||||||
|
$valueCounter.($diffResults.$row.$profileName) = 1
|
||||||
|
$vibRow | add-member -membertype NoteProperty -name $profileName -Value $diffResults.$row.$profileName
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($valueCounter.Count -gt 1 -or $ShowAllVIBs) {
|
||||||
|
$outputTable += $vibRow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# useful for debugging
|
||||||
|
#$diffResults | ConvertTo-Json
|
||||||
|
#$outputTable|Export-Csv -Path .\image-diff-results.csv -NoTypeInformation
|
||||||
|
|
||||||
|
if ($Grid) {
|
||||||
|
$outputTable | Out-GridView -Title "VMware ESXi Image Profile Comparator"
|
||||||
|
} else {
|
||||||
|
$outputTable
|
||||||
|
}
|
||||||
108
Scripts/esxi-image-creator.ps1
Normal file
108
Scripts/esxi-image-creator.ps1
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<#
|
||||||
|
Script name: esxi-image-creator.ps1
|
||||||
|
Last update: 24 May 2017
|
||||||
|
Author: Eric Gray, @eric_gray
|
||||||
|
Description: Create a VMware ESXi image profile based on
|
||||||
|
one or more depots and offline driver bundles.
|
||||||
|
Dependencies: PowerCLI Image Builder (VMware.ImageBuilder,VMware.VimAutomation.Core)
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[switch]$NewestDate = $false,
|
||||||
|
[switch]$WriteZip = $false,
|
||||||
|
[switch]$WriteISO = $false,
|
||||||
|
[switch]$LeaveCurrentDepotsMounted = $false,
|
||||||
|
[string]$NewProfileName = "Custom Image $(Get-Date -Format "yyyyMMddhhmm")",
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[ValidateSet('VMwareCertified','VMwareAccepted','PartnerSupported','CommunitySupported')]
|
||||||
|
[string]$Acceptance = "VMwareCertified",
|
||||||
|
[string[]]$Files = "*.zip"
|
||||||
|
)
|
||||||
|
|
||||||
|
#### Specify optional image fine-tuning here ####
|
||||||
|
# comma-separated list (array) of VIBs to exclude
|
||||||
|
$removeVibs = @("tools-light")
|
||||||
|
|
||||||
|
# force specific VIB version to be included, when more than one version is present
|
||||||
|
# e.g. "net-enic"="2.1.2.71-1OEM.550.0.0.1331820"
|
||||||
|
$overrideVibs = @{
|
||||||
|
# "net-enic"="2.1.2.71-1OEM.550.0.0.1331820",
|
||||||
|
}
|
||||||
|
|
||||||
|
#### end of optional fine-tuning ####
|
||||||
|
|
||||||
|
# may be desirable to manually mount an online depot in advance, such as for HPE
|
||||||
|
# e.g. Add-EsxSoftwareDepot http://vibsdepot.hpe.com/index-ecli-650.xml
|
||||||
|
if (! $LeaveCurrentDepotsMounted) {
|
||||||
|
Get-EsxSoftwareDepot | Remove-EsxSoftwareDepot
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($depot in Get-ChildItem $Files) {
|
||||||
|
if ($depot.Name.EndsWith(".zip") ) {
|
||||||
|
Add-EsxSoftwareDepot $depot.FullName
|
||||||
|
} else {
|
||||||
|
Write-Host "Not a zip depot:" $depot.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((Get-EsxImageProfile).count -eq 0) {
|
||||||
|
write-host "No image profiles found in the selected files"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# either use the native -Newest switch, or try to find latest VIBs by date (NewestDate)
|
||||||
|
if ($NewestDate) {
|
||||||
|
$pkgsAll = Get-EsxSoftwarePackage | sort -Property Name,CreationDate -Descending
|
||||||
|
$pkgsNewestDate=@()
|
||||||
|
|
||||||
|
foreach ($pkg in $pkgsAll) {
|
||||||
|
if ($pkgsNewestDate.GetEnumerator().name -notcontains $pkg.Name ) {
|
||||||
|
$pkgsNewestDate += $pkg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pkgs = $pkgsNewestDate
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$pkgs = Get-ESXSoftwarePackage -Newest
|
||||||
|
}
|
||||||
|
|
||||||
|
# rebuild the package array according to manual fine-tuning
|
||||||
|
if ($removeVibs) {
|
||||||
|
Write-Host "`nThe following VIBs will not be included in ${NewProfileName}:" -ForegroundColor Yellow
|
||||||
|
$removeVibs
|
||||||
|
$pkgs = $pkgs | ? name -NotIn $removeVibs
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($override in $overrideVibs.keys) {
|
||||||
|
# check that the override exists, then remove existing and add override
|
||||||
|
$tmpOver = Get-EsxSoftwarePackage -Name $override -Version $overrideVibs.$override
|
||||||
|
if ($tmpOver) {
|
||||||
|
$pkgs = $pkgs | ? name -NotIn $tmpOver.name
|
||||||
|
$pkgs += $tmpOver
|
||||||
|
} else {
|
||||||
|
Write-host "Did not find:" $override $overrideVibs.$override -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
New-EsxImageProfile -NewProfile $NewProfileName -SoftwarePackage $pkgs `
|
||||||
|
-Vendor Custom -AcceptanceLevel $Acceptance -Description "Made with esxi-image-creator.ps1" `
|
||||||
|
-ErrorAction Stop -ErrorVariable CreationError | Out-Null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "Custom image profile $NewProfileName not created." -ForegroundColor Yellow
|
||||||
|
$CreationError
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "`nFinished creating $NewProfileName" -ForegroundColor Yellow
|
||||||
|
|
||||||
|
if ($WriteZip) {
|
||||||
|
Write-Host "Creating zip bundle..." -ForegroundColor Green
|
||||||
|
Export-EsxImageProfile -ImageProfile $NewProfileName -ExportToBundle -FilePath .\${NewProfileName}.zip -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($WriteISO) {
|
||||||
|
Write-Host "Creating ISO image..." -ForegroundColor Green
|
||||||
|
Export-EsxImageProfile -ImageProfile $NewProfileName -ExportToIso -FilePath .\${NewProfileName}.iso -Force
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user