Merge branch 'master' of https://github.com/kmruddy/PowerCLI-Example-Scripts
This commit is contained in:
@@ -190,7 +190,7 @@ Function Get-ContentLibraryItemFiles {
|
||||
$itemIds = $contentLibraryItemService.list($libraryID)
|
||||
$DatastoreID = $library.storage_backings.datastore_id.Value
|
||||
$Datastore = get-datastore -id "Datastore-$DatastoreID"
|
||||
|
||||
|
||||
foreach($itemId in $itemIds) {
|
||||
$itemName = ($contentLibraryItemService.get($itemId)).name
|
||||
$contentLibraryItemFileSerice = Get-CisService com.vmware.content.library.item.file
|
||||
@@ -205,7 +205,7 @@ Function Get-ContentLibraryItemFiles {
|
||||
else{
|
||||
$fullfilepath = "UNKNOWN"
|
||||
}
|
||||
|
||||
|
||||
if(!$LibraryItemName) {
|
||||
$fileResult = [pscustomobject] @{
|
||||
Name = $file.name;
|
||||
@@ -709,4 +709,72 @@ Function New-VMFromVMTX {
|
||||
|
||||
Write-Host "`nDeploying new VM $NewVMName from VMTX Template $VMTXName ..."
|
||||
$results = $vmtxService.deploy($vmtxId,$vmtxDeploySpec)
|
||||
}
|
||||
}
|
||||
|
||||
Function New-SubscribedContentLibrary {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: William Lam
|
||||
Organization: VMware
|
||||
Blog: www.virtuallyghetto.com
|
||||
Twitter: @lamw
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
This function creates a new Subscriber Content Library from Subscription URL
|
||||
.PARAMETER LibraryName
|
||||
The name of the new vSphere Content Library
|
||||
.PARAMETER DatastoreName
|
||||
The name of the vSphere Datastore to store the Content Library
|
||||
.PARAMETER SubscriptionURL
|
||||
The URL of the published Content Library
|
||||
.PARAMETER SubscriptionThumbprint
|
||||
The SSL Thumbprint for the published Content Library
|
||||
.PARAMETER OnDemand
|
||||
Specifies whether content is downloaded on-demand (e.g. no immediately)
|
||||
.PARAMETER AutomaticSync
|
||||
Specifies whether automatic synchronization with the external content library is enabled
|
||||
.EXAMPLE
|
||||
New-SubscribedContentLibrary -LibraryName NestedESXi -DatastoreName vsanDatastore -SubscriptionURL https://download3.vmware.com/software/vmw-tools/lib.json -SubscriptionThumbprint "7a:c4:08:2d:d3:55:56:af:9f:26:43:65:d0:31:99:0b:d2:f3:d8:69" -AutomaticSync
|
||||
.EXAMPLE
|
||||
New-SubscribedContentLibrary -LibraryName NestedESXi -DatastoreName vsanDatastore -SubscriptionURL https://download3.vmware.com/software/vmw-tools/lib.json -SubscriptionThumbprint "7a:c4:08:2d:d3:55:56:af:9f:26:43:65:d0:31:99:0b:d2:f3:d8:69" -OnDemand
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][String]$LibraryName,
|
||||
[Parameter(Mandatory=$true)][String]$DatastoreName,
|
||||
[Parameter(Mandatory=$true)][String]$SubscriptionURL,
|
||||
[Parameter(Mandatory=$true)][String]$SubscriptionThumbprint,
|
||||
[Parameter(Mandatory=$false)][Switch]$OnDemand,
|
||||
[Parameter(Mandatory=$false)][Switch]$AutomaticSync
|
||||
)
|
||||
|
||||
$datastore = Get-Datastore -Name $DatastoreName
|
||||
|
||||
if($datastore) {
|
||||
$datastoreId = $datastore.ExtensionData.MoRef.Value
|
||||
$subscribeLibraryService = Get-CisService -Name "com.vmware.content.subscribed_library"
|
||||
|
||||
$StorageSpec = [pscustomobject] @{
|
||||
datastore_id = $datastoreId;
|
||||
type = "DATASTORE";
|
||||
}
|
||||
|
||||
$UniqueChangeId = [guid]::NewGuid().tostring()
|
||||
|
||||
$createSpec = $subscribeLibraryService.help.create.create_spec.create()
|
||||
$createSpec.name = $LibraryName
|
||||
$createSpec.type = "SUBSCRIBED"
|
||||
$addResults = $createSpec.storage_backings.Add($StorageSpec)
|
||||
|
||||
if($OnDemand) { $OnDemandFlag = $true } else { $OnDemandFlag = $false }
|
||||
if($AutomaticSync) { $AutomaticSyncFlag = $true } else { $AutomaticSyncFlag = $false }
|
||||
$createSpec.subscription_info.on_demand = $OnDemandFlag
|
||||
$createSpec.subscription_info.automatic_sync_enabled = $AutomaticSyncFlag
|
||||
$createSpec.subscription_info.subscription_url = $SubscriptionURL
|
||||
$createSpec.subscription_info.authentication_method = "NONE"
|
||||
$createSpec.subscription_info.ssl_thumbprint = $SubscriptionThumbprint
|
||||
|
||||
Write-Host "Creating new Subscribed Content Library called $LibraryName ..."
|
||||
$library = $subscribeLibraryService.create($UniqueChangeId, $createSpec)
|
||||
}
|
||||
}
|
||||
@@ -152,10 +152,12 @@ Function New-XVCMRequest {
|
||||
The name of the source vSphere Datacenter
|
||||
.PARAMETER DstDatacenter
|
||||
The name of the destination vSphere Datacenter
|
||||
.PARAMETER SrcCluster
|
||||
<Not needed for v2.0,removed from code>
|
||||
.PARAMETER DstCluster
|
||||
The name of the destination vSphere Cluster, set to null if DstHost is defined
|
||||
.PARAMETER DstPool
|
||||
The name of the destination vSphere Resource Pool
|
||||
.PARAMETER DstFolder
|
||||
The name of the destination vSphere Folder
|
||||
.PARAMETER DstDatastore
|
||||
The name of the destination Datastore
|
||||
.PARAMETER DstHost
|
||||
@@ -171,6 +173,15 @@ Function New-XVCMRequest {
|
||||
-DstDatastore vsanDatastore `
|
||||
-srcVMs @("PhotonOS-01","PhotonOS-02","PhotonOS-03","PhotonOS-04") `
|
||||
-NetworkMapping @{"DVPG-VM Network 1"="DVPG-Internal Network";"DVPG-VM Network 2"="DVPG-External Network"}
|
||||
.EXAMPLE
|
||||
New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF `
|
||||
-SrcDatacenter SDDC-Datacenter -srcVMs @(“DUDE-ubuntu”) `
|
||||
-DstDatacenter SDDC-Datacenter `
|
||||
-DstCluster "Cluster-1" -DstHost $null `
|
||||
-DstPool Compute-ResourcePool `
|
||||
-DstFolder Workloads `
|
||||
-DstDatastore WorkloadDatastore `
|
||||
-NetworkMapping @{"OREGON-VMs-sddc"="CALIF-sddc-VMs"}
|
||||
#>
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][String]$opType, #Added by CPM for 2.0
|
||||
@@ -178,8 +189,9 @@ Function New-XVCMRequest {
|
||||
[Parameter(Mandatory=$true)][String]$DstSite,
|
||||
[Parameter(Mandatory=$true)][String]$SrcDatacenter,
|
||||
[Parameter(Mandatory=$true)][String]$DstDatacenter,
|
||||
#[Parameter(Mandatory=$true)][String]$SrcCluster, #Removed by CPM for 2.0
|
||||
[Parameter(Mandatory=$true)][AllowNull()] $DstCluster, #Added [AllowNull()], removed [String] by CPM for 2.0
|
||||
[Parameter(Mandatory=$true)][String]$DstPool,
|
||||
[Parameter(Mandatory=$true)][String]$DstFolder,
|
||||
[Parameter(Mandatory=$true)][String]$DstDatastore,
|
||||
[Parameter(Mandatory=$true)][AllowNull()] $DstHost, #Added by CPM for 2.0
|
||||
[Parameter(Mandatory=$true)][String[]]$srcVMs,
|
||||
@@ -193,7 +205,8 @@ Function New-XVCMRequest {
|
||||
"targetSite"=$DstSite;
|
||||
"sourceDatacenter"=$SrcDatacenter;
|
||||
"targetDatacenter"=$dstDatacenter;
|
||||
#"sourceCluster"=$SrcCluster; #Removed by CPM for 2.0
|
||||
"targetPool"=$DstPool;
|
||||
"targetFolder"=$DstFolder;
|
||||
"targetCluster"=$DstCluster;
|
||||
"targetDatastore"=$DstDatastore;
|
||||
"targetHost"=$DstHost; #Added by CPM for 2.0
|
||||
|
||||
BIN
Modules/VMware.DRaaS/VMware.DRaaS.psd1
Executable file
BIN
Modules/VMware.DRaaS/VMware.DRaaS.psd1
Executable file
Binary file not shown.
256
Modules/VMware.DRaaS/VMware.DRaaS.psm1
Normal file
256
Modules/VMware.DRaaS/VMware.DRaaS.psm1
Normal file
@@ -0,0 +1,256 @@
|
||||
Function Connect-DRaas {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: William Lam
|
||||
Date: 05/23/2019
|
||||
Organization: VMware
|
||||
Blog: http://www.virtuallyghetto.com
|
||||
Twitter: @lamw
|
||||
===========================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
This cmdlet creates $global:draasConnection object containing the DRaaS URL along with CSP Token Header
|
||||
.DESCRIPTION
|
||||
This cmdlet creates $global:draasConnection object containing the DRaaS URL along with CSP Token Header
|
||||
.EXAMPLE
|
||||
Connect-DRaaS -RefreshToken $RefreshToken -OrgName $OrgName -SDDCName $SDDCName
|
||||
.NOTES
|
||||
You must be logged into VMC using Connect-VmcServer cmdlet
|
||||
#>
|
||||
Param (
|
||||
[Parameter(Mandatory=$true)][String]$RefreshToken,
|
||||
[Parameter(Mandatory=$true)][String]$OrgName,
|
||||
[Parameter(Mandatory=$true)][String]$SDDCName
|
||||
)
|
||||
|
||||
If (-Not $global:DefaultVMCServers.IsConnected) { Write-error "No valid VMC Connection found, please use the Connect-VMC to connect"; break } Else {
|
||||
$sddcService = Get-VmcService "com.vmware.vmc.orgs.sddcs"
|
||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
||||
$sddc = $sddcService.get($orgId,$sddcId)
|
||||
|
||||
}
|
||||
|
||||
$results = Invoke-WebRequest -Uri "https://console.cloud.vmware.com/csp/gateway/am/api/auth/api-tokens/authorize?refresh_token=$RefreshToken" -Method POST -ContentType "application/json" -UseBasicParsing -Headers @{"csp-auth-token"="$RefreshToken"}
|
||||
if($results.StatusCode -ne 200) {
|
||||
Write-Host -ForegroundColor Red "Failed to retrieve Access Token, please ensure your VMC Refresh Token is valid and try again"
|
||||
break
|
||||
}
|
||||
$accessToken = ($results | ConvertFrom-Json).access_token
|
||||
|
||||
$headers = @{
|
||||
"csp-auth-token"="$accessToken"
|
||||
"Content-Type"="application/json"
|
||||
"Accept"="application/json"
|
||||
}
|
||||
$global:draasConnection = new-object PSObject -Property @{
|
||||
'Server' = "https://vmc.vmware.com/vmc/draas/api/orgs/$orgId/sddcs/$sddcId/site-recovery"
|
||||
'headers' = $headers
|
||||
}
|
||||
$global:draasConnection
|
||||
}
|
||||
|
||||
Function Get-DRaas {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: William Lam
|
||||
Date: 05/23/2019
|
||||
Organization: VMware
|
||||
Blog: http://www.virtuallyghetto.com
|
||||
Twitter: @lamw
|
||||
===========================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
Returns information about DRaaS configuration for a given SDDC
|
||||
.DESCRIPTION
|
||||
This cmdlet returns information about DRaaS configuration for a given SDDC. Can be used to monitor both activate and deactivate operations.
|
||||
.EXAMPLE
|
||||
Get-DRaas
|
||||
#>
|
||||
Param (
|
||||
[Switch]$Troubleshoot
|
||||
)
|
||||
|
||||
If (-Not $global:draasConnection) { Write-error "No DRaaS Connection found, please use Connect-DRaaS" } Else {
|
||||
$method = "GET"
|
||||
$draasUrl = $global:draasConnection.Server
|
||||
$draasVersionUrl = $global:draasConnection.Server + "/versions"
|
||||
|
||||
if($Troubleshoot) {
|
||||
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasUrl`n"
|
||||
}
|
||||
|
||||
try {
|
||||
if($PSVersionTable.PSEdition -eq "Core") {
|
||||
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
|
||||
} else {
|
||||
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers
|
||||
}
|
||||
} catch {
|
||||
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
|
||||
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
|
||||
break
|
||||
} else {
|
||||
Write-Error "Error in retrieving DRaaS Information"
|
||||
Write-Error "`n($_.Exception.Message)`n"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if($requests.StatusCode -eq 200) {
|
||||
$json = ($requests.Content | ConvertFrom-Json)
|
||||
|
||||
$draasId = $json.id;
|
||||
$draasState = $json.site_recovery_state;
|
||||
$srmNode = $json.srm_node.ip_address;
|
||||
$srmNodeState = $json.site_recovery_state;
|
||||
$vrNode = $json.vr_node.ip_address;
|
||||
$vrNodeState = $json.vr_node.state;
|
||||
$draasUrl = $json.draas_h5_url;
|
||||
|
||||
if($srmNodeState -eq "ACTIVATED") {
|
||||
if($Troubleshoot) {
|
||||
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasVersionUrl`n"
|
||||
}
|
||||
|
||||
try {
|
||||
if($PSVersionTable.PSEdition -eq "Core") {
|
||||
$requests = Invoke-WebRequest -Uri $draasVersionUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
|
||||
} else {
|
||||
$requests = Invoke-WebRequest -Uri $draasVersionUrl -Method $method -Headers $global:draasConnection.headers
|
||||
}
|
||||
} catch {
|
||||
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
|
||||
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
|
||||
break
|
||||
} else {
|
||||
Write-Error "Error in retrieving DRaaS Information"
|
||||
Write-Error "`n($_.Exception.Message)`n"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if($requests.StatusCode -eq 200) {
|
||||
$json = ($requests.Content | ConvertFrom-Json).node_versions
|
||||
|
||||
$srmVersion,$srmDescription = ($json | where {$_.node_ip -eq $srmNode}).full_version.split("`n")
|
||||
$vrVersion,$vrDescription = ($json | where {$_.node_ip -eq $vrNode}).full_version.split("`n")
|
||||
|
||||
$results = [pscustomobject] @{
|
||||
ID = $draasId;
|
||||
DRaaSState = $draasState;
|
||||
SRMNode = $srmNode;
|
||||
SRMVersion = $srmVersion;
|
||||
SRMNodeState = $srmNodeState;
|
||||
VRNode = $vrNode;
|
||||
VRVersion = $vrVersion;
|
||||
VRNodeState = $vrNodeState;
|
||||
DRaaSURL = $draasUrl;
|
||||
}
|
||||
|
||||
$results
|
||||
}
|
||||
} elseif ($srmNodeState -eq "ACTIVATING" -or $srmNodeState -eq "DEACTIVATING") {
|
||||
$results = [pscustomobject] @{
|
||||
ID = $draasId;
|
||||
DRaaSState = $draasState;
|
||||
SRMNode = $srmNode;
|
||||
SRMNodeState = $srmNodeState;
|
||||
VRNode = $vrNode;
|
||||
VRNodeState = $vrNodeState;
|
||||
DRaaSURL = $draasUrl;
|
||||
}
|
||||
|
||||
$results
|
||||
} else {
|
||||
Write-Host "`nDRaaS is currently deactivated, please run Set-DRaas -Activate`n"
|
||||
}
|
||||
} else {
|
||||
Write-Host "`nDRaaS has not been activated before, please run Set-DRaas -Activate`n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Function Set-DRaas {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: William Lam
|
||||
Date: 05/23/2019
|
||||
Organization: VMware
|
||||
Blog: http://www.virtuallyghetto.com
|
||||
Twitter: @lamw
|
||||
===========================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
Activate or deactivate DRaaS for a given SDDC
|
||||
.DESCRIPTION
|
||||
This cmdlet activates or deactivates DRaaS for a given SDDC
|
||||
.EXAMPLE
|
||||
Get-DRaas
|
||||
#>
|
||||
Param (
|
||||
[Switch]$Activate,
|
||||
[Switch]$Deactivate,
|
||||
[Switch]$Troubleshoot
|
||||
)
|
||||
|
||||
If (-Not $global:draasConnection) { Write-error "No DRaaS Connection found, please use Connect-DRaaS" } Else {
|
||||
$draasUrl = $global:draasConnection.server
|
||||
|
||||
if($Activate) {
|
||||
$method = "POST"
|
||||
|
||||
if($Troubleshoot) {
|
||||
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasUrl`n"
|
||||
}
|
||||
|
||||
try {
|
||||
if($PSVersionTable.PSEdition -eq "Core") {
|
||||
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
|
||||
} else {
|
||||
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers
|
||||
}
|
||||
} catch {
|
||||
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
|
||||
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
|
||||
break
|
||||
} else {
|
||||
Write-Error "Error in activating DRaaS"
|
||||
Write-Error "`n($_.Exception.Message)`n"
|
||||
break
|
||||
}
|
||||
}
|
||||
Write-Host "`nActivating DRaaS, this will take some time and you can monitor the progress using Get-DRaaS or using the VMC Console UI`n"
|
||||
} elseif ($Deactivate) {
|
||||
$method = "DELETE"
|
||||
|
||||
if($Troubleshoot) {
|
||||
Write-Host -ForegroundColor cyan "`n[DEBUG] - $METHOD`n$draasUrl`n"
|
||||
}
|
||||
|
||||
try {
|
||||
if($PSVersionTable.PSEdition -eq "Core") {
|
||||
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers -SkipCertificateCheck
|
||||
} else {
|
||||
$requests = Invoke-WebRequest -Uri $draasUrl -Method $method -Headers $global:draasConnection.headers
|
||||
}
|
||||
} catch {
|
||||
if($_.Exception.Response.StatusCode -eq "Unauthorized") {
|
||||
Write-Host -ForegroundColor Red "`nThe CSP session is no longer valid, please re-run the Connect-DRaaS cmdlet to retrieve a new token`n"
|
||||
break
|
||||
} else {
|
||||
Write-Error "Error in deactivating DRaaS"
|
||||
Write-Error "`n($_.Exception.Message)`n"
|
||||
break
|
||||
}
|
||||
}
|
||||
Write-Host "`nDeactivating DRaaS, this will take some time and you can monitor the progress using Get-DRaaS or the VMC Console UI`n"
|
||||
} else {
|
||||
Write-Error "Invalid Operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ Description = 'PowerShell Module for Managing Hybrid Cloud Extension (HCX) on VM
|
||||
PowerShellVersion = '6.0'
|
||||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = 'Connect-HcxServer', 'Get-HcxCloudConfig', 'Get-HcxEndpoint', 'New-HcxMigration', 'Get-HcxMigration', 'Connect-HcxVAMI', 'Get-HcxVCConfig', 'Set-HcxLicense', 'Set-HcxVCConfig', 'Get-HcxNSXConfig', 'Set-HcxNSXConfig', 'Get-HcxCity', 'Get-HcxLocation', 'Set-HcxLocation', 'Get-HcxRoleMapping', 'Set-HcxRoleMapping', 'Get-HcxProxy', 'Set-HcxProxy', 'Remove-HcxProxy'
|
||||
FunctionsToExport = 'Connect-HcxServer', 'Get-HcxCloudConfig', 'Get-HcxEndpoint', 'New-HcxMigration', 'Get-HcxMigration', 'Connect-HcxVAMI', 'Get-HcxVCConfig', 'Set-HcxLicense', 'Set-HcxVCConfig', 'Get-HcxNSXConfig', 'Set-HcxNSXConfig', 'Get-HcxCity', 'Get-HcxLocation', 'Set-HcxLocation', 'Get-HcxRoleMapping', 'Set-HcxRoleMapping', 'Get-HcxProxy', 'Set-HcxProxy', 'Remove-HcxProxy', 'Get-HcxLicense'
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||
CmdletsToExport = @()
|
||||
|
||||
|
||||
@@ -453,12 +453,23 @@ Function Get-HcxMigration {
|
||||
Get-HcxMigration -MigrationId <MigrationID>
|
||||
#>
|
||||
Param (
|
||||
[Parameter(Mandatory=$false)][String]$MigrationId,
|
||||
[Parameter(Mandatory=$false)][String[]]$MigrationId,
|
||||
[Switch]$RunningMigrations
|
||||
)
|
||||
|
||||
If (-Not $global:hcxConnection) { Write-error "HCX Auth Token not found, please run Connect-HcxManager " } Else {
|
||||
$spec = @{}
|
||||
If($PSBoundParameters.ContainsKey("MigrationId")){
|
||||
$spec = @{
|
||||
filter = @{
|
||||
migrationId = $MigrationId
|
||||
}
|
||||
paging =@{
|
||||
pageSize = $MigrationId.Count
|
||||
}
|
||||
}
|
||||
} Else {
|
||||
$spec = @{}
|
||||
}
|
||||
$body = $spec | ConvertTo-Json
|
||||
|
||||
$hcxQueryUrl = $global:hcxConnection.Server + "/migrations?action=query"
|
||||
@@ -468,10 +479,10 @@ Function Get-HcxMigration {
|
||||
$requests = Invoke-WebRequest -Uri $hcxQueryUrl -Method POST -Headers $global:hcxConnection.headers -UseBasicParsing
|
||||
}
|
||||
|
||||
$migrations = ($requests.content | ConvertFrom-Json).rows
|
||||
|
||||
if($PSBoundParameters.ContainsKey("MigrationId")){
|
||||
$migrations = $migrations | where { $_.migrationId -eq $MigrationId }
|
||||
$migrations = ($requests.content | ConvertFrom-Json).items
|
||||
} else {
|
||||
$migrations = ($requests.content | ConvertFrom-Json).rows
|
||||
}
|
||||
|
||||
if($RunningMigrations){
|
||||
@@ -559,16 +570,22 @@ Function Get-HcxVCConfig {
|
||||
#>
|
||||
If (-Not $global:hcxVAMIConnection) { Write-error "HCX Auth Token not found, please run Connect-HcxVAMI " } Else {
|
||||
$vcConfigUrl = $global:hcxVAMIConnection.Server + "/api/admin/global/config/vcenter"
|
||||
$pscConfigUrl = $global:hcxVAMIConnection.Server + "/api/admin/global/config/lookupservice"
|
||||
|
||||
if($PSVersionTable.PSEdition -eq "Core") {
|
||||
$vcRequests = Invoke-WebRequest -Uri $vcConfigUrl -Method GET -Headers $global:hcxVAMIConnection.headers -UseBasicParsing -SkipCertificateCheck
|
||||
$ssoRequests = Invoke-WebRequest -Uri $pscConfigUrl -Method GET -Headers $global:hcxVAMIConnection.headers -UseBasicParsing -SkipCertificateCheck
|
||||
} else {
|
||||
$vcRequests = Invoke-WebRequest -Uri $vcConfigUrl -Method GET -Headers $global:hcxVAMIConnection.headers -UseBasicParsing
|
||||
$ssoRequests = Invoke-WebRequest -Uri $pscConfigUrl -Method GET -Headers $global:hcxVAMIConnection.headers -UseBasicParsing
|
||||
}
|
||||
$vcData = ($vcRequests.content | ConvertFrom-Json).data.items
|
||||
$ssoData = ($ssoRequests.content | ConvertFrom-Json).data.items
|
||||
|
||||
$tmp = [pscustomobject] @{
|
||||
Name = $vcData.config.name;
|
||||
UserName = $vcData.Config.userName
|
||||
LookupServiceUrl = $ssoData.config.lookupServiceUrl
|
||||
Version = $vcData.config.version;
|
||||
Build = $vcData.config.buildNumber;
|
||||
UUID = $vcData.config.vcuuid;
|
||||
@@ -578,6 +595,38 @@ Function Get-HcxVCConfig {
|
||||
}
|
||||
}
|
||||
|
||||
Function Get-HcxLicense {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: Mark McGilly
|
||||
Date: 4/29/2019
|
||||
Organization: Liberty Mutual Insurance
|
||||
===========================================================================
|
||||
|
||||
.SYNOPSIS
|
||||
Returns the license key that is registered with HCX Manager
|
||||
.DESCRIPTION
|
||||
This cmdlet returns the license key registered with HCX Manager
|
||||
.EXAMPLE
|
||||
Get-HcxLicense
|
||||
#>
|
||||
|
||||
If (-Not $global:hcxVAMIConnection) { Write-error "HCX Auth Token not found, please run Connect-HcxVAMI " } Else {
|
||||
$hcxConfigUrl = $global:hcxVAMIConnection.Server + "/api/admin/global/config/hcx"
|
||||
|
||||
if($PSVersionTable.PSEdition -eq "Core") {
|
||||
$licenseRequests = Invoke-WebRequest -Uri $hcxConfigUrl -Method GET -Headers $global:hcxVAMIConnection.headers -UseBasicParsing -SkipCertificateCheck
|
||||
} else {
|
||||
$licenseRequests = Invoke-WebRequest -Uri $hcxConfigUrl -Method GET -Headers $global:hcxVAMIConnection.headers -UseBasicParsing
|
||||
}
|
||||
$license = ($licenseRequests.content | ConvertFrom-Json).data.items
|
||||
if($licenseRequests) {
|
||||
$license.config.activationKey
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function Set-HcxLicense {
|
||||
<#
|
||||
.NOTES
|
||||
@@ -789,6 +838,7 @@ Function Get-HcxNSXConfig {
|
||||
|
||||
$tmp = [pscustomobject] @{
|
||||
Name = $nsxData.config.url;
|
||||
UserName = $nsxData.config.userName
|
||||
Version = $nsxData.config.version;
|
||||
HCXUUID = $nsxData.config.uuid;
|
||||
}
|
||||
@@ -1200,6 +1250,7 @@ Function Set-HcxProxy {
|
||||
[Parameter(Mandatory=$True)]$ProxyPort,
|
||||
[Parameter(Mandatory=$False)]$ProxyUser,
|
||||
[Parameter(Mandatory=$False)]$ProxyPassword,
|
||||
[Parameter(Mandatory=$False)]$ProxyExclusions,
|
||||
[Switch]$Troubleshoot
|
||||
)
|
||||
|
||||
@@ -1214,7 +1265,7 @@ Function Set-HcxProxy {
|
||||
config = @{
|
||||
proxyHost = "$ProxyServer";
|
||||
proxyPort = "$ProxyPort";
|
||||
nonProxyHosts = "";
|
||||
nonProxyHosts = "$ProxyExclusions";
|
||||
userName = "$ProxyUser";
|
||||
password = "$ProxyPassword";
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,13 @@ Description = 'PowerShell Module for Managing NSX-T on VMware Cloud on AWS'
|
||||
PowerShellVersion = '6.0'
|
||||
|
||||
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||
FunctionsToExport = 'Connect-NSXTProxy', 'Get-NSXTSegment', 'New-NSXTSegment', 'Remove-NSXTSegment', 'Get-NSXTGroup', 'New-NSXTGroup', 'Remove-NSXTGroup', 'Get-NSXTService', 'New-NSXTService', 'Get-NSXTFirewall', 'New-NSXTFirewall', 'Remove-NSXTFirewall', 'Get-NSXTDistFirewallSection', 'Get-NSXTDistFirewall', 'New-NSXTDistFirewall', 'Remove-NSXTDistFirewall', 'Get-NSXTRouteTable', 'Get-NSXTOverviewInfo'
|
||||
FunctionsToExport = 'Connect-NSXTProxy', 'Get-NSXTSegment', 'New-NSXTSegment', 'Remove-NSXTSegment', `
|
||||
'Get-NSXTGroup', 'New-NSXTGroup', 'Remove-NSXTGroup', 'Get-NSXTService', 'New-NSXTService', `
|
||||
'Get-NSXTFirewall', 'New-NSXTFirewall', 'Remove-NSXTFirewall', 'Get-NSXTDistFirewallSection', `
|
||||
'Get-NSXTDistFirewall', 'New-NSXTDistFirewall', 'Remove-NSXTDistFirewall', 'Get-NSXTRouteTable', `
|
||||
'Get-NSXTOverviewInfo', 'Get-NSXTInfraScope', 'Get-NSXTInfraGroup', 'New-NSXTRouteBasedVPN', `
|
||||
'Get-NSXTRouteBasedVPN', 'Remove-NSXTRouteBasedVPN', 'Remove-NSXTService', 'New-NSXTDistFirewallSection', 'Get-NSXTDistFirewallSection', `
|
||||
'New-NSXTPolicyBasedVPN', 'Get-NSXTPolicyBasedVPN', 'Remove-NSXTPolicyBasedVPN', 'Get-NSXTDNS', 'Set-NSXTDNS'
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||
CmdletsToExport = @()
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -874,8 +874,8 @@ Function Get-VMCSDDCSummary {
|
||||
Get-VMCSDDCSummary -Name <SDDC Name> -Org <Org Name>
|
||||
#>
|
||||
Param (
|
||||
[Parameter(Mandatory=$True)]$OrgName,
|
||||
[Parameter(Mandatory=$True)]$SDDCName
|
||||
[Parameter(Mandatory=$True)]$Org,
|
||||
[Parameter(Mandatory=$True)]$Name
|
||||
)
|
||||
|
||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
||||
@@ -895,6 +895,7 @@ Function Get-VMCSDDCSummary {
|
||||
InstanceType = $sddc.resource_config.sddc_manifest.esx_ami.instance_type;
|
||||
VpcCIDR = $sddc.resource_config.vpc_info.vpc_cidr;
|
||||
NSXT = $sddc.resource_config.nsxt;
|
||||
VPC_VGW = $sddc.resource_config.vpc_info.vgw_id;
|
||||
}
|
||||
$results
|
||||
}
|
||||
@@ -903,7 +904,7 @@ Function Get-VMCPublicIP {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: William Lam
|
||||
Created by: William LamVPC_VGW
|
||||
Date: 09/12/2018
|
||||
Organization: VMware
|
||||
Blog: http://www.virtuallyghetto.com
|
||||
|
||||
Reference in New Issue
Block a user