Compare commits
47 Commits
kmruddy-pa
...
VMFSIncrea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3dda8cc639 | ||
|
|
99250732fb | ||
|
|
7bbec511cb | ||
|
|
b2ba87db86 | ||
|
|
7392e451c5 | ||
|
|
1489e86b66 | ||
|
|
7a38462f1a | ||
|
|
ddfb85780f | ||
|
|
06a3ea0210 | ||
|
|
172e1436c5 | ||
|
|
e1937544fb | ||
|
|
7f6482b7af | ||
|
|
f47c3a7c3b | ||
|
|
e91b0c0649 | ||
|
|
ca70d01e54 | ||
|
|
1dff599996 | ||
|
|
2e25d166a0 | ||
|
|
e709f1fdde | ||
|
|
c432a0d1fa | ||
|
|
99673b1dfa | ||
|
|
3403db0ead | ||
|
|
2f595f086d | ||
|
|
e7c968d32b | ||
|
|
8469b3a285 | ||
|
|
456bd28b45 | ||
|
|
41a79d34a7 | ||
|
|
32096f6e02 | ||
|
|
67ba5de622 | ||
|
|
c8b2607b94 | ||
|
|
fd3c02b434 | ||
|
|
eae378822b | ||
|
|
e6744ea742 | ||
|
|
4464bf001b | ||
|
|
2a9a1b576b | ||
|
|
06d3eed37d | ||
|
|
6c49ae183f | ||
|
|
9187c45589 | ||
|
|
c342a7c3d4 | ||
|
|
677a5ce734 | ||
|
|
44abee7538 | ||
|
|
3ed0aa9ca4 | ||
|
|
ae5456560d | ||
|
|
beaeddba59 | ||
|
|
d20e5735e7 | ||
|
|
2f40185ceb | ||
|
|
b7d31ca3f4 | ||
|
|
deadb6f2c3 |
42
LICENSE.md
Normal file
42
LICENSE.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# PowerCLI-Example-Scripts
|
||||
VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT
|
||||
|
||||
Notice to User: This Technology Preview License Agreement (the “Agreement”) is a CONTRACT between you (either an individual or a single entity) (“you” or “Licensee”) and VMware, Inc. (“VMware”), which covers your use of the Technology Preview Software (as defined below). If you do not agree to the terms of this Agreement, then do not install or use the Technology Preview Software. By explicitly accepting this Agreement, however, or by installing, copying, downloading, accessing, or otherwise using the Technology Preview Software, you are acknowledging and agreeing to be bound by the following terms.
|
||||
|
||||
1. DEFINITIONS. (a) “Technology Preview Software” means the unreleased, concept version of VMware’s software, in object form only, excluding any Open Source Software provided with the such software, and the media and Documentation provided by VMware to Licensee and for which Licensee is granted a use license pursuant to this Agreement. (b) “Documentation” means the printed and online written reference material furnished to Licensee in conjunction with the Technology Preview Software, including, without limitation, instructions, testing guidelines, and end user guides. (c) “Intellectual Property Rights” shall mean all intellectual property rights, including, without limitation, patent, copyright, trademark, and trade secret. (d) “Open Source Software” means various open source software components provided with the Technology Preview Software that are licensed to you under the terms of the applicable license agreements included with such open source software components or other materials for the Technology Preview Software. (e) “Updates” means a modification, error correction, bug fix, new release, or other update to or for the Technology Preview Software.
|
||||
|
||||
2. LICENSE GRANT, USE AND OWNERSHIP.
|
||||
|
||||
(a) Limited License. Subject to the terms and conditions of this Agreement, VMware grants to Licensee a non-exclusive, non-transferable license (without the right to sublicense) (i) to use the Technology Preview Software in accordance with the Documentation solely for purposes of internal testing and evaluation, (ii) to use the Documentation provided with the Technology Preview Software in support of Licensee’s authorized use of the Technology Preview Software, and (iii) to copy the Technology Preview Software for archival or backup purposes, provided that all titles and trademarks, copyright, and restricted rights notices are reproduced on such copies.
|
||||
|
||||
(b) Evaluation Feedback. The purpose of this limited license is the testing and evaluation of the Technology Preview Software as set forth above. In furtherance of this purpose, Licensee shall provide feedback to VMware concerning the functionality and performance of the Technology Preview Software from time to time as reasonably requested by VMware, including, without limitation, identifying potential errors and improvements. Licensee will provide the requested feedback in a manner that is convenient to Licensee subject to reasonable availability of Licensee’s personnel. Notwithstanding the foregoing, prior to Licensee disclosing to VMware any information under this Agreement that Licensee considers proprietary or confidential, Licensee shall obtain VMware’s prior written approval to disclose such information to VMware, and without such prior written approval from VMware, Licensee shall not disclose any such information to VMware. VMware may use feedback to improve or enhance its products and, accordingly, you hereby grant to VMware a non-exclusive, perpetual, irrevocable, royalty-free, transferable, worldwide right and license, with the right to sublicense, to use, reproduce, disclose, distribute, perform, display, modify, prepare derivative works of and otherwise exploit the feedback and other information without restriction in any manner now known or in the future conceived and to make, use, sell, offer to sell, import and export any product or service that incorporates the feedback and other information.
|
||||
|
||||
(c) Restrictions. Licensee shall not copy or use the Technology Preview Software (including the Documentation) except as expressly permitted in this Agreement. Except to the extent that any applicable mandatory laws prevent VMware restraining Licensee from doing so, Licensee will not, and will not permit any third party to, sublicense, rent, copy, modify, create derivative works of, translate, reverse engineer, decompile, disassemble, or otherwise reduce to human perceivable form any portion of the Technology Preview Software or accompanying Documentation. Without limiting the generality of the foregoing, Licensee shall not use the Technology Preview Software for Licensee’s product development or any other commercial purpose. The Technology Preview Software and all performance data and test results, including without limitation, benchmark test results (collectively “Performance Data”) relating to the Technology Preview Software are the Confidential Information of VMware, and will be treated in accordance with the terms of Section 4 of this Agreement. Accordingly, Licensee shall not publish or disclose to any third party any Performance Data relating to the Technology Preview Software.
|
||||
|
||||
(d) Ownership. VMware shall own and retain all right, title and interest in and to the Intellectual Property Rights in the Technology Preview Software, subject only to the limited license expressly set forth in Section 2(a) hereof. Licensee does not acquire any other rights, express or implied, in the Technology Preview Software. ALL RIGHTS NOT EXPRESSLY GRANTED HEREUNDER ARE RESERVED TO VMWARE.
|
||||
|
||||
(e) No Support Services. VMware is under no obligation to support the Technology Preview Software in any way or to provide any Updates to Licensee. In the event VMware, in its sole discretion, supplies any Update to Licensee, the Update shall be deemed Technology Preview Software under this Agreement and shall be subject to the terms and conditions of this Agreement.
|
||||
|
||||
(f) Third-Party Software. The Technology Preview Software may enable a computer to run multiple instances of third-party guest operating systems and application programs. Licensee acknowledges that Licensee is responsible for obtaining any licenses necessary to operate any third-party software, including guest operating systems and application programs.
|
||||
|
||||
(g) Open Source Software. Except for Sections 5, 6 and 7, the terms and conditions of this Agreement shall not apply to any Open Source Software accompanying the Technology Preview Software. Any such Open Source Software is provided under the terms of the open source license agreement or copyright notice accompanying such Open Source Software or in the open source licenses file accompanying the Technology Preview Software.
|
||||
|
||||
3. TERM AND TERMINATION. Licensee’s rights with respect to the Technology Preview Software will terminate upon the earlier of (a) automatic expiration of the Technology Preview Software based on the system date, or (b) termination by VMware, in its sole discretion, of Licensee’s rights with respect to the Technology Preview Software provided under this Agreement upon notice on the VMware website. Upon any expiration or termination of rights with respect to the Technology Preview Software under this Agreement, the rights and licenses granted to Licensee under this Agreement shall immediately terminate, and Licensee shall immediately cease using, and will destroy or render practically inaccessible the Technology Preview Software, Documentation, and all other tangible items in Licensee’s possession or control that contain Confidential Information. The rights and obligations of the parties set forth in Sections 2(b), 2(c), 2(d), 2(e), 2(f), 2(g), 3, 4, 5, 6 and 7 shall survive termination or expiration of this Agreement for any reason.
|
||||
|
||||
4. CONFIDENTIALITY. (a) Confidentiality. "Confidential Information" means the Technology Preview Software, all information regarding the Technology Preview Software (including any trade secrets, know-how, inventions, techniques, processes, and algorithms embodied in the Technology Preview Software), Documentation, Performance Data, any Updates, and other information provided by VMware to Licensee under this Agreement, whether disclosed orally, in writing, or by examination or inspection, other than information that Licensee can demonstrate (i) was already known to Licensee, other than under an obligation of confidentiality, at the time of disclosure; (ii) was generally available in the public domain at the time of disclosure to Licensee; (iii) became generally available in the public domain after disclosure other than through any act or omission of Licensee; (iv) was subsequently lawfully disclosed to Licensee by a third party without any obligation of confidentiality; or (v) was independently developed by Licensee without use of or reference to any information or materials disclosed by VMware or its suppliers. If Licensee is required to disclose Confidential Information by applicable law or court order, Licensee shall notify VMware of the required disclosure promptly in writing and shall cooperate with VMware in any lawful action to contest or limit the scope of the required disclosure. Confidential Information shall include, without limitation, any information relating to VMware products, product roadmaps, and other technical, business, financial and product development plans, forecasts and strategies. Licensee shall not use any Confidential Information for any purpose other than as expressly authorized under this Agreement. In no event shall Licensee use the Technology Preview Software or any Confidential Information to develop, manufacture, market, sell, or distribute any product or service, including any VMware products. Licensee shall not disclose any Confidential Information to any third party. Without limiting the foregoing, Licensee shall use at least the same degree of care that it uses to prevent the disclosure of its own confidential information of like importance, but in no event less than reasonable care, to prevent the disclosure of such Confidential Information. (b) Additional Confidentiality Restrictions for Highly Confidential Technology Preview Software. For certain Technology Preview Software designated by VMware as highly confidential (“Highly Confidential Technology Preview Software”) in VMware’s correspondence to you regarding this Technology Preview Software or in any Documentation, additional heightened confidentiality restrictions designated below will apply. (i) Licensee shall limit dissemination of Highly Confidential Technology Preview Software and related information concerning product features, future technologies and roadmaps only to Information Technology teams and/or software/solutions development teams of Licensee designated by VMware, and only to individuals on those teams who have a need to know the Confidential Information for purposes expressly authorized under this Agreement. For clarity and without limiting the generality of the foregoing, Licensee shall not disseminate any Highly Confidential Technology Preview Software to Licensee's sales and marketing field organizations. Licensee will assign an employee who will be primarily responsible (“Primary Contact”) for ensuring that the terms of this Agreement are complied with. (ii) Licensee acknowledges that damages for improper disclosure of Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps may be irreparable and that monetary damages would be inadequate to compensate VMware for any breach of this Agreement. In the event that VMware reasonably believes that Licensee has disseminated certain of such Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps to an unauthorized party, Licensee will be immediately removed from VMware’s Technology Preview Software program and will not be permitted to participate in any VMware Technology Preview Software program in the future. Additionally, all rights and licenses granted to Licensee under this Agreement shall immediately terminate in accordance with Section 3 herein (Term and Termination). (c) Remedies. In addition to all other remedies available in law or otherwise, VMware is entitled to seek equitable relief, including injunctive relief, against the threatened breach of this Agreement or the continuation of any such breach.
|
||||
|
||||
5. LIMITATION OF LIABILITY. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE IS PROVIDED WITHOUT CHARGE FOR LIMITED EVALUATION PURPOSES. ACCORDINGLY, THE TOTAL LIABILITY OF VMWARE AND ITS LICENSORS ARISING OUT OF OR RELATED TO THIS AGREEMENT SHALL NOT EXCEED US$100.00. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT SHALL VMWARE OR ITS LICENSORS HAVE LIABILITY FOR ANY INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY (INCLUDING WITHOUT LIMITATION, TORT, STATUTE, CONTRACT OR OTHER), EVEN IF VMWARE AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
|
||||
|
||||
6. WARRANTY DISCLAIMER. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE, OPEN SOURCE SOFTWARE, DOCUMENTATION, AND ANY UPDATES MAY CONTAIN ERRORS AND ARE PROVIDED FOR LIMITED EVALUATION ONLY. THE TECHNOLOGY PREVIEW SOFTWARE, THE OPEN SOURCE SOFTWARE, THE DOCUMENTATION, AND ANY UPDATES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE. VMWARE AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. Licensee acknowledges that VMware has not publicly announced the availability of the Technology Preview Software, that such Technology Preview Software may contain features currently under development, that VMware has not promised or guaranteed to Licensee that such Technology Preview Software will be announced or made available to anyone in the future, that VMware has no express or implied obligation to Licensee to announce or introduce the Technology Preview Software, that VMware has no obligation to introduce a product similar to or compatible with the Technology Preview Software, and that any version number (if any) referenced is subject to change and does not in any way represent VMware’s commitment to release any product in the future. Accordingly, Licensee acknowledges that any research or development that it performs regarding the Technology Preview Software or any product associated with the Technology Preview Software is done entirely at Licensee’s own risk. Specifically, the Technology Preview Software may contain features, functionality or modules that will not be included in the production version of the Technology Preview Software, if released, or that will be marketed separately for additional fees.
|
||||
|
||||
7. OTHER PROVISIONS. (a) Governing Law. This Agreement, and all disputes arising out of or related thereto, shall be governed by and construed under the laws of the State of California without reference to conflict of laws principles. All such disputes shall be subject to the exclusive jurisdiction of the state and federal courts located in Santa Clara County, California, and the parties agree and submit to the personal and exclusive jurisdiction and venue of these courts. The United Nations Convention for the International Sale of Goods shall not apply. (b) Export Control. The Technology Preview Software is of United States origin and is provided subject to the U.S. Export Administration Regulations. Diversion contrary to U.S. law is prohibited. Without limiting the foregoing, you agree that (i) you are not, and are not acting on behalf of, any person who is a citizen, national, or resident of, or who is controlled by the government of, Cuba, Iran, North Korea, Sudan, or Syria, or any other country to which the United States has prohibited export transactions; (ii) you are not, and are not acting on behalf of, any person or entity listed on the U.S. Treasury Department list of Specially Designated Nationals and Blocked Persons, or the U.S. Commerce Department Denied Persons List or Entity List; and (iii) you will not use the Technology Preview Software for, and will not permit the Technology Preview Software to be used for, any purposes prohibited by law, including, without limitation, for any prohibited development, design, manufacture or production of missiles or nuclear, chemical or biological weapons. U.S. Export Control Classification Numbers (ECCN’s) may be found at VMware help page: http://www.vmware.com/help/export-control. (c) Modification. This is the entire agreement between the parties relating to the subject matter hereof and all other terms are rejected. No waiver or modification of this Agreement shall be valid unless in writing signed by each party. The waiver of a breach of any term hereof shall in no way be construed as a waiver of any other term or breach hereof. If any provision of this Agreement is held by a court of competent jurisdiction to be contrary to law, the remaining provisions of this Agreement shall remain in full force and effect. (d) Data Privacy. Licensee agrees that VMware may process technical and related usage information about Licensee’s use of the Technology Preview Software for statistical and analytical purposes. Usage information is collected strictly for internal statistical and analytical purposes for the development of VMware products and services. Licensee understands that any log files generated in order to obtain support from VMware may contain sensitive, confidential or personal information. Licensee should consider obfuscating any logs before sending them to VMware. VMware’s privacy policy (http://www.vmware.com/help/privacy.html) shall apply.
|
||||
|
||||
8. ASSIGNMENT. Licensee shall not assign this Agreement or any rights or obligations hereunder, directly or indirectly, by operation of law, merger, acquisition of stock or assets, or otherwise, without the prior written consent of VMware. Any attempted assignment or transfer in violation of the foregoing will be null and void. Subject to the foregoing, this Agreement shall inure to the benefit of and be binding upon the parties and their respective successors and permitted assigns.
|
||||
|
||||
9. CONTACT INFORMATION. If you have any questions about this Agreement, please direct all correspondence to: VMware, Inc., 3401 Hillview Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. VMware is a trademark of VMware, Inc. and is registered in the U.S. and numerous other countries.
|
||||
|
||||
Rev. 2014Mar10
|
||||
|
||||
|
||||
|
||||
|
||||
6
Modules/VMFSIncrease/LICENSE.txt.URL
Normal file
6
Modules/VMFSIncrease/LICENSE.txt.URL
Normal file
@@ -0,0 +1,6 @@
|
||||
[InternetShortcut]
|
||||
URL=https://github.com/lucdekens/LogInsight/blob/v1.0/LICENSE.txt
|
||||
IDList=
|
||||
HotKey=0
|
||||
IconFile=C:\Users\ldekens\AppData\Local\Mozilla\Firefox\Profiles\2ahnnh1i.default\shortcutCache\ec4nFcIEAQBPFmSiPtTJ2w==.ico
|
||||
IconIndex=0
|
||||
18
Modules/VMFSIncrease/VMFSIncrease.psd1
Normal file
18
Modules/VMFSIncrease/VMFSIncrease.psd1
Normal file
@@ -0,0 +1,18 @@
|
||||
@{
|
||||
ModuleToProcess = 'VMFSIncrease.psm1'
|
||||
ModuleVersion = '1.0.0.0'
|
||||
GUID = '9f167385-c5c6-4a65-ac14-949c67519001'
|
||||
Author = 'Luc Dekens '
|
||||
CompanyName = 'Community'
|
||||
Copyright = '(c) 2016. All rights reserved.'
|
||||
Description = 'Expand and Extend VMFS DatastoresModule description'
|
||||
PowerShellVersion = '3.0'
|
||||
FunctionsToExport = 'Get-VmfsDatastoreInfo','Get-VmfsDatastoreIncrease','New-VmfsDatastoreIncrease'
|
||||
PrivateData = @{
|
||||
PSData = @{
|
||||
Tags = @('VMFS','Expand','Extend','vSphere')
|
||||
LicenseUri = 'https://www.tldrlegal.com/l/mit'
|
||||
ProjectUri = 'https://github.com/lucdekens/VMFSIncrease'
|
||||
}
|
||||
}
|
||||
}
|
||||
247
Modules/VMFSIncrease/VMFSIncrease.psm1
Normal file
247
Modules/VMFSIncrease/VMFSIncrease.psm1
Normal file
@@ -0,0 +1,247 @@
|
||||
function Get-VmfsDatastoreInfo
|
||||
{
|
||||
[CmdletBinding(SupportsShouldProcess = $True)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True)]
|
||||
[PSObject]$Datastore
|
||||
)
|
||||
|
||||
Process
|
||||
{
|
||||
if ($Datastore -is [String])
|
||||
{
|
||||
$Datastore = Get-Datastore -Name $Datastore -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ($Datastore -isnot [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.Datastore])
|
||||
{
|
||||
Write-Error 'Invalid value for Datastore.'
|
||||
return
|
||||
}
|
||||
if ($Datastore.Type -ne 'VMFS')
|
||||
{
|
||||
Write-Error "$($Datastore.Name) is not a VMFS datastore"
|
||||
return
|
||||
}
|
||||
|
||||
# Get the Datastore System Manager from an ESXi that has the Datastore
|
||||
$esx = Get-View -Id ($Datastore.ExtensionData.Host | Get-Random | Select -ExpandProperty Key)
|
||||
$hsSys = Get-View -Id $esx.ConfigManager.StorageSystem
|
||||
|
||||
foreach ($extent in $Datastore.ExtensionData.Info.Vmfs.Extent)
|
||||
{
|
||||
$lun = $esx.Config.StorageDevice.ScsiLun | where{ $_.CanonicalName -eq $extent.DiskName }
|
||||
|
||||
$hdPartInfo = $hsSys.RetrieveDiskPartitionInfo($lun.DeviceName)
|
||||
$hdPartInfo[0].Layout.Partition | %{
|
||||
New-Object PSObject -Property ([ordered]@{
|
||||
Datastore = $Datastore.Name
|
||||
CanonicalName = $lun.CanonicalName
|
||||
Model = "$($lun.Vendor.TrimEnd(' ')).$($lun.Model.TrimEnd(' ')).$($lun.Revision.TrimEnd(' '))"
|
||||
DiskSizeGB = $hdPartInfo[0].Layout.Total.BlockSize * $hdPartInfo[0].Layout.Total.Block / 1GB
|
||||
DiskBlocks = $hdPartInfo[0].Layout.Total.Block
|
||||
DiskBlockMB = $hdPartInfo[0].Layout.Total.BlockSize/1MB
|
||||
PartitionFormat = $hdPartInfo[0].Spec.PartitionFormat
|
||||
Partition = if ($_.Partition -eq '') { '<free>' }else{ $_.Partition }
|
||||
Used = $extent.Partition -eq $_.Partition
|
||||
Type = $_.Type
|
||||
PartitionSizeGB = [math]::Round(($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize / 1GB, 1)
|
||||
PartitionBlocks = $_.End.Block - $_.Start.Block + 1
|
||||
PartitionBlockMB = $_.Start.BlockSize/1MB
|
||||
Start = $_.Start.Block
|
||||
End = $_.End.Block
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VmfsDatastoreIncrease
|
||||
{
|
||||
[CmdletBinding(SupportsShouldProcess = $True)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True)]
|
||||
[PSObject]$Datastore
|
||||
)
|
||||
|
||||
Process
|
||||
{
|
||||
if ($Datastore -is [String])
|
||||
{
|
||||
$Datastore = Get-Datastore -Name $Datastore -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ($Datastore -isnot [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.Datastore])
|
||||
{
|
||||
Write-Error 'Invalid value for Datastore.'
|
||||
return
|
||||
}
|
||||
|
||||
if ($Datastore.Type -ne 'VMFS')
|
||||
{
|
||||
Write-Error "$($Datastore.Name) is not a VMFS datastore"
|
||||
return
|
||||
}
|
||||
|
||||
# Get the Datastore System Manager from an ESXi that has the Datastore
|
||||
$esx = Get-View -Id ($Datastore.ExtensionData.Host | Get-Random | Select -ExpandProperty Key)
|
||||
$hsSys = Get-View -Id $esx.ConfigManager.StorageSystem
|
||||
$hdSys = Get-View -Id $esx.ConfigManager.DatastoreSystem
|
||||
|
||||
$extents = $Datastore.ExtensionData.Info.Vmfs.Extent | Select -ExpandProperty DiskName
|
||||
|
||||
$hScsiDisk = $hdSys.QueryAvailableDisksForVmfs($Datastore.ExtensionData.MoRef)
|
||||
foreach ($disk in $hScsiDisk)
|
||||
{
|
||||
$partInfo = $hsSys.RetrieveDiskPartitionInfo($disk.DeviceName)
|
||||
$partUsed = ($partInfo[0].Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
|
||||
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
|
||||
if ($extents -contains $disk.CanonicalName)
|
||||
{
|
||||
$incType = 'Expand'
|
||||
$vmfsExpOpt = $hdSys.QueryVmfsDatastoreExpandOptions($Datastore.ExtensionData.MoRef)
|
||||
$PartMax = ($vmfsExpOpt[0].Info.Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
|
||||
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
|
||||
}
|
||||
else
|
||||
{
|
||||
$incType = 'Extend'
|
||||
$vmfsExtOpt = $hdSys.QueryVmfsDatastoreExtendOptions($Datastore.ExtensionData.MoRef, $disk.DevicePath, $null)
|
||||
$partMax = ($vmfsExpOpt[0].Info.Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
|
||||
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
|
||||
}
|
||||
New-Object PSObject -Property ([ordered]@{
|
||||
Datastore = $Datastore.Name
|
||||
CanonicalName = $disk.CanonicalName
|
||||
Model = "$($disk.Vendor.TrimEnd(' ')).$($disk.Model.TrimEnd(' ')).$($disk.Revision.TrimEnd(' '))"
|
||||
DiskSizeGB = $partInfo[0].Layout.Total.BlockSize * $partInfo[0].Layout.Total.Block / 1GB
|
||||
DiskBlocks = $partInfo[0].Layout.Total.Block
|
||||
DiskBlockMB = $partInfo[0].Layout.Total.BlockSize/1MB
|
||||
AvailableGB = [math]::Round($partMax - $partUsed, 2)
|
||||
Type = $incType
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function New-VmfsDatastoreIncrease
|
||||
{
|
||||
[CmdletBinding(SupportsShouldProcess = $True)]
|
||||
param (
|
||||
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $True)]
|
||||
[PSObject]$Datastore,
|
||||
[int]$IncreaseSizeGB,
|
||||
[Parameter(Position = 1)]
|
||||
[string]$CanonicalName,
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'Expand')]
|
||||
[switch]$Expand,
|
||||
[Parameter(Mandatory = $true, ParameterSetName = 'ExTend')]
|
||||
[switch]$Extend
|
||||
)
|
||||
|
||||
Process
|
||||
{
|
||||
if ($Datastore -is [String])
|
||||
{
|
||||
$Datastore = Get-Datastore -Name $Datastore -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ($Datastore -isnot [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.Datastore])
|
||||
{
|
||||
Write-Error 'Invalid value for Datastore.'
|
||||
return
|
||||
}
|
||||
|
||||
if ($Datastore.Type -ne 'VMFS')
|
||||
{
|
||||
Write-Error "$($Datastore.Name) is not a VMFS datastore"
|
||||
return
|
||||
}
|
||||
|
||||
# Get the Datastore System Manager from an ESXi that has the Datastore
|
||||
$esx = Get-View -Id ($Datastore.ExtensionData.Host | Get-Random | Select -ExpandProperty Key)
|
||||
$hsSys = Get-View -Id $esx.ConfigManager.StorageSystem
|
||||
$hdSys = Get-View -Id $esx.ConfigManager.DatastoreSystem
|
||||
|
||||
$extents = $Datastore.ExtensionData.Info.Vmfs.Extent | Select -ExpandProperty DiskName
|
||||
|
||||
$hScsiDisk = $hdSys.QueryAvailableDisksForVmfs($Datastore.ExtensionData.MoRef)
|
||||
|
||||
# Expand or Extend
|
||||
switch ($PSCmdlet.ParameterSetName)
|
||||
{
|
||||
'Expand' {
|
||||
$expOpt = $hdSys.QueryVmfsDatastoreExpandOptions($Datastore.ExtensionData.MoRef)
|
||||
if ($CanonicalName)
|
||||
{
|
||||
$dsOpt = $expOpt | where{ $_.Spec.Extent.DiskName -eq $CanonicalName }
|
||||
}
|
||||
else
|
||||
{
|
||||
$dsOpt = $expOpt | Sort-Object -Property { $_.Spec.Extent.Diskname } | select -first 1
|
||||
}
|
||||
if ($IncreaseSizeGB -ne 0)
|
||||
{
|
||||
$lun = $hScsiDisk | where{ $_.CanonicalName -eq $dsOpt.Spec.Extent.DiskName }
|
||||
$partInfo = $hsSys.RetrieveDiskPartitionInfo($lun.DeviceName)
|
||||
$partMax = ($expOpt[0].Info.Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
|
||||
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
|
||||
$partUsed = ($partInfo[0].Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
|
||||
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
|
||||
if (($partMax - $partUsed) -ge $IncreaseSizeGB)
|
||||
{
|
||||
$spec = $dsOpt.Spec
|
||||
$spec.Partition.Partition[0].EndSector -= ([math]::Floor(($partMax - $partUsed - $IncreaseSizeGB) * 1GB/512))
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Error "Requested expand size $($IncreaseSizeGB)GB not available on $($lun.CanonicalName)"
|
||||
return
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$spec = $dsOpt.Spec
|
||||
}
|
||||
$hdSys.ExpandVmfsDatastore($Datastore.ExtensionData.MoRef, $spec)
|
||||
}
|
||||
'Extend' {
|
||||
if ($CanonicalName)
|
||||
{
|
||||
$lun = $hScsiDisk | where{ $extents -notcontains $_.CanonicalName -and $_.CanonicalName -eq $CanonicalName }
|
||||
}
|
||||
else
|
||||
{
|
||||
$lun = $hScsiDisk | where{ $extents -notcontains $_.CanonicalName } | Sort-Object -Property CanonicalName | select -First 1
|
||||
}
|
||||
if (!$lun)
|
||||
{
|
||||
Write-Error "No valid LUN provided or found for extent"
|
||||
return
|
||||
}
|
||||
$vmfsExtOpt = $hdSys.QueryVmfsDatastoreExtendOptions($Datastore.ExtensionData.MoRef, $lun.DevicePath, $null)
|
||||
if ($IncreaseSizeGB -ne 0)
|
||||
{
|
||||
$partInfo = $hsSys.RetrieveDiskPartitionInfo($lun.DeviceName)
|
||||
$partMax = ($vmfsExpOpt[0].Info.Layout.Partition | where{ $_.Type -eq 'VMFS' } | %{ ($_.End.Block - $_.Start.Block + 1) * $_.Start.BlockSize } |
|
||||
Measure-Object -Sum | select -ExpandProperty Sum)/1GB
|
||||
if ($partMax -ge $IncreaseSizeGB)
|
||||
{
|
||||
$spec = $vmfsExtOpt[0].Spec
|
||||
$spec.Partition.Partition[0].EndSector = $spec.Partition.Partition[0].StartSector + [math]::Floor($IncreaseSizeGB * 1GB / 512)
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Error "No valid LUN for extent with $($IncreaseSizeGB)GB space found"
|
||||
return
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$spec = $vmfsExtOpt.Spec
|
||||
}
|
||||
|
||||
$hdSys.ExtendVmfsDatastore($Datastore.ExtensionData.MoRef, $spec)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Get-VmfsDatastoreInfo,Get-VmfsDatastoreIncrease,New-VmfsDatastoreIncrease
|
||||
473
Modules/VMFSIncrease/en-US/VMFSIncrease.psm1-Help.xml
Normal file
473
Modules/VMFSIncrease/en-US/VMFSIncrease.psm1-Help.xml
Normal file
@@ -0,0 +1,473 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<helpItems xmlns="http://msh" schema="maml">
|
||||
<!--Edited with: SAPIEN PowerShell HelpWriter 2015 v1.0.16-->
|
||||
<!--Generated by: SAPIEN PowerShell HelpWriter 2015 v1.0.16-->
|
||||
<!--
|
||||
Module: VMFSIncrease
|
||||
Version: 1.0.0.0
|
||||
-->
|
||||
<!--All Commands-->
|
||||
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
|
||||
<!--Command-->
|
||||
<command:details>
|
||||
<command:name>Get-VmfsDatastoreInfo</command:name>
|
||||
<maml:description>
|
||||
<maml:para>Provides partition information for all the extents in the datastore.</maml:para>
|
||||
</maml:description>
|
||||
<maml:copyright>
|
||||
<maml:para/>
|
||||
</maml:copyright>
|
||||
<command:verb>Get</command:verb>
|
||||
<command:noun>VmfsDatastoreInfo</command:noun>
|
||||
<dev:version/>
|
||||
</command:details>
|
||||
<maml:description>
|
||||
<maml:para>The function will display partition information for all the extents used by the datastore.</maml:para>
|
||||
</maml:description>
|
||||
<command:syntax>
|
||||
<!--Parameter Sets-->
|
||||
<command:syntaxItem>
|
||||
<maml:name>Get-VmfsDatastoreInfo</maml:name>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:syntaxItem>
|
||||
</command:syntax>
|
||||
<command:parameters>
|
||||
<!--All Parameters-->
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>PSObject</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:parameters>
|
||||
<command:inputTypes>
|
||||
<!--Inputs-->
|
||||
<command:inputType>
|
||||
<dev:type>
|
||||
<maml:name>System.Management.Automation.PSObject
|
||||
</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<maml:description>
|
||||
<maml:para/>
|
||||
</maml:description>
|
||||
</command:inputType>
|
||||
</command:inputTypes>
|
||||
<command:returnValues>
|
||||
<!--Outputs-->
|
||||
<command:returnValue>
|
||||
<dev:type>
|
||||
<maml:name>System.Object</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<maml:description>
|
||||
<maml:para/>
|
||||
</maml:description>
|
||||
</command:returnValue>
|
||||
</command:returnValues>
|
||||
<command:examples>
|
||||
<!--Examples-->
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>Get-VmfsDatastoreInfo -Datastore MyDS</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>Will return partition information for the Datastore named MyDS</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>Get-Datastore -Name My* | Get-VmfsDatastoreInfo</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>This example will return partition information for all the Datastore objects that are returned by the Get-Datastore PowerCLI cmdlet</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
</command:examples>
|
||||
</command:command>
|
||||
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
|
||||
<!--Command-->
|
||||
<command:details>
|
||||
<command:name>Get-VmfsDatastoreIncrease</command:name>
|
||||
<maml:description>
|
||||
<maml:para>Displays the increase options for a datastore</maml:para>
|
||||
</maml:description>
|
||||
<maml:copyright>
|
||||
<maml:para/>
|
||||
</maml:copyright>
|
||||
<command:verb>Get</command:verb>
|
||||
<command:noun>VmfsDatastoreIncrease</command:noun>
|
||||
<dev:version/>
|
||||
</command:details>
|
||||
<maml:description>
|
||||
<maml:para>The function will provide all the Expand and Extend options for a specific datastore</maml:para>
|
||||
</maml:description>
|
||||
<command:syntax>
|
||||
<!--Parameter Sets-->
|
||||
<command:syntaxItem>
|
||||
<maml:name>Get-VmfsDatastoreIncrease</maml:name>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:syntaxItem>
|
||||
</command:syntax>
|
||||
<command:parameters>
|
||||
<!--All Parameters-->
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>PSObject</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:parameters>
|
||||
<command:inputTypes>
|
||||
<!--Inputs-->
|
||||
<command:inputType>
|
||||
<dev:type>
|
||||
<maml:name>System.Management.Automation.PSObject
|
||||
</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<maml:description>
|
||||
<maml:para/>
|
||||
</maml:description>
|
||||
</command:inputType>
|
||||
</command:inputTypes>
|
||||
<command:returnValues>
|
||||
<!--Outputs-->
|
||||
<command:returnValue>
|
||||
<dev:type>
|
||||
<maml:name>System.Object</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<maml:description>
|
||||
<maml:para/>
|
||||
</maml:description>
|
||||
</command:returnValue>
|
||||
</command:returnValues>
|
||||
<command:examples>
|
||||
<!--Examples-->
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>Get-VmfsDatastoreIncrease -Datastore MyDS</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The exmaple will list all Expand and Extend options available for the Datastore, named MyDS</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>Get-Datastore -Name MyDS* | Get-VmfsDatastoreIncrease</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The Expand and Extend options for all Datastore retruned by the PowerCLI Get-Datastore will be returned.</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
</command:examples>
|
||||
</command:command>
|
||||
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
|
||||
<!--Command-->
|
||||
<command:details>
|
||||
<command:name>New-VmfsDatastoreIncrease</command:name>
|
||||
<maml:description>
|
||||
<maml:para>Increase the capacity of a Datastore</maml:para>
|
||||
</maml:description>
|
||||
<maml:copyright>
|
||||
<maml:para/>
|
||||
</maml:copyright>
|
||||
<command:verb>New</command:verb>
|
||||
<command:noun>VmfsDatastoreIncrease</command:noun>
|
||||
<dev:version/>
|
||||
</command:details>
|
||||
<maml:description>
|
||||
<maml:para>The capacity of the Datastore in increased through an Expand or an Extend.
|
||||
To allow successful completion there shall be free capacity on one of the Extents, or there shall be free LUNs available.
|
||||
With the Expand or Extend switches the caller selects which type of capacity increase is used.</maml:para>
|
||||
</maml:description>
|
||||
<command:syntax>
|
||||
<!--Parameter Sets-->
|
||||
<command:syntaxItem>
|
||||
<maml:name>New-VmfsDatastoreIncrease</maml:name>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="">
|
||||
<maml:name>CanonicalName</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The Canonical name of the LUN on which to create a new Extent, or the name of the LUN on which to apply the Expansion.
|
||||
If this parameter is not provided, the function will sort the available LUN alphanumerically on the Canonical names and slect the first one.</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>IncreaseSizeGB</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The amount of GB by which to increase the size of the Datastore.
|
||||
If this parameter is not used, all of the available Expand or Extend diskspace will be used.</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>Expand</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>A switch to indicate if the Datastore shall be Expanded</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:syntaxItem>
|
||||
<command:syntaxItem>
|
||||
<maml:name>New-VmfsDatastoreIncrease</maml:name>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="">
|
||||
<maml:name>CanonicalName</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The Canonical name of the LUN on which to create a new Extent, or the name of the LUN on which to apply the Expansion.
|
||||
If this parameter is not provided, the function will sort the available LUN alphanumerically on the Canonical names and slect the first one.</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>IncreaseSizeGB</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The amount of GB by which to increase the size of the Datastore.
|
||||
If this parameter is not used, all of the available Expand or Extend diskspace will be used.</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>Extend</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>A switch to indicate if the Datastore shall be Extended</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:syntaxItem>
|
||||
</command:syntax>
|
||||
<command:parameters>
|
||||
<!--All Parameters-->
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="True (ByValue)" position="0" aliases="">
|
||||
<maml:name>Datastore</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The name of the Datastore or a PowerCLI Datastore object</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">PSObject</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>PSObject</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>IncreaseSizeGB</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The amount of GB by which to increase the size of the Datastore.
|
||||
If this parameter is not used, all of the available Expand or Extend diskspace will be used.</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">Int32</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>Int32</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1" aliases="">
|
||||
<maml:name>CanonicalName</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>The Canonical name of the LUN on which to create a new Extent, or the name of the LUN on which to apply the Expansion.
|
||||
If this parameter is not provided, the function will sort the available LUN alphanumerically on the Canonical names and slect the first one.</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>String</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>Expand</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>A switch to indicate if the Datastore shall be Expanded</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">SwitchParameter</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>SwitchParameter</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named" aliases="">
|
||||
<maml:name>Extend</maml:name>
|
||||
<maml:description>
|
||||
<maml:para>A switch to indicate if the Datastore shall be Extended</maml:para>
|
||||
</maml:description>
|
||||
<command:parameterValue required="true" variableLength="false">SwitchParameter</command:parameterValue>
|
||||
<dev:type>
|
||||
<maml:name>SwitchParameter</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<dev:defaultValue>
|
||||
</dev:defaultValue>
|
||||
</command:parameter>
|
||||
</command:parameters>
|
||||
<command:inputTypes>
|
||||
<!--Inputs-->
|
||||
<command:inputType>
|
||||
<dev:type>
|
||||
<maml:name>System.Management.Automation.PSObject
|
||||
</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<maml:description>
|
||||
<maml:para/>
|
||||
</maml:description>
|
||||
</command:inputType>
|
||||
</command:inputTypes>
|
||||
<command:returnValues>
|
||||
<!--Outputs-->
|
||||
<command:returnValue>
|
||||
<dev:type>
|
||||
<maml:name>System.Object</maml:name>
|
||||
<maml:uri/>
|
||||
</dev:type>
|
||||
<maml:description>
|
||||
<maml:para/>
|
||||
</maml:description>
|
||||
</command:returnValue>
|
||||
</command:returnValues>
|
||||
<command:examples>
|
||||
<!--Examples-->
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>New-VmfsDatastoreIncrease -Datastore MyDS -Expand</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The capacity of the Datastore, named MyDS, will be Expanded with all available free space on the first extent of the Datastore.</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>New-VmfsDatastoreIncrease -Name MyDS -Expand -IncreaseSizeGB 25</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The capacity of the Datastore, named MyDS, will be Expanded with 25GB on the first extent of the Datastore.
|
||||
Provided if course, this amount of free space is available.</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>New-VmfsDatastoreIncrease -Datastore 'TestDS' -Expand -IncreaseSizeGB 15 -CanonicalName 'naa.600507680180732f1800000000000011'</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The capacity of the Datastore MyDS will be increased with 15GB on the extent with the Canonicalname naa.600507680180732f1800000000000011</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>New-VmfsDatastoreIncrease -Datastore MyDS -Expand -CanonicalName 'naa.600507680180732f1800000000000012'</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The capacity of the Datastore MyDS will be increased with all available free space on the extent with the Canonicalname naa.600507680180732f1800000000000012</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 5 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>New-VmfsDatastoreIncrease -Datastore MyDS -Extend</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>A new Extent will be added to Datastore MyDS.
|
||||
All available free space of the LUN will be allocated.
|
||||
The available LUNs are ordered alphanumerically by their Canonicalname, and the first LUN is used.</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
<command:example>
|
||||
<maml:title>-------------------------- EXAMPLE 6 --------------------------</maml:title>
|
||||
<maml:introduction>
|
||||
<maml:para>PS C:\></maml:para>
|
||||
</maml:introduction>
|
||||
<dev:code>Get-Datastore -Name MyDS | New-VmfsDatastoreIncrease -Extend -IncreaseSizeGB 50</dev:code>
|
||||
<dev:remarks>
|
||||
<maml:para>The capacity of the Datastore returned by the PowerCLI Get-Datastore cmdlet will be increased by 50GB.
|
||||
This is done by adding a new Extent to the Datastore.
|
||||
The available LUNs are ordered alphanumerically by their Canonicalname, and the first LUN is used.</maml:para>
|
||||
</dev:remarks>
|
||||
</command:example>
|
||||
</command:examples>
|
||||
</command:command>
|
||||
<!--Generated by: SAPIEN PowerShell HelpWriter 2015 v1.0.16-->
|
||||
</helpItems>
|
||||
13
Modules/VMFSIncrease/en-US/about_VMFSIncrease.help.txt
Normal file
13
Modules/VMFSIncrease/en-US/about_VMFSIncrease.help.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
TOPIC
|
||||
VMFSIncrease
|
||||
|
||||
SYNOPSIS
|
||||
The VMFSIncrease module offers the same functionality that is available
|
||||
through the Increase button in the vSphere Web Client.
|
||||
|
||||
DESCRIPTION
|
||||
The VMFSIncrease offers functionality that allows to Expand or Extend
|
||||
VMFS Datastores. The module uses the vSphere API to implement this functionality.
|
||||
|
||||
SEE ALSO
|
||||
http://www.lucd.info/2016/07/29/vmfs-datastores-expand-and-extend
|
||||
92
Pester/Get-DatastoreProvisioned.Tests.ps1
Normal file
92
Pester/Get-DatastoreProvisioned.Tests.ps1
Normal file
@@ -0,0 +1,92 @@
|
||||
# To run: "Invoke-Pester <path>\Get-DatastoreProvisioned.Tests.ps1"
|
||||
|
||||
<#
|
||||
Script name: Get-DatastoreProvisioned.Tests.ps1
|
||||
Created on: 2016/07/27
|
||||
Author: Brian Bunke, @brianbunke
|
||||
Description: Help validate that any changes to Get-DatastoreProvisioned.ps1 do not break existing functionality
|
||||
Dependencies: Pester
|
||||
|
||||
===Tested Against Environment====
|
||||
vSphere Version: 6.0 U1/U2
|
||||
PowerCLI Version: PowerCLI 6.3 R1
|
||||
PowerShell Version: 5.0
|
||||
OS Version: Windows 7/10
|
||||
#>
|
||||
|
||||
# Tests file stored separately from actual script
|
||||
# Find where this file is running from, replace parent folder 'Pester' with 'Scripts'
|
||||
$Path = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Pester","Scripts")
|
||||
# Remove the '.Tests.' from the file name
|
||||
$File = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
|
||||
# With changes made to the path, dot-source the function for testing
|
||||
. "$Path\$File"
|
||||
|
||||
Describe 'Get-DatastoreProvisioned' {
|
||||
# Need to create a few example objects to proxy Get-Datastore pipeline input
|
||||
$1 = [PSCustomObject]@{
|
||||
Name = 'iSCSI-spin'
|
||||
CapacityGB = 38.40
|
||||
FreeSpaceGB = 15.55
|
||||
ExtensionData = @{
|
||||
Summary = @{
|
||||
Capacity = 41234567890
|
||||
FreeSpace = 16696685366
|
||||
Uncommitted = 12345678999
|
||||
}}}
|
||||
$2 = [PSCustomObject]@{
|
||||
Name = 'iSCSI-ssd'
|
||||
CapacityGB = 51.74
|
||||
FreeSpaceGB = 10.35
|
||||
ExtensionData = @{
|
||||
Summary = @{
|
||||
Capacity = 55555555555
|
||||
FreeSpace = 11111111111
|
||||
Uncommitted = 23456765432
|
||||
}}}
|
||||
$3 = [PSCustomObject]@{
|
||||
Name = 'FC-ssd'
|
||||
CapacityGB = 10.35
|
||||
FreeSpaceGB = 4.14
|
||||
ExtensionData = @{
|
||||
Summary = @{
|
||||
Capacity = 11111111111
|
||||
FreeSpace = 4444444444
|
||||
Uncommitted = 2222222222
|
||||
}}}
|
||||
|
||||
It "Doesn't change existing functionality" {
|
||||
$StillWorks = $1,$2,$3 | Get-DatastoreProvisioned
|
||||
$StillWorks | Should Not BeNullOrEmpty
|
||||
($StillWorks | Measure-Object).Count | Should Be 3
|
||||
($StillWorks | Get-Member -MemberType NoteProperty).Count | Should Be 6
|
||||
'Name','FreeSpaceGB','CapacityGB','ProvisionedGB','UsedPct','ProvisionedPct' | ForEach-Object {
|
||||
($StillWorks | Get-Member -MemberType NoteProperty).Name -contains $_ | Should Be $true
|
||||
}
|
||||
}
|
||||
|
||||
It 'Still calculates correctly' {
|
||||
$calc = $1 | Get-DatastoreProvisioned
|
||||
$calc | Should Not BeNullOrEmpty
|
||||
$calc.ProvisionedGB | Should Be 34.35
|
||||
$calc.UsedPct | Should Be 59.51
|
||||
$calc.ProvisionedPct | Should Be 89.45
|
||||
}
|
||||
|
||||
# Get-Datastore | Get-DatastoreProvisioned | Format-Table -AutoSize
|
||||
It 'Follows Help Example 1' {
|
||||
$Help1 = $1,$2,$3 | Get-DatastoreProvisioned
|
||||
$Help1 | Should Not BeNullOrEmpty
|
||||
($Help1 | Measure-Object).Count | Should Be 3
|
||||
# not testing Format-Table
|
||||
}
|
||||
|
||||
# Get-Datastore -Name '*ssd' | Get-DatastoreProvisioned | Where-Object ProvisionedPct -ge 100
|
||||
It 'Follows Help Example 2' {
|
||||
$Help2 = $1,$2,$3 | Where Name -like '*ssd' | Get-DatastoreProvisioned | Where ProvisionedPct -ge 100
|
||||
$Help2 | Should Not BeNullOrEmpty
|
||||
($Help2 | Measure-Object).Count | Should Be 1
|
||||
$Help2.Name | Should BeExactly 'iSCSI-ssd'
|
||||
$Help2.ProvisionedPct | Should BeGreaterThan 100
|
||||
}
|
||||
}
|
||||
44
Pester/Test Connection to VC.ps1
Normal file
44
Pester/Test Connection to VC.ps1
Normal file
@@ -0,0 +1,44 @@
|
||||
<#
|
||||
Script name: Test Connection to VC.ps1
|
||||
Created on: 07/15/2016
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection and disconnection can be made to a vCenter
|
||||
Dependencies: Pester Module
|
||||
Example run:
|
||||
|
||||
Invoke-Pester -Script @{ Path = '.\Test Connection to VC.ps1'; Parameters = @{ VCNAME="VC01.local"; VCUSER="Administrator@vsphere.local"; VCPASS="Admin!23"} }
|
||||
|
||||
#>
|
||||
|
||||
$VCUSER = $Parameters.Get_Item("VCUSER")
|
||||
$VCPASS = $Parameters.Get_Item("VCPASS")
|
||||
$VCNAME = $Parameters.Get_Item("VCNAME")
|
||||
|
||||
Describe "PowerCLI Tests" {
|
||||
It "Importing PowerCLI Modules" {
|
||||
Get-Module VMware* | Foreach {
|
||||
Write-Host "Importing Module $($_.name) Version $($_.Version)"
|
||||
$_ | Import-Module
|
||||
Get-Module $_ | Should Be $true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Connect-VIServer Tests" {
|
||||
|
||||
$connection = Connect-VIServer $VCName -User $VCUser -password $VCPass
|
||||
It "Connection is active" {
|
||||
$Global:DefaultVIServer[0].isconnected | Should Be $true
|
||||
}
|
||||
|
||||
It "Checking connected server name is $VCName" {
|
||||
$Global:DefaultVIServer[0].name | Should Be $VCName
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Disconnect-VIServer Tests" {
|
||||
It "Disconnect from $VCName" {
|
||||
Disconnect-VIServer $VCName -confirm:$false
|
||||
$Global:DefaultVIServer | Should Be $null
|
||||
}
|
||||
}
|
||||
200
README.md
200
README.md
@@ -1,42 +1,192 @@
|
||||
# PowerCLI-Example-Scripts
|
||||
VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT
|
||||
# PowerCLI Community Repository
|
||||
## Principles of Operations
|
||||
## Table of Contents
|
||||
* [Abstract](https://github.com/vmware/PowerCLI-Example-Scripts#abstract)
|
||||
* [Table of Contents](https://github.com/vmware/PowerCLI-Example-Scripts#table-of-contents)
|
||||
* [Content Restrictions](https://github.com/vmware/PowerCLI-Example-Scripts#content-restrictions)
|
||||
* [Type of Content](https://github.com/vmware/PowerCLI-Example-Scripts#type-of-content)
|
||||
* [Getting Started](https://github.com/vmware/PowerCLI-Example-Scripts#getting-started)
|
||||
* [Accessing the Repository](https://github.com/vmware/PowerCLI-Example-Scripts#accessing-the-repository)
|
||||
* [Adding Resources](https://github.com/vmware/PowerCLI-Example-Scripts#adding-resources)
|
||||
* [Meta Information](https://github.com/vmware/PowerCLI-Example-Scripts#meta-information)
|
||||
* [Required Information](https://github.com/vmware/PowerCLI-Example-Scripts#required-information)
|
||||
* [Suggested Information](https://github.com/vmware/PowerCLI-Example-Scripts#suggested-information)
|
||||
* [Suggested Quality Management](https://github.com/vmware/PowerCLI-Example-Scripts#suggested-quality-management)
|
||||
* [General Best Practices](https://github.com/vmware/PowerCLI-Example-Scripts#general-best-practices)
|
||||
* [Alias Usage](https://github.com/vmware/PowerCLI-Example-Scripts#alias-usage)
|
||||
* [Scripts](https://github.com/vmware/PowerCLI-Example-Scripts#scripts)
|
||||
* [Modules](https://github.com/vmware/PowerCLI-Example-Scripts#modules)
|
||||
* [Help Information](https://github.com/vmware/PowerCLI-Example-Scripts#help-information)
|
||||
* [Security](https://github.com/vmware/PowerCLI-Example-Scripts#security)
|
||||
* [Resource Maintenance](https://github.com/vmware/PowerCLI-Example-Scripts#resource-maintenance)
|
||||
* [Maintenance Ownership](https://github.com/vmware/PowerCLI-Example-Scripts#maintenance-ownership)
|
||||
* [Filing issues](https://github.com/vmware/PowerCLI-Example-Scripts#filing-isssues)
|
||||
* [Resolving issues](https://github.com/vmware/PowerCLI-Example-Scripts#resolving-issues)
|
||||
* [Additional Resources](https://github.com/vmware/PowerCLI-Example-Scripts#additional-resources)
|
||||
* [Discussions](https://github.com/vmware/PowerCLI-Example-Scripts#discussions)
|
||||
* [VMware Sample Exchange](https://github.com/vmware/PowerCLI-Example-Scripts#vmware-sample-exchange)
|
||||
* [VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT](https://github.com/vmware/PowerCLI-Example-Scripts#vmware-technology-preview-license-agreement)
|
||||
|
||||
Notice to User: This Technology Preview License Agreement (the “Agreement”) is a CONTRACT between you (either an individual or a single entity) (“you” or “Licensee”) and VMware, Inc. (“VMware”), which covers your use of the Technology Preview Software (as defined below). If you do not agree to the terms of this Agreement, then do not install or use the Technology Preview Software. By explicitly accepting this Agreement, however, or by installing, copying, downloading, accessing, or otherwise using the Technology Preview Software, you are acknowledging and agreeing to be bound by the following terms.
|
||||
## Abstract
|
||||
This document will serve for collaboration to identify the operating principles of a centralized PowerCLI Community Repository on GitHub.
|
||||
|
||||
1. DEFINITIONS. (a) “Technology Preview Software” means the unreleased, concept version of VMware’s software, in object form only, excluding any Open Source Software provided with the such software, and the media and Documentation provided by VMware to Licensee and for which Licensee is granted a use license pursuant to this Agreement. (b) “Documentation” means the printed and online written reference material furnished to Licensee in conjunction with the Technology Preview Software, including, without limitation, instructions, testing guidelines, and end user guides. (c) “Intellectual Property Rights” shall mean all intellectual property rights, including, without limitation, patent, copyright, trademark, and trade secret. (d) “Open Source Software” means various open source software components provided with the Technology Preview Software that are licensed to you under the terms of the applicable license agreements included with such open source software components or other materials for the Technology Preview Software. (e) “Updates” means a modification, error correction, bug fix, new release, or other update to or for the Technology Preview Software.
|
||||
The central PowerCLI repo will be located at: <https://github.com/vmware/PowerCLI-Example-Scripts>
|
||||
## Content Restrictions
|
||||
### Type of Content
|
||||
The repository has been provided to allow the community to share resources that leverage VMware’s PowerCLI. This can include:
|
||||
* Sample Scripts
|
||||
* Modules
|
||||
* DSC Resources
|
||||
* PowerActions scripts
|
||||
* Pester Tests
|
||||
* Tools built with PowerShell
|
||||
|
||||
2. LICENSE GRANT, USE AND OWNERSHIP.
|
||||
## Getting Started
|
||||
### Accessing the Repository
|
||||
#### Downloading the Repository for Local Access
|
||||
1. Load the GitHub repository page: <https://github.com/vmware/PowerCLI-Example-Scripts>
|
||||
2. Click on the green “Clone or Download” button and then click “Download ZIP”
|
||||
3. Once downloaded, extract the zip file to the location of your choosing
|
||||
4. At this point, you now have a local copy of the repository
|
||||
|
||||
(a) Limited License. Subject to the terms and conditions of this Agreement, VMware grants to Licensee a non-exclusive, non-transferable license (without the right to sublicense) (i) to use the Technology Preview Software in accordance with the Documentation solely for purposes of internal testing and evaluation, (ii) to use the Documentation provided with the Technology Preview Software in support of Licensee’s authorized use of the Technology Preview Software, and (iii) to copy the Technology Preview Software for archival or backup purposes, provided that all titles and trademarks, copyright, and restricted rights notices are reproduced on such copies.
|
||||
#### Creating Your Own GitHub Based Access Point
|
||||
1. Login (or signup) to GitHub
|
||||
2. Load the GitHub repository page: <https://github.com/vmware/PowerCLI-Example-Scripts>
|
||||
3. Click on the Fork button, which will create a copy of the repository and place it in the GitHub based location of your choosing.
|
||||
|
||||
(b) Evaluation Feedback. The purpose of this limited license is the testing and evaluation of the Technology Preview Software as set forth above. In furtherance of this purpose, Licensee shall provide feedback to VMware concerning the functionality and performance of the Technology Preview Software from time to time as reasonably requested by VMware, including, without limitation, identifying potential errors and improvements. Licensee will provide the requested feedback in a manner that is convenient to Licensee subject to reasonable availability of Licensee’s personnel. Notwithstanding the foregoing, prior to Licensee disclosing to VMware any information under this Agreement that Licensee considers proprietary or confidential, Licensee shall obtain VMware’s prior written approval to disclose such information to VMware, and without such prior written approval from VMware, Licensee shall not disclose any such information to VMware. VMware may use feedback to improve or enhance its products and, accordingly, you hereby grant to VMware a non-exclusive, perpetual, irrevocable, royalty-free, transferable, worldwide right and license, with the right to sublicense, to use, reproduce, disclose, distribute, perform, display, modify, prepare derivative works of and otherwise exploit the feedback and other information without restriction in any manner now known or in the future conceived and to make, use, sell, offer to sell, import and export any product or service that incorporates the feedback and other information.
|
||||
|
||||
(c) Restrictions. Licensee shall not copy or use the Technology Preview Software (including the Documentation) except as expressly permitted in this Agreement. Except to the extent that any applicable mandatory laws prevent VMware restraining Licensee from doing so, Licensee will not, and will not permit any third party to, sublicense, rent, copy, modify, create derivative works of, translate, reverse engineer, decompile, disassemble, or otherwise reduce to human perceivable form any portion of the Technology Preview Software or accompanying Documentation. Without limiting the generality of the foregoing, Licensee shall not use the Technology Preview Software for Licensee’s product development or any other commercial purpose. The Technology Preview Software and all performance data and test results, including without limitation, benchmark test results (collectively “Performance Data”) relating to the Technology Preview Software are the Confidential Information of VMware, and will be treated in accordance with the terms of Section 4 of this Agreement. Accordingly, Licensee shall not publish or disclose to any third party any Performance Data relating to the Technology Preview Software.
|
||||
### Adding Resources
|
||||
#### GitHub - Copy/Paste Option
|
||||
1. Browse to the appropriate section (example: Scripts)
|
||||
2. Select the “Create new file” button
|
||||
3. On the new page, enter a file name, enter the resource’s information
|
||||
4. Within the “Commit new file” area, enter the title and description, then select “Create a new branch for this commit…” and enter a sensical branch name
|
||||
5. Click “Propose new file”
|
||||
6. On the “Open a pull request” page, click “Create pull request”
|
||||
|
||||
(d) Ownership. VMware shall own and retain all right, title and interest in and to the Intellectual Property Rights in the Technology Preview Software, subject only to the limited license expressly set forth in Section 2(a) hereof. Licensee does not acquire any other rights, express or implied, in the Technology Preview Software. ALL RIGHTS NOT EXPRESSLY GRANTED HEREUNDER ARE RESERVED TO VMWARE.
|
||||
|
||||
(e) No Support Services. VMware is under no obligation to support the Technology Preview Software in any way or to provide any Updates to Licensee. In the event VMware, in its sole discretion, supplies any Update to Licensee, the Update shall be deemed Technology Preview Software under this Agreement and shall be subject to the terms and conditions of this Agreement.
|
||||
#### GitHub - Upload files Option
|
||||
1. Browse to the appropriate section (example: Modules)
|
||||
2. Select the “Upload files” button
|
||||
3. On the new page, drag or choose the files to add
|
||||
4. Within the “Commit changes” area, enter the title and description, then select “Create a new branch for this commit…” and enter a sensical branch name
|
||||
5. Click “Propose new file”
|
||||
6. On the “Open a pull request” page, click “Create pull request”
|
||||
|
||||
(f) Third-Party Software. The Technology Preview Software may enable a computer to run multiple instances of third-party guest operating systems and application programs. Licensee acknowledges that Licensee is responsible for obtaining any licenses necessary to operate any third-party software, including guest operating systems and application programs.
|
||||
|
||||
(g) Open Source Software. Except for Sections 5, 6 and 7, the terms and conditions of this Agreement shall not apply to any Open Source Software accompanying the Technology Preview Software. Any such Open Source Software is provided under the terms of the open source license agreement or copyright notice accompanying such Open Source Software or in the open source licenses file accompanying the Technology Preview Software.
|
||||
|
||||
3. TERM AND TERMINATION. Licensee’s rights with respect to the Technology Preview Software will terminate upon the earlier of (a) automatic expiration of the Technology Preview Software based on the system date, or (b) termination by VMware, in its sole discretion, of Licensee’s rights with respect to the Technology Preview Software provided under this Agreement upon notice on the VMware website. Upon any expiration or termination of rights with respect to the Technology Preview Software under this Agreement, the rights and licenses granted to Licensee under this Agreement shall immediately terminate, and Licensee shall immediately cease using, and will destroy or render practically inaccessible the Technology Preview Software, Documentation, and all other tangible items in Licensee’s possession or control that contain Confidential Information. The rights and obligations of the parties set forth in Sections 2(b), 2(c), 2(d), 2(e), 2(f), 2(g), 3, 4, 5, 6 and 7 shall survive termination or expiration of this Agreement for any reason.
|
||||
## Meta Information
|
||||
This section will provide guidance on information which should be included with each submitted PowerCLI resource. Information listed in the Suggested Information will not be required for commit of a pull request to the repo, but will certainly increase ease of use for users of the resource.
|
||||
### Required Information
|
||||
The following information must be included with each submitted scripting resource. Please include the information in the appropriate location based upon the submitted scripting resource.
|
||||
|
||||
4. CONFIDENTIALITY. (a) Confidentiality. "Confidential Information" means the Technology Preview Software, all information regarding the Technology Preview Software (including any trade secrets, know-how, inventions, techniques, processes, and algorithms embodied in the Technology Preview Software), Documentation, Performance Data, any Updates, and other information provided by VMware to Licensee under this Agreement, whether disclosed orally, in writing, or by examination or inspection, other than information that Licensee can demonstrate (i) was already known to Licensee, other than under an obligation of confidentiality, at the time of disclosure; (ii) was generally available in the public domain at the time of disclosure to Licensee; (iii) became generally available in the public domain after disclosure other than through any act or omission of Licensee; (iv) was subsequently lawfully disclosed to Licensee by a third party without any obligation of confidentiality; or (v) was independently developed by Licensee without use of or reference to any information or materials disclosed by VMware or its suppliers. If Licensee is required to disclose Confidential Information by applicable law or court order, Licensee shall notify VMware of the required disclosure promptly in writing and shall cooperate with VMware in any lawful action to contest or limit the scope of the required disclosure. Confidential Information shall include, without limitation, any information relating to VMware products, product roadmaps, and other technical, business, financial and product development plans, forecasts and strategies. Licensee shall not use any Confidential Information for any purpose other than as expressly authorized under this Agreement. In no event shall Licensee use the Technology Preview Software or any Confidential Information to develop, manufacture, market, sell, or distribute any product or service, including any VMware products. Licensee shall not disclose any Confidential Information to any third party. Without limiting the foregoing, Licensee shall use at least the same degree of care that it uses to prevent the disclosure of its own confidential information of like importance, but in no event less than reasonable care, to prevent the disclosure of such Confidential Information. (b) Additional Confidentiality Restrictions for Highly Confidential Technology Preview Software. For certain Technology Preview Software designated by VMware as highly confidential (“Highly Confidential Technology Preview Software”) in VMware’s correspondence to you regarding this Technology Preview Software or in any Documentation, additional heightened confidentiality restrictions designated below will apply. (i) Licensee shall limit dissemination of Highly Confidential Technology Preview Software and related information concerning product features, future technologies and roadmaps only to Information Technology teams and/or software/solutions development teams of Licensee designated by VMware, and only to individuals on those teams who have a need to know the Confidential Information for purposes expressly authorized under this Agreement. For clarity and without limiting the generality of the foregoing, Licensee shall not disseminate any Highly Confidential Technology Preview Software to Licensee's sales and marketing field organizations. Licensee will assign an employee who will be primarily responsible (“Primary Contact”) for ensuring that the terms of this Agreement are complied with. (ii) Licensee acknowledges that damages for improper disclosure of Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps may be irreparable and that monetary damages would be inadequate to compensate VMware for any breach of this Agreement. In the event that VMware reasonably believes that Licensee has disseminated certain of such Highly Confidential Technology Preview Software or related information concerning product features, future technologies and roadmaps to an unauthorized party, Licensee will be immediately removed from VMware’s Technology Preview Software program and will not be permitted to participate in any VMware Technology Preview Software program in the future. Additionally, all rights and licenses granted to Licensee under this Agreement shall immediately terminate in accordance with Section 3 herein (Term and Termination). (c) Remedies. In addition to all other remedies available in law or otherwise, VMware is entitled to seek equitable relief, including injunctive relief, against the threatened breach of this Agreement or the continuation of any such breach.
|
||||
* Author Name
|
||||
* This can include full name, Twitter profile, or other identifiable piece of information that would allow interested parties to contact author with questions.
|
||||
* Date
|
||||
* Date the resource was written
|
||||
* Minimal/High Level Description
|
||||
* What does the resource do
|
||||
* Any KNOWN limitations or dependencies
|
||||
* vSphere version, required modules, etc.
|
||||
|
||||
5. LIMITATION OF LIABILITY. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE IS PROVIDED WITHOUT CHARGE FOR LIMITED EVALUATION PURPOSES. ACCORDINGLY, THE TOTAL LIABILITY OF VMWARE AND ITS LICENSORS ARISING OUT OF OR RELATED TO THIS AGREEMENT SHALL NOT EXCEED US$100.00. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT SHALL VMWARE OR ITS LICENSORS HAVE LIABILITY FOR ANY INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, OR CONSEQUENTIAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY (INCLUDING WITHOUT LIMITATION, TORT, STATUTE, CONTRACT OR OTHER), EVEN IF VMWARE AND ITS LICENSORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
|
||||
#### Note Placement Examples:
|
||||
Script: Top few lines
|
||||
Module: Module manifest
|
||||
|
||||
#### Required Script Note Example:
|
||||
`<#`
|
||||
`Script name: script_name.ps1`
|
||||
`Created on: 07/07/2016`
|
||||
`Author: Author Name, @TwitterHandle`
|
||||
`Description: The purpose of the script is to …`
|
||||
`Dependencies: None known`
|
||||
`#>`
|
||||
|
||||
6. WARRANTY DISCLAIMER. IT IS UNDERSTOOD THAT THE TECHNOLOGY PREVIEW SOFTWARE, OPEN SOURCE SOFTWARE, DOCUMENTATION, AND ANY UPDATES MAY CONTAIN ERRORS AND ARE PROVIDED FOR LIMITED EVALUATION ONLY. THE TECHNOLOGY PREVIEW SOFTWARE, THE OPEN SOURCE SOFTWARE, THE DOCUMENTATION, AND ANY UPDATES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE. VMWARE AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. Licensee acknowledges that VMware has not publicly announced the availability of the Technology Preview Software, that such Technology Preview Software may contain features currently under development, that VMware has not promised or guaranteed to Licensee that such Technology Preview Software will be announced or made available to anyone in the future, that VMware has no express or implied obligation to Licensee to announce or introduce the Technology Preview Software, that VMware has no obligation to introduce a product similar to or compatible with the Technology Preview Software, and that any version number (if any) referenced is subject to change and does not in any way represent VMware’s commitment to release any product in the future. Accordingly, Licensee acknowledges that any research or development that it performs regarding the Technology Preview Software or any product associated with the Technology Preview Software is done entirely at Licensee’s own risk. Specifically, the Technology Preview Software may contain features, functionality or modules that will not be included in the production version of the Technology Preview Software, if released, or that will be marketed separately for additional fees.
|
||||
### Suggested Information
|
||||
The following information should be included when possible. Inclusion of information provides valuable information to consumers of the resource.
|
||||
* vSphere version against which the script was developed/tested
|
||||
* PowerCLI build against which the script was developed/tested
|
||||
* PowerShell version against which the script was developed/tested
|
||||
* OS platform version against which the script was tested/developed
|
||||
* Keywords that make it easier to find a script, for example: VDS, health check
|
||||
|
||||
7. OTHER PROVISIONS. (a) Governing Law. This Agreement, and all disputes arising out of or related thereto, shall be governed by and construed under the laws of the State of California without reference to conflict of laws principles. All such disputes shall be subject to the exclusive jurisdiction of the state and federal courts located in Santa Clara County, California, and the parties agree and submit to the personal and exclusive jurisdiction and venue of these courts. The United Nations Convention for the International Sale of Goods shall not apply. (b) Export Control. The Technology Preview Software is of United States origin and is provided subject to the U.S. Export Administration Regulations. Diversion contrary to U.S. law is prohibited. Without limiting the foregoing, you agree that (i) you are not, and are not acting on behalf of, any person who is a citizen, national, or resident of, or who is controlled by the government of, Cuba, Iran, North Korea, Sudan, or Syria, or any other country to which the United States has prohibited export transactions; (ii) you are not, and are not acting on behalf of, any person or entity listed on the U.S. Treasury Department list of Specially Designated Nationals and Blocked Persons, or the U.S. Commerce Department Denied Persons List or Entity List; and (iii) you will not use the Technology Preview Software for, and will not permit the Technology Preview Software to be used for, any purposes prohibited by law, including, without limitation, for any prohibited development, design, manufacture or production of missiles or nuclear, chemical or biological weapons. U.S. Export Control Classification Numbers (ECCN’s) may be found at VMware help page: http://www.vmware.com/help/export-control. (c) Modification. This is the entire agreement between the parties relating to the subject matter hereof and all other terms are rejected. No waiver or modification of this Agreement shall be valid unless in writing signed by each party. The waiver of a breach of any term hereof shall in no way be construed as a waiver of any other term or breach hereof. If any provision of this Agreement is held by a court of competent jurisdiction to be contrary to law, the remaining provisions of this Agreement shall remain in full force and effect. (d) Data Privacy. Licensee agrees that VMware may process technical and related usage information about Licensee’s use of the Technology Preview Software for statistical and analytical purposes. Usage information is collected strictly for internal statistical and analytical purposes for the development of VMware products and services. Licensee understands that any log files generated in order to obtain support from VMware may contain sensitive, confidential or personal information. Licensee should consider obfuscating any logs before sending them to VMware. VMware’s privacy policy (http://www.vmware.com/help/privacy.html) shall apply.
|
||||
#### Suggested Script Note Example:
|
||||
`<#`
|
||||
`Script name: script_name.ps1`
|
||||
`Created on: 07/07/2016`
|
||||
`Author: Author Name, @TwitterHandle`
|
||||
`Description: The purpose of the script is to …`
|
||||
`Dependencies: None known`
|
||||
|
||||
8. ASSIGNMENT. Licensee shall not assign this Agreement or any rights or obligations hereunder, directly or indirectly, by operation of law, merger, acquisition of stock or assets, or otherwise, without the prior written consent of VMware. Any attempted assignment or transfer in violation of the foregoing will be null and void. Subject to the foregoing, this Agreement shall inure to the benefit of and be binding upon the parties and their respective successors and permitted assigns.
|
||||
`===Tested Against Environment====`
|
||||
`vSphere Version: 6.0`
|
||||
`PowerCLI Version: PowerCLI 6.3 R1`
|
||||
`PowerShell Version: 5.0`
|
||||
`OS Version: Windows 10`
|
||||
`Keyword: VM`
|
||||
`#>`
|
||||
|
||||
9. CONTACT INFORMATION. If you have any questions about this Agreement, please direct all correspondence to: VMware, Inc., 3401 Hillview Avenue, Palo Alto, CA 94304, United States of America or email info@vmware.com. VMware is a trademark of VMware, Inc. and is registered in the U.S. and numerous other countries.
|
||||
## Suggested Quality Management
|
||||
This section describes guidelines put in place to maintain a standard of quality while also promoting broader contribution.
|
||||
### General Best Practices
|
||||
### Resource Naming
|
||||
* Give the resource a name that is indicitive of the actions and/or results of its running
|
||||
|
||||
Rev. 2014Mar10
|
||||
|
||||
### Fault Handling
|
||||
* Read and apply the following basic fault handling where applicable: Microsoft’s Hey, Scripting Guy! Blog: https://blogs.technet.microsoft.com/heyscriptingguy/2014/07/09/handling-errors-the-powershell-way/
|
||||
|
||||
### Alias Usage
|
||||
* Avoid any alias usage within all submitted resources.
|
||||
|
||||
### Global Variable Usage
|
||||
* Avoid changing any global variables
|
||||
|
||||
### Help Information
|
||||
* All resources should have inline documentation.
|
||||
|
||||
### Scripts
|
||||
* The script should be easy to read and understand
|
||||
* Place user-defined variables towards the top of the script
|
||||
|
||||
### Modules
|
||||
* The module file, PSM1, should contain only functions. A module manifest file, PSD1, should also be created and included. A module formatting file (format.ps1xml) is desirable but not a requirement.
|
||||
* Use only standard verbs
|
||||
|
||||
### Security
|
||||
* Usage of PowerShell’s strict mode is preferred, but not required.
|
||||
* Remove any information related to one’s own environment (examples: Passwords, DNS/IP Addresses, custom user credentials, etc)
|
||||
|
||||
## Resource Maintenance
|
||||
### Maintenance Ownership
|
||||
Ownership of any and all submitted resources are maintained by the submitter. This ownership also includes maintenance of any and all submitted resources.
|
||||
### Filing Issues
|
||||
Any bugs or other issues should be filed within GitHub by way of the repository’s Issue Tracker.
|
||||
### Resolving Issues
|
||||
Any community member can resolve issues within the repository, however only the owner or a board member can approve the update. Once approved, assuming the resolution involves a pull request, only a board member will be able to merge and close the request.
|
||||
|
||||
## Additional Resources
|
||||
### Discussions
|
||||
Join in on the discussion within the VMware Code Slack team's PowerCLI channel: <https://code.vmware.com/slack/>
|
||||
### VMware Sample Exchange
|
||||
It is highly recommened to add any and all submitted resources to the VMware Sample Exchange: <https://developercenter.vmware.com/samples>
|
||||
|
||||
Sample Exchange can be allowed to access your GitHub resources, by way of a linking process, where they can be indexed and searched by the community. There are VMware social media accounts which will advertise resources posted to the site and there's no additional accounts needed, as the VMware Sample Exchange uses MyVMware credentials.
|
||||
|
||||
## VMWARE TECHNOLOGY PREVIEW LICENSE AGREEMENT
|
||||
The VMware Technnology Preview License Agreement: <https://github.com/vmware/PowerCLI-Example-Scripts/blob/master/LICENSE.md>
|
||||
|
||||
# Repository Administrator Resources
|
||||
## Table of Contents
|
||||
* Board Members
|
||||
* Approval of Additions
|
||||
|
||||
## Board Members
|
||||
|
||||
Board members are volunteers from the PowerCLI community and VMware staff members, board members are not held responsible for any issues which may occur from running of scripts inside this repository.
|
||||
|
||||
Members:
|
||||
* Josh Atwell (Community Member)
|
||||
* Luc Dekens (Community Member)
|
||||
* Jonathan Medd (Community Member)
|
||||
* Alan Renouf (VMware)
|
||||
* Kyle Ruddy (VMware)
|
||||
* Rynardt Spies (Community Member)
|
||||
|
||||
## Approval of Additions
|
||||
Items added to the repository, including items from the Board members, require 2 votes from the board members before being added to the repository. The approving members will have ideally downloaded and tested the item. When two “Approved for Merge” comments are added from board members, the pull can then be committed to the repository.
|
||||
|
||||
67
Scripts/Get-DatastoreProvisioned.ps1
Normal file
67
Scripts/Get-DatastoreProvisioned.ps1
Normal file
@@ -0,0 +1,67 @@
|
||||
<#
|
||||
Script name: Get-DatastoreProvisioned.ps1
|
||||
Created on: 2016/07/27
|
||||
Author: Brian Bunke, @brianbunke
|
||||
Description: Augments Get-Datastore with thin provisioned info
|
||||
Note to future contributors: Test changes with Pester file Get-DatastoreProvisioned.Tests.ps1
|
||||
|
||||
===Tested Against Environment====
|
||||
vSphere Version: 6.0 U1/U2
|
||||
PowerCLI Version: PowerCLI 6.3 R1
|
||||
PowerShell Version: 5.0
|
||||
OS Version: Windows 7/10
|
||||
#>
|
||||
|
||||
function Get-DatastoreProvisioned {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Retrieve the total thin provisioned space on each datastore.
|
||||
|
||||
.DESCRIPTION
|
||||
Intended to reveal provisioned space alongside total/free space, to assist with svMotion decisions.
|
||||
-Name should be supplied from the pipeline via Get-Datastore.
|
||||
|
||||
.EXAMPLE
|
||||
Get-Datastore | Get-DatastoreProvisioned | Format-Table -AutoSize
|
||||
View all datastores and view their capacity statistics in the current console.
|
||||
|
||||
.EXAMPLE
|
||||
Get-Datastore -Name '*ssd' | Get-DatastoreProvisioned | Where-Object -Property ProvisionedPct -ge 100
|
||||
For all datastores ending in 'ssd', return the capacity stats of those at least 100% provisioned.
|
||||
|
||||
.INPUTS
|
||||
[VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl]
|
||||
Object type supplied by PowerCLI function Get-Datastore
|
||||
|
||||
.LINK
|
||||
https://github.com/vmware/PowerCLI-Example-Scripts
|
||||
|
||||
.LINK
|
||||
https://twitter.com/brianbunke
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param (
|
||||
# Specifies the datastore names to check. Tested only with pipeline input (see examples).
|
||||
[Parameter(ValueFromPipeline = $true)]
|
||||
$Name
|
||||
)
|
||||
|
||||
PROCESS {
|
||||
ForEach ($DS in $Name) {
|
||||
# Calculate total provisioned space from the exposed properties
|
||||
$Provisioned = ($DS.ExtensionData.Summary.Capacity -
|
||||
$DS.ExtensionData.Summary.FreeSpace +
|
||||
$DS.ExtensionData.Summary.Uncommitted) / 1GB
|
||||
|
||||
# Return info, wrapping it in the Math.Round method to trim to two decimal places
|
||||
[PSCustomObject]@{
|
||||
Name = $DS.Name
|
||||
FreeSpaceGB = [math]::Round($DS.FreeSpaceGB, 2)
|
||||
CapacityGB = [math]::Round($DS.CapacityGB, 2)
|
||||
ProvisionedGB = [math]::Round($Provisioned, 2)
|
||||
UsedPct = [math]::Round((($DS.CapacityGB - $DS.FreeSpaceGB) / $DS.CapacityGB) * 100, 2)
|
||||
ProvisionedPct = [math]::Round(($Provisioned / $DS.CapacityGB) * 100, 2)
|
||||
} #pscustomobject
|
||||
} #foreach
|
||||
} #process
|
||||
} #function
|
||||
41
Scripts/Get-VMID.ps1
Normal file
41
Scripts/Get-VMID.ps1
Normal file
@@ -0,0 +1,41 @@
|
||||
function Get-VMID {
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created by: Markus Kraus
|
||||
Organization: Private
|
||||
Personal Blog: mycloudrevolution.com
|
||||
Twitter: @vMarkus_K
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
This will quickly return all IDs of VMs
|
||||
.Example
|
||||
Get-VMID -myVMs (Get-VM) | ft
|
||||
.Example
|
||||
$SampleVMs = Get-VM "tst*"
|
||||
Get-VMID -myVMs $SampleVMs
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true,
|
||||
ValueFromPipeline=$True,
|
||||
Position=0)]
|
||||
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]
|
||||
$myVMs
|
||||
)
|
||||
Process {
|
||||
|
||||
$MyView = @()
|
||||
ForEach ($myVM in $myVMs){
|
||||
$UUIDReport = [PSCustomObject] @{
|
||||
Name = $myVM.name
|
||||
UUID = $myVM.extensiondata.Config.UUID
|
||||
InstanceUUID = $myVM.extensiondata.config.InstanceUUID
|
||||
LocationID = $myVM.extensiondata.config.LocationId
|
||||
MoRef = $myVM.extensiondata.Moref.Value
|
||||
}
|
||||
$MyView += $UUIDReport
|
||||
}
|
||||
$MyView
|
||||
}
|
||||
}
|
||||
113
Scripts/Sysprep_Automation_Script.ps1
Normal file
113
Scripts/Sysprep_Automation_Script.ps1
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
<#==================================================
|
||||
Generated On: 6/27/2014 2:49 PM
|
||||
Generated By: Brian Graf
|
||||
VMware Technical Marketing Engineer - Automation
|
||||
Organization: VMware
|
||||
vCenter Sysprep File Transfer
|
||||
==================================================
|
||||
--------------------------------------------------
|
||||
==================USAGE===========================
|
||||
This script has been created to aid users who
|
||||
upload multiple sysprep files to vCenter Server.
|
||||
The upload button in vCenter only allows a single
|
||||
file per upload. This script will allow the user
|
||||
to upload as many files as they please.
|
||||
--------------------------------------------------
|
||||
===============REQUIREMENTS=======================
|
||||
Fill in the environment variables below. There
|
||||
Is a $DefaultVIServer and a $target_vcenter.
|
||||
This is because some customers may be running
|
||||
their target vCenter server within a different
|
||||
vCenter environment.
|
||||
|
||||
On your local machine, you will need a directory
|
||||
that includes the following folders:
|
||||
* 2k
|
||||
* svr2003-64
|
||||
* svr2003
|
||||
* xp
|
||||
* 1.1
|
||||
* xp-64
|
||||
|
||||
Place all sysprep files within their respective
|
||||
folders.
|
||||
|
||||
Run the script. The script will determine if
|
||||
the target_vCenter is a Windows VM or VCSA
|
||||
and place the files accordingly.
|
||||
|
||||
***NOTE*** This script will give an error if
|
||||
it tries to upload a filename that already exists
|
||||
in the vCenter directory. If you wish for the
|
||||
script to overwrite any file with the same name
|
||||
add '-force' to the end of the copy-vmguestfile
|
||||
command.
|
||||
--------------------------------------------------
|
||||
#>
|
||||
|
||||
# ----------------------------------------
|
||||
# USER CONFIGURATION - EDIT AS NEEDED
|
||||
# ----------------------------------------
|
||||
$DefaultVIServer = "vcsa.lab.local"
|
||||
$vCUser = "root"
|
||||
$vCPass = "VMware1!"
|
||||
$target_vcenter = "VCSA"
|
||||
$target_vcenter_user = "root"
|
||||
$target_vcenter_password = "VMware1!"
|
||||
$Location = "C:\temp"
|
||||
$vC_Partition = "C:"
|
||||
# ----------------------------------------
|
||||
# END USER CONFIGURATION
|
||||
# ----------------------------------------
|
||||
|
||||
# Sysprep Folders on vCenter
|
||||
$folders = @("2k","svr2003-64","svr2003","xp","1.1","xp-64")
|
||||
|
||||
# Add PowerCLI Snapin
|
||||
Add-PSSnapin vmware.vimautomation.core
|
||||
|
||||
# Connect to vCenter
|
||||
connect-viserver $DefaultVIServer -user $vCUser -password $vCPass
|
||||
|
||||
# Get view of the vCenter data
|
||||
$myVC= get-vm $target_vcenter | get-view
|
||||
|
||||
# $OS captures the Operating System Name
|
||||
$OS = $myVC.config.GuestFullName
|
||||
|
||||
# Switch of Operating System
|
||||
switch -wildcard ($OS)
|
||||
{
|
||||
# As per the compatibility guide, all OS's from the compatibility guide have been added
|
||||
"*SUSE*" {Write-Host "This is a SUSE Machine" -ForegroundColor Green; $OS = "VCSA"}
|
||||
"* XP *" {Write-Host "This is a Windows XP Machine" -ForegroundColor Green}
|
||||
"* 2003 *" {Write-Host "This is a Windows Server 2003 Machine" -ForegroundColor Green}
|
||||
"* 2008 *" {Write-Host "This is a Windows Server 2008 Machine" -ForegroundColor Green}
|
||||
"* 2012 *" {Write-Host "This is a Windows Server 2012 Machine" -ForegroundColor Green}
|
||||
Default {Write-Host "This is the default" -ForegroundColor Green}
|
||||
}
|
||||
Write-Host ""
|
||||
|
||||
# If Location is not set, ask user to input location
|
||||
if ($Location -eq ""){
|
||||
$Location = Read-Host "Where is the sysprep file located? (ex. c:\temp) "
|
||||
}
|
||||
|
||||
# Cycle through Sysprep Folders on local machine
|
||||
foreach($folder in $folders){
|
||||
if ($OS -eq "VCSA"){$Destination = "/etc/vmware-vpx/sysprep/$folder"} else {$Destination = "$vC_Partition\ProgramData\VMware\VMware VirtualCenter\Sysprep\$folder"}
|
||||
|
||||
# Get files from each folder
|
||||
Get-ChildItem "$($Location)\$($folder)" -ErrorAction SilentlyContinue | ForEach-Object {
|
||||
$source = "$($Location)\$($folder)\$_"
|
||||
|
||||
Write-Host "Transferring File `"$_`" " -ForegroundColor Green #Source = $source" -ForegroundColor Green
|
||||
Write-Host "Destination = $Destination" -ForegroundColor Green
|
||||
|
||||
# Copy Files to vCenter Sysprep folders
|
||||
Copy-vmguestfile -source "$source" -Destination "$Destination" -VM "$target_vcenter" -LocalToGuest -GuestUser "$target_vcenter_user" -GuestPassword "$target_vcenter_password"
|
||||
|
||||
}
|
||||
}
|
||||
Disconnect-viServer -confirm:$false
|
||||
Binary file not shown.
116
Scripts/vRealize Operations Maintenance Mode.ps1
Normal file
116
Scripts/vRealize Operations Maintenance Mode.ps1
Normal file
@@ -0,0 +1,116 @@
|
||||
Connect-VIServer vc-l-01a.corp.local -User administrator@vsphere.local -Password VMware1!
|
||||
Connect-OMServer vrops.corp1.local -User admin -Password VMware1!
|
||||
|
||||
function Enable-OMMaintenance {
|
||||
<#
|
||||
.NOTES
|
||||
Script name: vRealize Operations Maintenance Mode.ps1
|
||||
Created on: 07/26/2016
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Dependencies: PowerCLI 6.0 R2 or later
|
||||
.DESCRIPTION
|
||||
Places a vSphere Inventory object into maintenance mode in vRealize Operations
|
||||
.Example
|
||||
Set All VMs with a name as backup as being in maintenance mode for 20 minutes:
|
||||
|
||||
Get-VM backup* | Enable-OMMaintenance -MaintenanceTime 20
|
||||
|
||||
Name Health ResourceKind Description
|
||||
---- ------ ------------ -----------
|
||||
backup-089e13fd-7d7a-0 Grey VirtualMachine
|
||||
backup-d90e0b39-2618-0 Grey VirtualMachine
|
||||
backup-e48ca842-316a-0 Grey VirtualMachine
|
||||
backup-77da3713-919a-0 Grey VirtualMachine
|
||||
backup-c32f4da8-86c4-0 Grey VirtualMachine
|
||||
backup-c3fcb95c-cfe2-0 Grey VirtualMachine
|
||||
backup-4318bb1e-614a-0 Grey VirtualMachine
|
||||
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.String]
|
||||
$Resource,
|
||||
|
||||
[Parameter(Position=1, Mandatory=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[Int]
|
||||
$MaintenanceTime
|
||||
)
|
||||
process {
|
||||
Foreach ($Entry in $resource) {
|
||||
$Item = Get-Inventory -Name $Entry | Get-OMResource
|
||||
if (-not $Item) {
|
||||
throw "$Entry not found"
|
||||
} Else {
|
||||
$Item.ExtensionData.MarkResourceAsBeingMaintained($MaintenanceTime)
|
||||
Get-Inventory -Name $Entry | Get-OMResource
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Disable-OMMaintenance {
|
||||
<#
|
||||
.NOTES
|
||||
Script name: vRealize Operations Maintenance Mode.ps1
|
||||
Created on: 07/26/2016
|
||||
Author: Alan Renouf, @alanrenouf
|
||||
Dependencies: PowerCLI 6.0 R2 or later
|
||||
.DESCRIPTION
|
||||
Removes a vSphere Inventory object from maintenance mode in vRealize Operations
|
||||
.Example
|
||||
Disable maintenance mode for all VMs with a name of backup
|
||||
|
||||
Get-VM backup* | Disable-OMMaintenance
|
||||
|
||||
Name Health ResourceKind Description
|
||||
---- ------ ------------ -----------
|
||||
backup-089e13fd-7d7a-0 Grey VirtualMachine
|
||||
backup-d90e0b39-2618-0 Grey VirtualMachine
|
||||
backup-e48ca842-316a-0 Grey VirtualMachine
|
||||
backup-77da3713-919a-0 Grey VirtualMachine
|
||||
backup-c32f4da8-86c4-0 Yellow VirtualMachine
|
||||
backup-c3fcb95c-cfe2-0 Yellow VirtualMachine
|
||||
backup-4318bb1e-614a-0 Yellow VirtualMachine
|
||||
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[System.String]
|
||||
$Resource
|
||||
)
|
||||
process {
|
||||
Foreach ($Entry in $resource) {
|
||||
$Item = Get-Inventory -Name $Entry | Get-OMResource
|
||||
if (-not $Item) {
|
||||
throw "$Entry not found"
|
||||
} Else {
|
||||
$Item.ExtensionData.UnmarkResourceAsBeingMaintained()
|
||||
Get-Inventory -Name $Entry | Get-OMResource
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Enable a single host as being in maintenance mode for 1 minute"
|
||||
Enable-OMMaintenance -Resource ESX-01a* -MaintenanceTime 1
|
||||
|
||||
Write-Host "List All Host Resources and their state"
|
||||
Get-OMResource ESX-* | Select Name, State | FT
|
||||
|
||||
Write-Host "Set All VMs with a name as backup as being in maintenance mode for 20 minutes"
|
||||
Get-VM backup* | Enable-OMMaintenance -MaintenanceTime 20
|
||||
|
||||
Write-Host "List All Backup VM Resources and their state"
|
||||
Get-VM backup* | Get-OMResource | Select Name, State | FT
|
||||
|
||||
Write-Host "Disable maintenance mode for all VMs with a name as backup as we have completed our scheduled work"
|
||||
Get-VM backup* | Disable-OMMaintenance
|
||||
|
||||
Write-Host "List All VM Resources and their state"
|
||||
Get-VM backup* | Get-OMResource | Select Name, State | FT
|
||||
|
||||
Reference in New Issue
Block a user