I know this isn't powershell, which is techsexy, it's plain old vbscript.  
however... we did just send it out to 200k clients in the last 2 months, to 
make ccmcache 25gb on NON-Virtual Machines, if they happened to have enough 
free space to allow that to be done.  Those were our parameters: don't do this 
on virtual machines; (which yeah, we could have done that by excluding them in 
the collection, too), and of course only bother to try to change it to 25600 if 
there is enough space to make that happen anyway.  Feel free to steal and 
adjust as you need.

Discovery script (and what means compliant is the string "Compliant") :
On Error Resume Next
strComputer = "."
strVirtual = "No"
set oUIResource = CreateObject("UIResource.UIResourcemgr")
set CacheInfo = oUIResource.GetCacheInfo
''wscript.echo cacheinfo.totalsize
IsVirtual
If strVirtual = "Yes" Then 
        Wscript.echo "Compliant"
'       Wscript.echo "Virtual PC"
else
'       Wscript.echo "PC is not Virtual, continue checking cachesize"
if CacheInfo.TotalSize < 25600 then
   '25600=25gb
   'continue testing
        strDrive = Left(CacheInfo.Location,2)
        strComputer = "."
        set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
        set colItems = objWMI.ExecQuery("Select * from Win32_LogicalDisk where 
name = '" & strDrive & "'")
        for each item in colItems
           strFreeSpace =  Round(Item.Freespace/1073741824)
        Next
        if strFreeSpace > 25 then
          wscript.echo "Cache Size is currently: " & CacheInfo.TotalSize & ", 
FreeSpace on " & strDrive & " is " & strFreeSpace & " GB."
        Else
          'We can't fix you anyway, so fake a compliant
          wscript.echo "Compliant"
          'wscript.echo "Not Enough FreeSpace on " & strDrive & " only " & 
strFreeSpace & " GB available."
        end if
  else
   wscript.echo "Compliant"
end if
end if
wscript.quit

Sub IsVirtual
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems2 = objWMIService.ExecQuery("Select * from 
Win32_ComputerSystemProduct",,48)
For Each objItem in colItems2
Val1 = objItem.Name
select Case Val1
Case "VMware Virtual Platform"
        strVirtual = "Yes"
case "VMware7,1"
        strVirtual = "Yes"
case "Virtual Machine"
        strVirtual = "Yes"
Case "Parallels Virtual Platform"
        strVirtual = "Yes"
End Select
Next
End Sub

-----------------
And, the Remediation Script

On Error Resume Next 
Dim oUIResource, objCacheInfo
Set oUIResource = CreateObject("UIResource.UIResourceMgr") 
Set objCacheInfo = oUIResource.GetCacheInfo 
objCacheInfo.TotalSize = 25600
if err.number <> 0 then
  wscript.echo "Failed to Set New Cache Size -- likely not enough free disk 
space.  Error Number: " & err.number &_
    " Error Description: " & err.Description
end if
wscript.quit


Sherry Kissinger 


On Wednesday, July 9, 2014 1:49 PM, John Aubrey <[email protected]> 
wrote:
  


 
I don’t use a ton of PowerShell, but the big issue I ran into was 32 vs 64 bit 
PowerShell.  This is the command I used for launching a script in 64-bit 
PowerShell. 
  
%systemroot%\sysnative\windowspowershell\v1.0\powershell.exe -executionpolicy 
unrestricted .\NeedReboot.ps1 
  
From: [email protected] [mailto:[email protected]] On 
Behalf Of Krueger, Jeff
Sent: Wednesday, July 9, 2014 1:59 PM
To: [email protected]
Subject: [mssms] Remediation Script for Compliance Item not working.   
  
I made a compliance item for the ccmcache size.  The discover script is working 
correctly, but the remediation script below is not working.  I’m not seeing any 
errors in the client logs though those may be some of the most cryptic logs 
I’ve seen. 
  
$CacheQuery= Get-WmiObject -Namespace ROOT\CCM\SoftMgmtAgent -Class CacheConfig 
$CacheQuery.Size = 12288 
$CacheQuery.Put()  
  
The script works fine from a powershell window, so I’m not sure why it’s not 
working with the configuration item settings. 
  
Jeff Krueger 
IT - Endpoint Design Services 
Henry Ford Health System 
[email protected] 
248.853.4466 
  
    

CONFIDENTIALITY NOTICE: This email contains information from the sender that 
may be CONFIDENTIAL, LEGALLY PRIVILEGED, PROPRIETARY or otherwise protected 
from disclosure. This email is intended for use only by the person or entity to 
whom it is addressed. If
 you are not the intended recipient, any use, disclosure, copying, 
distribution, printing, or any action taken in reliance on the contents of this 
email, is strictly prohibited. If you received this email in error, please 
contact the sending party by reply
 email, delete the email from your computer system and shred any paper copies.

Note to Patients: There are a number of risks you should consider before using 
e-mail to communicate with us. See our Privacy & Security page on 
http://www.henryford.com/ for more detailed information as well as information 
concerning MyChart, our new patient portal. If you do not believe that our 
policy gives you the privacy and security protection you need, do not send 
e-mail or Internet communications to us. 


Reply via email to