Skip to content

Commit

Permalink
update init to get referenced VMw DLL from proper location; fix #9
Browse files Browse the repository at this point in the history
  • Loading branch information
mtboren committed May 16, 2017
1 parent a476e89 commit 56b7f52
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 9 additions & 6 deletions DRSRule.init.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
if((Get-PowerCLIVersion).Build -ge 4624819){
$pcliDll = "${env:\ProgramFiles(x86)}\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.Vim.dll"
}
else{
$pcliDll = "${env:\ProgramFiles(x86)}\VMware\Infrastructure\vSphere PowerCLI\VMware.Vim.dll"
}
## the version of PowerCLI at which the path to "VMware.Vim.dll" change from "${env:\ProgramFiles(x86)}\VMware\Infrastructure\vSphere PowerCLI\." (two folders up from the core module's directory) to the VMware.VimAutomation.Core module directory
## build 4624819 is PowerCLI 6.5rel1 -- 6.5.0, build 4624819; this (6.5rel1) is module version 6.5.0.2604913
$verPowerCLIWhereDllMoved = [System.Version]"6.5.0.2604913"

$oModuleInfo = Get-Module -ListAvailable -Name VMware.VimAutomation.Core
## the directory in which the VMware.Vim.dll file resides, based on module version
$strVMwareVimDllDirectory = if ($oModuleInfo.Version -ge $verPowerCLIWhereDllMoved) {$oModuleInfo.ModuleBase} else {(Get-Item (Get-Module VMware.VimAutomation.Core).ModuleBase).Parent.Parent.FullName}
## the full filespec of the DLL
$pcliDll = Join-Path -Path $strVMwareVimDllDirectory -ChildPath "VMware.Vim.dll"

Add-Type -ReferencedAssemblies $pcliDll -TypeDefinition @"
using VMware.Vim;
Expand Down
12 changes: 12 additions & 0 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#### ToDo items for DRSRule module
- for [Issue #2](https://github.com/PowerCLIGoodies/DRSRule/issues/2), add ability to remove one or more target items from a DRS VMGroup or VMHost group via `Set-DrsVMGroup`, `Set-DrsVMHostGroup`
- also, investigate other item reported in that issue of a problem "when the user wants to remove all VMs from a VM group. That errors out"
- for [Issue #9](https://github.com/PowerCLIGoodies/DRSRule/issues/9), ensure that location of required PowerCLI .DLL is properly determined; possibly like:
``` PowerShell
$pcliDll = if ((Get-PowerCLIVersion).Build -ge 4624819){
Join-Path -Path (Get-Module -Name VMware.VimAutomation.Core -ListAvailable).ModuleBase -ChildPath "VMware.Vim.dll"
}
else {
"${env:\ProgramFiles(x86)}\VMware\Infrastructure\vSphere PowerCLI\VMware.Vim.dll"
}
```
- look into possibility of increasing speed in `Get-DrsVMGroup` (somewhat slow in medium to large environments)
- add [Pester](https://github.com/pester/Pester) tests
- `New-Drs*`, `Set-Drs*`, `Remove-Drs*` tests
- add SDRS rule support
Expand Down

0 comments on commit 56b7f52

Please sign in to comment.