Getting error as "The parameter CommonRule should contain only VAIOfilter rules." for new-spbmstoragepolicy command.
This was working fine earlier, but facing this issue recently. I am executing command as below:
New-SpbmStoragePolicy -Name replication_052705_3043 -CommonRule (New-SpbmRule -Capability (Get-SpbmCapability -Name "abc.abc@REPLICATION") -Value 2)
When I manually create a policy via web UI and execute get command, it shows the output as below.
PS C:\Users\Administrator> Get-SpbmStoragePolicy -Name test
Name Description Rule Sets Common Rules
---- ----------- --------- ------------
test {} {abc.abc@REPLICATION=2}
What am i missing here?
Which PowerCLI version?
Did you also try with an array?
New-SpbmStoragePolicy -Name replication_052705_3043 -CommonRule @(New-SpbmRule -Capability (Get-SpbmCapability -Name "abc.abc@REPLICATION") -Value 2)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the response LuCD.
Same output after using array and please see the details of powershell version.
PS C:\Users\Administrator> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I meant the PowerCLI version
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry, please see the command output below.
PS C:\Users\testadm> Get-PowerCLIVersion
WARNING: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.
PowerCLI Version
----------------
VMware PowerCLI 12.2.0 build 17538434
---------------
Component Versions
---------------
VMware Common PowerCLI Component 12.2 build 17531244
VMware Cis Core PowerCLI Component PowerCLI Component 12.2 build 17531611
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.2 build 17531987
There is in the meantime a version 12.3, but I don't think that will solve your issue.
Give it a try, if it doesn't help, I suggest opening an SR
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Actually, the poewrcli version details I posted earlier is where this issue is not seen, but with below powercli version only this issue occurs. Apologies for confusion.
I mean with powercli component 12.2 this issue doesn't occur, but occurs with 12.3 only.
PS C:\Users\testadm> Get-PowerCLIVersion
WARNING: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.
PowerCLI Version
----------------
VMware PowerCLI 12.2.0 build 17538434
---------------
Component Versions
---------------
VMware Common PowerCLI Component 12.3 build 17838947
VMware Cis Core PowerCLI Component PowerCLI Component 12.3 build 17839331
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 12.3 build 17839688
Then it looks definitely like an issue in 12.3.
I suggest opening an SR.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Is there any way we can restrict the module to 12.2.0?
I am getting below error when tried to do so.
PS C:\Users\testadm> Install-Module -Name vmware.vimautomation.core -RequiredVersion 12.2.0
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'vmware.vimautomation.core'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
ception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
The easiest way is to first remove all PowerCLI modules.
And then use the function Kyle provided in Obtaining Specific PowerCLI Versions from the PowerShell Gallery
You have to specify the full version, as listed on the PSGallery.
For 12.0 that is in fact 12.2.0.17538434
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ok, thanks, but when I installed the version 12.2.0.17538434, it still installs some 12.3.0 modules.
PS C:\Users\testadm> Install-Module -Name vmware.powercli -RequiredVersion 12.2.0.17538434
PS C:\Users\testadm> Get-Module -Name vmware* -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 12.2.0.... VMware.CloudServices {Connect-Vcs, Disconnect-Vcs, Get-VcsOrganizationRole, Get...
Script 7.0.2.1... VMware.DeployAutomation {Add-CustomCertificate, Add-DeployRule, Add-ProxyServer, A...
Script 7.0.2.1... VMware.ImageBuilder {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-Esx...
Manifest 12.2.0.... VMware.PowerCLI
Script 7.0.2.1... VMware.Vim
Script 12.3.0.... VMware.VimAutomation.Cis.Core {Connect-CisServer, Disconnect-CisServer, Get-CisService}
Script 12.0.0.... VMware.VimAutomation.Cloud {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, G...
Script 12.3.0.... VMware.VimAutomation.Common {Get-PowerCLIContext, Get-Task, New-OAuthSecurityContext, ...
Script 12.3.0.... VMware.VimAutomation.Core {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...
Script 12.3.0.... VMware.VimAutomation.Hcx {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance...
Script 12.3.0.... VMware.VimAutomation.HorizonView {Connect-HVServer, Disconnect-HVServer}
Script 12.0.0.... VMware.VimAutomation.License Get-LicenseDataManager
Script 12.3.0.... VMware.VimAutomation.Nsxt {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtGlobal...
Script 12.2.0.... VMware.VimAutomation.Sdk Get-ErrorReport
Script 12.3.0.... VMware.VimAutomation.Security {Add-AttestationServiceInfo, Add-KeyProviderServiceInfo, A...
Script 12.3.0.... VMware.VimAutomation.Srm {Connect-SrmServer, Disconnect-SrmServer}
Script 12.3.0.... VMware.VimAutomation.Storage {Add-EntityDefaultKeyProvider, Add-KeyManagementServer, Ad...
Script 1.6.0.0 VMware.VimAutomation.StorageUtility Update-VmfsDatastore
Script 12.3.0.... VMware.VimAutomation.Vds {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, E...
Script 12.2.0.... VMware.VimAutomation.Vmc {Add-VmcSddcHost, Connect-Vmc, Disconnect-Vmc, Get-AwsAcco...
Script 12.2.0.... VMware.VimAutomation.vROps {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-O...
Script 12.3.0.... VMware.VimAutomation.WorkloadMan... {Disable-WMCluster, Enable-WMCluster, Get-WMCluster, Get-W...
Script 12.1.0.... VMware.VumAutomation {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Complia...
You have to use that function I mentioned
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
So I followed the steps from the page you provided.
Saved the Save-PowerCLI code in one ps1 file. But getting errors as below.
---------------------------------------------------------------------------------------------------------------------------------------
PS C:\Users\testadm> Import-Module C:\users\testadm\Save-PowerCLI.ps1
PS C:\Users\testadm> Save-PowerCLI -requiredversion 12.2.0.17538434 -path C:\users\testadm\Downloads\powercli12
Save-PowerCLI : The term 'Save-PowerCLI' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Save-PowerCLI -requiredversion 12.2.0.17538434 -path C:\users\testadm ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Save-PowerCLI:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Suggestion [3,General]: The command Save-PowerCLI was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Save-PowerCLI". See "get-help about_Command_Precedence" for more details.
PS C:\Users\testadm> .\Save-PowerCLI.ps1
function : The term 'function' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\testadm\Save-PowerCLI.ps1:1 char:1
+ function Save-PowerCLI {
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (function:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Why are you doing Import-Module C:\users\testadm\Save-PowerCLI.ps1?
The blog post doesn't mention that.
You have to save the function in a .ps1 file (there are 2 links to the code just above the function).
Then call the function
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok, so earlier I had copy pasted the code from the page. Now I downloaded the file from https://code.vmware.com/samples?id=5226#code
Now when I run the command: .\Save-PowerCLI.ps1 -Requiredversion '12.2.0.17538434' -Path .\Downloads\Powercli1220\
It doesn't give any error but modules are also not downloaded 😞
Are you calling that function somewhere?
If you have the .ps1 file with the function, you can first dot-source the function, and then call it.
. .\Save-PowerCLI.ps1
Save-PowerCLI -RequiredVersion 12.2.0.17538434
There is a blank between the 2 dots in the first line.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is working. Thank you very much LucD
Hello hello 👋
Has this ever been fixed? 😅
I'm using VMware.VimAutomation.Storage 12.7.0.20091292
$CommonRules = @(New-SpbmRule -Capability (Get-SpbmCapability -Name "vmwarevmcrypt.vmwarevmcrypt@ENCRYPTION") -Value "False")
New-SpbmStoragePolicy -Name "test" -Description "test" -CommonRule $CommonRules
New-SpbmStoragePolicy : 20/02/2023 16:53:32 New-SpbmStoragePolicy The parameter CommonRule should contain only VAIOfilter rules
Apparently not yet in 12.7.
You could try 13.0, but this issue is not mentioned as a fix in the 13.0 Release Notes afaik
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
same with 13.0 indeed
I have created a SR 23408879402 but not sure if it is in the right place as there was no powercli product option in dropdown.