Thursday 23 April 2015

Update-SPDistributedCacheSize : Cannot bind parameter 'CacheSizeInMB'. Cannot convert value "250 MB" to type "System.UInt32". Error: "Input string was not in a correct format."



Get Distributed Cache :

To check the existing memory allocation for the Distributed Cache service on a server, run the following command at the SharePoint Management Shell command prompt:


cls
asnp "*sh*"
Use-CacheCluster

Get-AFCacheHostConfiguration -ComputerName "spdev" -CachePort "22233" 



Update Cache :


  1. Stop the Distributed Cache service on all cache hosts. To stop the Distributed Cache service, go to Services on Server in Central Administration, and Stop the Distributed Cache service on all cache hosts in the farm.
  2. To reconfigure the cache size of the Distributed Cache service, run the following command one time only on any cache host at the SharePoint Management Shell command prompt:
    Update-SPDistributedCacheSize -CacheSizeInMB CacheSize 
    
    
    Where:
    • CacheSize is the cache size's memory allocation assignment in MB. In the previous example, the cache size was calculated at 7168 MB for a server with 16 GB of total memory.
  3. Restart the Distributed Cache service on all cache hosts. To restart the Distributed Cache service, go to Services on Server in Central Administration, and Start the Distributed Cache service on all cache hosts in the farm.
ex:

Update-SPDistributedCacheSize -CacheSizeInMB "250 MB" 

Update-SPDistributedCacheSize : Cannot bind parameter 'CacheSizeInMB'. Cannot 
convert value "250 MB" to type "System.UInt32". Error: "Input string was not in 
a correct format."
At line:1 char:46
+ Update-SPDistributedCacheSize -CacheSizeInMB "250 MB"
+                                              ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Update-SPDistributedCacheSiz 
   e], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.SharePoin 
   t.PowerShell.SPCmdletConfigureDistributedCacheSize


In order to Fix the issue remove "MB" in string , pass only int value

Update-SPDistributedCacheSize -CacheSizeInMB  250

Again We will See updated Cache in the Server.

cls
asnp "*sh*"
Use-CacheCluster

Get-AFCacheHostConfiguration -ComputerName "spdev" -CachePort "22233" 

You can see Value increased to 250 MB.