Skip to content

Commit f03ac4a

Browse files
committed
Merge branch 'dev'
2 parents 2b12097 + 2130e54 commit f03ac4a

File tree

8 files changed

+255
-93
lines changed

8 files changed

+255
-93
lines changed

ChangeLog.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
### ChangeLog for vNugglets.Utility PowerShell module
22

3+
#### v1.2, released 18 Jun 2017
4+
5+
- \[improvement] updated function `Get-VNVMByAddress`:
6+
- greatly increased speed by using `VMware.Vim.SearchIndex` for by-IP searches (`SearchIndex` search methods do not support wildcard, though, so getting VM by wildcard address still uses slower mechanism); example speed increase for searching for VM by specific IP: went from 13s to about 0.25s in a vCenter with about 7,500 VMs -- woo-hoo!
7+
- added new parameters `-GuestHostname` and `-UUID` to support for searching by guest DNS name or VM BIOS UUID, respectively (these also use methods of `VMware.Vim.SearchIndex` object, so the searches are super fast)
8+
- \[improvement] updated function `Copy-VNVIRole`:
9+
- takes new parameter, `-SourceRole`, for passing VIRole object itself as value, and this parameter accepts value from pipeline, for more natural use of cmdlet
10+
- deduces source vCenter server from `-SourceRole` value, simplifying use of cmdlet (no need to specify `-SourceVCName` parameter when providing the source VIRole object)
11+
- `-DestinationVCName` parameter now optional, further simplifying use of cmdlet; if parameter not specified, destination vCenter will be the same as the source vCenter
12+
- \[internal improvement] updated module prepartion to use `Update-ModuleManifest` for keeping module manifest in shape
13+
- added manifest entries for tags and for URIs for project, release notes, license, etc.
14+
- prepared for publishing to the [PowerShellGallery](https://www.powershellgallery.com/))
15+
16+
317
#### v1.1, released 20 Dec 2016
418

519
- \[new] added function `Find-VNVMWithDuplicateMACAddress` for finding duplicate VM NIC MAC address in vCenter
@@ -10,13 +24,13 @@
1024
- created module from many of the juicy snippets/functions that we shared at [vNugglets.com](http://vNugglets.com) over the years
1125
- updated `Copy-VNVIRole` to be a safer function overall by removing old `Invoke-Expression` methodology
1226
- standardized parameter names across cmdlets in the module and expanded some previously truncated/cryptic parameter names (go, usability and discoverability!)
13-
- added/updated "by name regular expression pattern" and "by liternal name string" parameters to several cmdlets
27+
- added/updated "by name regular expression pattern" and "by literal name string" parameters to several cmdlets
1428
- modernized cmdlets to use capabilities of somewhat newer PowerShell releases (like ordered hashtables) and built-in property return iteration, breaking PowerShell v2.0 compatibility (it's time to upgrade, right?)
15-
- updated `Invoke-VNEvacuateDatastore`:
29+
- updated `Invoke-VNEvacuateDatastore`:
1630
- added feature that uses any/all datastores in datastore cluster (when specifying a datastore cluster for Destination parameter value) for potential destination _per object_ (this allows for a potentially different datastore for each virtual disk on a VM)
1731
- added ability to exclude a VM/template's files from evacuation process (via parameter)
1832
- added `-WhatIf` support
19-
- updated cmdlet names to use standard/approved verbs where they were not already in use. Renamed functions/snippets as follows:
33+
- updated cmdlet names to use standard/approved verbs where they were not already in use. Renamed functions/snippets as follows:
2034
- `Get-VNVMByRDM` was "Get-VMWithGivenRDM"
2135
- `Get-VNVMByVirtualPortGroup` was "Get-VMOnNetworkPortGroup"
2236
- `Get-VNVMHostBrokenUplink` was "Get-BustedVmnic"

License

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2016 vNugglets
3+
Copyright (c) since 2016, vNugglets
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

ToDo.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
- support for virtual distributed switches ("vDS" or "vDSwitches"); currently only supports virtual standard switches ("vSS")
66
- support for accepting VMHost ID from pipeline (by property), so that the following works tip top:
77
`Get-Cluster myCluster | Get-VMHost | Get-VNVMHostBrokenUplink`
8-
- update function `Get-VNVMByAddress` to:
9-
- use `VMware.Vim.SearchIndex` for speed for FindAllByIp (does support wildcard, though)
10-
- support searching by guest DNS name (also using `VMware.Vim.SearchIndex`, via the `FindAllByDnsName` method)
118
- update function `Get-VNVMByVirtualPortGroup` to take a standard- or distributed virtual portgroup as a parameter (and, from pipeline)
12-
- update function `Copy-VNVIRole` to take SourceVIRole as VIRole object, and to accept it from pipeline
139
- update function `Get-VNUplinkNicForVM` to give more meaningful VDSwitch identification (currently returns something to the effect of `DvsPortset-1` for the VDSwitch name)
1410
- ?add function for changing VM boot order
1511
- investigate using a PropertyCollector to more quickly retrieve VM network adapter MAC addresses for function `Find-VNVMWithDuplicateMACAddress`

Update-VNModuleManifest.ps1

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<# .Description
2+
Some code to help automate the updating of the ModuleManifest file
3+
#>
4+
[CmdletBinding(SupportsShouldProcess=$true)]
5+
param()
6+
begin {
7+
## some code to generate the module manifest
8+
$strFilespecForPsd1 = "$PSScriptRoot\vNugglets.Utility\vNugglets.Utility.psd1"
9+
10+
$hshModManifestParams = @{
11+
# Confirm = $true
12+
Path = $strFilespecForPsd1
13+
ModuleVersion = "1.2.0"
14+
Description = "Module with the super useful functions that were previously scattered about the web by the vNugglets team (particularly, at vNugglets.com)"
15+
## some aliases, both as written, and with "VN" prefixed on them
16+
AliasesToExport = Write-Output ConnVIServer DisconnVIServer | Foreach-Object {$_; "VN$_"}
17+
FileList = Write-Output vNugglets.Utility.psd1 vNuggletsUtilityMod.psm1 vNuggletsUtilityMod_functions.ps1, vNugglets_SupportingFunctions.ps1, en-US\about_vNugglets.Utility.help.txt
18+
FunctionsToExport = Write-Output Connect-VNVIServer Copy-VNVIRole Disconnect-VNVIServer Find-VNVMWithDuplicateMACAddress Get-VNNetworkClusterInfo Get-VNUplinkNicForVM Get-VNVMByAddress Get-VNVMByRDM Get-VNVMByVirtualPortGroup Get-VNVMDiskAndRDM Get-VNVMEVCInfo Get-VNVMHostBrokenUplink Get-VNVMHostFirmwareInfo Get-VNVMHostHBAWWN Get-VNVMHostLogicalVolumeInfo Get-VNVMHostNICFirmwareAndDriverInfo Invoke-VNEvacuateDatastore Move-VNTemplateFromVMHost Update-VNTitleBarForPowerCLI
19+
IconUri = "http://static.vnugglets.com/imgs/vNuggletsLogo.jpg"
20+
LicenseUri = "https://github.com/vNugglets/vNuggletsPSMod/blob/master/License"
21+
NestedModules = Write-Output vNuggletsUtilityMod_functions.ps1 vNugglets_SupportingFunctions.ps1
22+
# PassThru = $true
23+
ProjectUri = "https://github.com/vNugglets/vNuggletsPSMod"
24+
ReleaseNotes = "See release notes at https://github.com/vNugglets/vNuggletsPSMod/blob/master/ChangeLog.md"
25+
## relies on a centrally-important VMware PowerCLI module
26+
RequiredModules = "VMware.VimAutomation.Core"
27+
Tags = Write-Output vNugglets vNugglets.com "VMware vSphere" FaF PowerCLI VIRole "MAC Address" VM RDM vPG "Virtual Portgroup" EVC VMHost HBA Datastore
28+
# Verbose = $true
29+
} ## end hashtable
30+
} ## end begin
31+
32+
process {
33+
if ($PsCmdlet.ShouldProcess($strFilespecForPsd1, "Update module manifest")) {
34+
## do the actual module manifest update
35+
PowerShellGet\Update-ModuleManifest @hshModManifestParams
36+
## replace the comment in the resulting module manifest that includes "PSGet_" prefixed to the actual module name with a line without "PSGet_" in it
37+
(Get-Content -Path $strFilespecForPsd1 -Raw).Replace("# Module manifest for module 'PSGet_vNugglets.Utility'", "# Module manifest for module 'vNugglets.Utility'") | Set-Content -Path $strFilespecForPsd1
38+
} ## end if
39+
} ## end prcoess
40+
41+
42+
<#
43+
## used for original manifest creation
44+
$hshModManifestParams = @{
45+
Path = $strFilespecForPsd1
46+
Author = "Matt Boren"
47+
CompanyName = "vNugglets.com"
48+
Copyright = "MIT License"
49+
## when setting value for DefaultCommandPrefix in module, need to account for that when setting value for Aliases anywhere (need to code those to point at what the functions _will_ be called when the DefaultCommandPrefix is applied)
50+
#DefaultCommandPrefix = ""
51+
#FormatsToProcess = "SomeModule.format.ps1xml"
52+
ModuleToProcess = "vNuggletsUtilityMod.psm1"
53+
ModuleVersion = "1.1.0"
54+
## scripts (.ps1) that are listed in the NestedModules key are run in the module's session state, not in the caller's session state. To run a script in the caller's session state, list the script file name in the value of the ScriptsToProcess key in the manifest
55+
NestedModules = @("vNuggletsUtilityMod_functions.ps1", "vNugglets_SupportingFunctions.ps1")
56+
PowerShellVersion = [System.Version]"4.0"
57+
Description = "Module with the functions that have previously been scattered about the web by the vNugglets team (particularly, at vNugglets.com"
58+
## specifies script (.ps1) files that run in the caller's session state when the module is imported. You can use these scripts to prepare an environment, just as you might use a login script
59+
# ScriptsToProcess = "New-HtmlReport_configItems.ps1"
60+
VariablesToExport = @()
61+
AliasesToExport = @()
62+
CmdletsToExport = @()
63+
FileList = Write-Output vNugglets.Utility.psd1 vNuggletsUtilityMod.psm1 vNuggletsUtilityMod_functions.ps1, vNugglets_SupportingFunctions.ps1, about_vNugglets.Utility.help.txt
64+
Verbose = $true
65+
}
66+
## using -PassThru so as to pass the generated module manifest contents to a var for later output as ASCII (instead of having a .psd1 file of default encoding, Unicode)
67+
$oManifestOutput = New-ModuleManifest @hshModManifestParams -PassThru
68+
## have to do in separate step, as PSD1 file is "being used by another process" -- the New-ModuleManifest cmdlet, it seems
69+
# in order to have this module usable (importable) via PowerShell v2, need to update the newly created .psd1 file, replacing the 'RootModule' keyword with 'ModuleToProcess'
70+
# ($oManifestOutput -split "`n" | Foreach-Object {$_ -replace "^RootModule = ", "ModuleToProcess = "}) -join "`n" | Out-File -Verbose -FilePath $strFilespecForPsd1 -Encoding ASCII
71+
$oManifestOutput | Out-File -Verbose $strFilespecForPsd1 -Encoding ASCII
72+
#>

makeModule.ps1

Lines changed: 0 additions & 31 deletions
This file was deleted.

vNugglets.Utility/vNugglets.Utility.psd1

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Matt Boren
55
#
6-
# Generated on: 12/6/2016
6+
# Generated on: 6/18/2017
77
#
88

99
@{
@@ -12,7 +12,10 @@
1212
RootModule = 'vNuggletsUtilityMod.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.1.0'
15+
ModuleVersion = '1.2.0'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
1619

1720
# ID used to uniquely identify this module
1821
GUID = 'a22ca8fe-3739-463f-b8dd-4d5d2c9ffec4'
@@ -27,7 +30,7 @@ CompanyName = 'vNugglets.com'
2730
Copyright = 'MIT License'
2831

2932
# Description of the functionality provided by this module
30-
Description = 'Module with the functions that have previously been scattered about the web by the vNugglets team (particularly, at vNugglets.com'
33+
Description = 'Module with the super useful functions that were previously scattered about the web by the vNugglets team (particularly, at vNugglets.com)'
3134

3235
# Minimum version of the Windows PowerShell engine required by this module
3336
PowerShellVersion = '4.0'
@@ -38,17 +41,17 @@ PowerShellVersion = '4.0'
3841
# Minimum version of the Windows PowerShell host required by this module
3942
# PowerShellHostVersion = ''
4043

41-
# Minimum version of Microsoft .NET Framework required by this module
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
4245
# DotNetFrameworkVersion = ''
4346

44-
# Minimum version of the common language runtime (CLR) required by this module
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
4548
# CLRVersion = ''
4649

4750
# Processor architecture (None, X86, Amd64) required by this module
4851
# ProcessorArchitecture = ''
4952

5053
# Modules that must be imported into the global environment prior to importing this module
51-
# RequiredModules = @()
54+
RequiredModules = @('VMware.VimAutomation.Core')
5255

5356
# Assemblies that must be loaded prior to importing this module
5457
# RequiredAssemblies = @()
@@ -66,17 +69,29 @@ PowerShellVersion = '4.0'
6669
NestedModules = @('vNuggletsUtilityMod_functions.ps1',
6770
'vNugglets_SupportingFunctions.ps1')
6871

69-
# Functions to export from this module
70-
FunctionsToExport = '*'
72+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
73+
FunctionsToExport = 'Connect-VNVIServer', 'Copy-VNVIRole', 'Disconnect-VNVIServer',
74+
'Find-VNVMWithDuplicateMACAddress', 'Get-VNNetworkClusterInfo',
75+
'Get-VNUplinkNicForVM', 'Get-VNVMByAddress', 'Get-VNVMByRDM',
76+
'Get-VNVMByVirtualPortGroup', 'Get-VNVMDiskAndRDM', 'Get-VNVMEVCInfo',
77+
'Get-VNVMHostBrokenUplink', 'Get-VNVMHostFirmwareInfo',
78+
'Get-VNVMHostHBAWWN', 'Get-VNVMHostLogicalVolumeInfo',
79+
'Get-VNVMHostNICFirmwareAndDriverInfo',
80+
'Invoke-VNEvacuateDatastore', 'Move-VNTemplateFromVMHost',
81+
'Update-VNTitleBarForPowerCLI'
7182

72-
# Cmdlets to export from this module
73-
# CmdletsToExport = @()
83+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
84+
CmdletsToExport = @()
7485

7586
# Variables to export from this module
7687
# VariablesToExport = @()
7788

78-
# Aliases to export from this module
79-
# AliasesToExport = @()
89+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
90+
AliasesToExport = 'ConnVIServer', 'VNConnVIServer', 'DisconnVIServer',
91+
'VNDisconnVIServer'
92+
93+
# DSC resources to export from this module
94+
# DscResourcesToExport = @()
8095

8196
# List of all modules packaged with this module
8297
# ModuleList = @()
@@ -85,10 +100,34 @@ FunctionsToExport = '*'
85100
FileList = 'vNugglets.Utility.psd1', 'vNuggletsUtilityMod.psm1',
86101
'vNuggletsUtilityMod_functions.ps1',
87102
'vNugglets_SupportingFunctions.ps1',
88-
'about_vNugglets.Utility.help.txt'
103+
'en-US\about_vNugglets.Utility.help.txt'
104+
105+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
106+
PrivateData = @{
107+
108+
PSData = @{
109+
110+
# Tags applied to this module. These help with module discovery in online galleries.
111+
Tags = 'vNugglets','vNugglets.com','VMware vSphere','FaF','PowerCLI','VIRole','MAC Address','VM','RDM','vPG','Virtual Portgroup','EVC','VMHost','HBA','Datastore'
112+
113+
# A URL to the license for this module.
114+
LicenseUri = 'https://github.com/vNugglets/vNuggletsPSMod/blob/master/License'
115+
116+
# A URL to the main website for this project.
117+
ProjectUri = 'https://github.com/vNugglets/vNuggletsPSMod'
118+
119+
# A URL to an icon representing this module.
120+
IconUri = 'http://static.vnugglets.com/imgs/vNuggletsLogo.jpg'
121+
122+
# ReleaseNotes of this module
123+
ReleaseNotes = 'See release notes at https://github.com/vNugglets/vNuggletsPSMod/blob/master/ChangeLog.md'
124+
125+
# External dependent modules of this module
126+
# ExternalModuleDependencies = ''
89127

90-
# Private data to pass to the module specified in RootModule/ModuleToProcess
91-
# PrivateData = ''
128+
} # End of PSData hashtable
129+
130+
} # End of PrivateData hashtable
92131

93132
# HelpInfo URI of this module
94133
# HelpInfoURI = ''
Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
## dot-source the config items file
2-
#. $PSScriptRoot\configItems.ps1
3-
41
## Set aliases; when setting value for DefaultCommandPrefix in module, need to account for that when setting value for Alias here (value needs to be of what the final function name will be with that DefaultCommandPrefix)
52
$hshNewAliasInfo = @{
63
## Connect and Disconnect VIServer
@@ -13,14 +10,11 @@ $arrAliasNamesToExport = $hshNewAliasInfo.GetEnumerator() | Foreach-Object {
1310
$strNameThisAlias,"VN$strNameThisAlias" | Foreach-Object {if (-not (Get-Alias -Name $_ -ErrorAction:SilentlyContinue)) {New-Alias -Name $_ -Value $strValueThisAlias; $_}}
1411
} ## end foreach-object
1512

16-
## export these items for use by consumer
17-
$hshModuleMemberParams = @{
18-
Function = Write-Output Connect-VNVIServer, Copy-VNVIRole, Disconnect-VNVIServer, Find-VNVMWithDuplicateMACAddress,
19-
Get-VNNetworkClusterInfo, Get-VNUplinkNicForVM, Get-VNVMByAddress, Get-VNVMByRDM, Get-VNVMByVirtualPortGroup, Get-VNVMDiskAndRDM, Get-VNVMEVCInfo,
20-
Get-VNVMHostBrokenUplink, Get-VNVMHostFirmwareInfo, Get-VNVMHostHBAWWN, Get-VNVMHostLogicalVolumeInfo, Get-VNVMHostNICFirmwareAndDriverInfo,
21-
Invoke-VNEvacuateDatastore, Move-VNTemplateFromVMHost, Update-VNTitleBarForPowerCLI
22-
Alias = $arrAliasNamesToExport
23-
} ## end hsh
13+
## now handled in module manifest
14+
# ## export these items for use by consumer
15+
# $hshModuleMemberParams = @{
16+
# Alias = $arrAliasNamesToExport
17+
# } ## end hsh
2418

25-
## do the actual member export
26-
Export-ModuleMember @hshModuleMemberParams
19+
# ## do the actual member export
20+
# Export-ModuleMember @hshModuleMemberParams

0 commit comments

Comments
 (0)