Closed cc4in closed 5 years ago
Greetings, @cc4in -
Mhmm. In trying to recreate this issue with the module loaded normally, I failed. But, we do see this behavior when the module is only partially loaded.
What is the command line that you are using to import the DRSRule module? Is it like one of the following:
Import-Module c:\myModulesDir\DRSRule\DRSRule.psm1
, orImport-Module DRSRule
? Let's discuss so that we can get to the bottom of this. Cheers
@mtboren Similar issue here. Initially "Import-Module DRSRule" would not error, but any Get-DRS* function would fail with the errors shown above. Completely removed DRSRule & PowerCLI and started over, installing under my user's scope. Now results:
Add-Type : (0) : Metadata file ...\Documents\WindowsPowerShell\Modules\VMware.VimAutomation.Core\10.1.0.8344055\net45\VMware.Vim.dll' could not be found
I had noticed this prior to the module re-install also, as I had tried running the init directly to see if any errors were thrown. The only VMware.Vim.dll I could find is located under ...\Documents\WindowsPowerShell\Modules\VMware.Vim\6.7.0.9288211\net45
I tried hard coding that path in the DRSRule.init file, but that blew up and I don't know enough module coding to decipher what was failing.
I am seeing the same behaviour as above.
e.g. `PS C:> Get-DrsVMGroup Unable to find type [DRSRule.VMGroup]. At C:\Program Files\WindowsPowerShell\Modules\DRSRule\1.2.1\DRSRule.psm1:55 char:15
+ CategoryInfo : InvalidOperation: (DRSRule.VMGroup:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound`
I installed the module using
Find-Module DRSRule | Install-Module
Appears to be installed `PS C:> get-module -name DRSrule -listavailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
Script 1.2.1 DRSRule {Get-DrsVMGroup, Get-DrsVMHostGroup, Get-DrsVMToVMHostRule...
`
Hmmm, even a manual installation gives the same error as shown in the initial OP.
PowerCLI C:> Get-DrsVMGroup Unable to find type [DRSRule.VMGroup]. At C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules\DRSRule\DRSRule.psm1:55 char:15
- [OutputType([DRSRule.VMGroup],[VMware.Vim.ClusterVmGroup])]
- CategoryInfo : InvalidOperation: (DRSRule.VMGroup:TypeName) [], RuntimeException
- FullyQualifiedErrorId : TypeNotFound
I am having the same issue, even after modifying the top of my C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Modules\DRSRule\DRSRule.init.ps1 file with:
$pcliDll = "${env:\ProgramFiles(x86)}\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.Vim.dll”
My PowerCLI build is 11.0.0 build 10380590 and using DRSRule 1.2.1
Has anyone found a solution to the above problem? I have the same issue in my environment. PowerCLI version 10.1.0 build 8346946 and DRSRule version 1.2.1. The missing VMware.Vim.dll is now in path C:\Windows\System32\WindowsPowerShell\v1.0\Modules\VMware.Vim\net45, but I'm ont sure if this is the only problem. I modified the DRSRule.init.ps1 to use the new path for this dll, but was unsuccessful anyway....
I didn't solve it, but just went on using the features, vmware powercli gives us with 6.5 by itself. Not the best way, i know, but it's enough for my environment and my requirements.
Nonetheless i'd be interested if someone finds a solution for this...
I found a workaround. I modified the line 23 in the file "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DRSRule\DRSRule.init.ps1" with the correct path to the VMware.Vim.dll: $strVMwareVimDllFilespec = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\VMware.Vim\net45\VMware.Vim.dll"
I haven't found any problems with this modification in my existing scripts until now.
Thanks sand5turm. I was able to do what you did but my DRSRule.init.ps1 file was located at: C:\Program Files\Windows PowerShell\Modules\DRSRule\1.2.1\DRSRule.init.ps1
and my VMware.Vim.dll was located at: C:\Program Files\WindowsPowerShell\Modules\VMware.Vim\6.7.0.10334489\net45\VMware.Vim.dll
I also modified C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Modules\DRSRule\DRSRule.init.ps1 and modified $pcliDll to be "${env:\ProgramFiles(x86)}\VMware\Infrastructure\PowerCLI\Modules\VMware.VimAutomation.Core\VMware.Vim.dll"
Now I no longer get an error while running Get-DRSVMGroup
Greets-
Thanks for the details on what things are / are not working for you guys. I have found and coded around one of the bugs, now addressed in commit 0337916 (the Metadata file ...\net45\VMware.Vim.dll' could not be found
issue).
I'm still looking into the other bug (Unable to find type [DRSRule.VMGroup]
).
Matt,
The post I wrote yesterday was for addressing the (Unable to find type [DRSRule.VMGroup]) bug. Hopefully that helps
Got it, @Poolshark314 -- thanks
I'm having problems with Export-DRSRule. I get the following error:
PS C:\Users\My.Name> Get-Cluster "My Cluster" | Export-DrsRule -Name "DRSRule1" -Path "C:\Users\My.Name\Documents\DRS Rules\myrules.json"
Unable to find type [DRSRule.VMToVMRule].
At C:\Program Files\PowerShell\Modules\DRSRule\1.2.1\DRSRule.psm1:271 char:15
+ [OutputType([DRSRule.VMToVMRule],[VMware.Vim.ClusterAffinityRuleSpe ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (DRSRule.VMToVMRule:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
I'm using PowerShell Core version 6.1.0
PS C:\Users\My.Name> Get-Module | where name -Like VMware* | Select Version,Name
Version Name
6.7.0.9288211 VMware.Vim
10.1.0.8377811 VMware.VimAutomation.Cis.Core
10.1.0.8342134 VMware.VimAutomation.Common
10.1.0.8344055 VMware.VimAutomation.Core
10.1.0.8342078 VMware.VimAutomation.Sdk
10.1.0.8344219 VMware.VimAutomation.Vds
And version 1.2.1 of DRSRule
Thanks in advance, Greg
Working on wrapping up a v2.0 release. Such a release removes the ultimate cause of the problems in this issue (#17) -- instead of trying to handle the endless places in which some reference DLL might reside, the module in v2.0 leverages native PowerShell Classes, doing away with the DLL reference that caused more than a few problems in the 1.x line.
Thanks, everyone that helped with the troubleshooting on this issue. v2.0 of the module is imminent. Please update to that version and resume enjoying the module.
GitHub will auto-close this Issue when the feature branch is merged into master. I know you will, but: please open an Issue for anything that you find awry in the new module version, and for all of the great ideas that you might have for improving the module.
Cheers
I just updated my DRSRule to version 2.0 and now I am getting this error again. It is stating that the issue is in: C:\Program Files\WindowsPowerShell\Modules\DRSRule\2.0.0\DRSRule.psm1 on line 91 char 11 which is the New-Object declaration of type DRSRule_VMGroup.
The fix I mentioned in earlier comments seems to be longer applicable because I don't see those variables in the files any longer. Do you have any suggestions? I also just updated to PowerCli 11.2
Can someone help! I'm able to use the export-drsrule successfully, but get errors when importing the txt file with the following;
Get-DrsRuleObject : Cannot validate argument on parameter 'Object'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. At C:\Program Files\WindowsPowerShell\Modules\DRSRule\2.0.0\DRSRule.psm1:1572 char:38
+ CategoryInfo : InvalidData: (:) [Get-DrsRuleObject], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DrsRuleObject
I am using Powercli VMware PowerCLI 11.3.0 build 13990089 and verion 2.0.0 of the DRSRule.
I am testing with vcentre 6.7, creating a test VM/Host group, exporting out then deleting from vmware and trying to import back in from the export file. Any pointers would be appreciated.
Version: Get-DRSRule 1.2.1
When trying to use a function, always get Errors: