Friday, October 28, 2016

How to change SCCM reserve disk space for a DP

1) Run SQL query:

select SCR.ID, SCR.Name,SC.NalPath, SCR.Value3 from sc_sysresuse_property SCR join sc_sysresuse SC on SCR.SysResUseID = SC.ID where SCR.name = 'MinFreeSpace' and SC.NALPath like '%%' and SC.RoleTypeID = 3

get SCR_ID

2) Use the returned ID in step 1). Run the below query to update the 'MinFreeSpace' value.
update sc_sysresuse_property set value3 = 'set desired value in MB' where name = 'MinFreeSpace' and ID = ''
Example:
update sc_sysresuse_property set value3 =10240  where name = 'MinFreeSpace' and ID = xxxxxxxxxxxxx

3) Change registry value HKLM\software\Microsoft\SMS\DPreserveddiskspace to match the  number you used on step 2, eg: 10240. 

You don't have to reboot the DP.


Restart the SMS_SITE_Component_Manager service on SCCM site server.

Monday, October 17, 2016

SCOM 2012 r2 console crash after windows patch

After I installed Oct 2016 windows patches
I got this error whenever I tried to open "windows Computers" under "Monitoring"

Application log:
Faulting application name: Microsoft.EnterpriseManagement.Monitoring.Console.exe, version: 7.1.10226.1177, time stamp: 0x5697e092
Faulting module name: ntdll.dll, version: 6.1.7601.23543, time stamp: 0x57d2fde1
Exception code: 0xc000041d
Fault offset: 0x000000000004ef57
Faulting process id: 0x18a0
Faulting application start time: 0x01d228f4261a1d54
Faulting application path: C:\Program Files\Microsoft System Center 2012 R2\Operations Manager\Console\Microsoft.EnterpriseManagement.Monitoring.Console.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 7a5e2e0a-94e7-11e6-ab30-0050569b0035


SCOM console logs:

Problem signature:
  Problem Event Name: APPCRASH
  Application Name: Microsoft.EnterpriseManagement.Monitoring.Console.exe
  Application Version: 7.1.10226.1177
  Application Timestamp: 5697e092
  Fault Module Name: ntdll.dll
  Fault Module Version: 6.1.7601.23543
  Fault Module Timestamp: 57d2fde1
  Exception Code: c0000005
  Exception Offset: 000000000004eef1
  OS Version: 6.1.7601.2.1.0.272.7
  Locale ID: 1033
  Additional Information 1: 383a
  Additional Information 2: 383a5f09f3fd70a29b8be053663a1d2a
  Additional Information 3: 0ebe
  Additional Information 4: 0ebe29effad583805ef4413487a5a75f

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt


It seems "October 2016 security monthly quality rollup" is causing the issue
KB3192392 for Windows 8.1 and Server 2012 R2
KB3185332 for Windows server 2012
KB3185330 for Windows server 2008 R2

Remove the KB and restart the SCOM server and it will be fixed.

Saturday, October 15, 2016

Clustered task in Windows server 2012 R2 with 0x1 error

I tried to create a clustered task and got 0x1 error, according to M$ it means

0x1: An incorrect function was called or an unknown function was called. (ref: https://support.microsoft.com/en-us/kb/308558)
extra: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383604(v=vs.85).aspx

This is the original script that generated 0x1 error

$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "runme.ps1" -WorkingDirectory "E:\Shares\scripts"

E: is a clustered disk and I got 0x1 error when I execute the task manually.

Later I found that it has to do with execution policy, so I have changed it to

$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-executionpolicy bypass -file runme.ps1" -WorkingDirectory "E:\Shares\scripts"

and it ran without error.


Here is the complete script to create the task
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-executionpolicy bypass -file runme.ps1" -WorkingDirectory "E:\Shares\scripts"
$trigger = New-ScheduledTaskTrigger -Daily -At 3pm
Register-ClusteredScheduledTask –Cluster filesharecluster –TaskName MyResourceSpecificTask –TaskType ResourceSpecific –Resource "cluster disk 2" –Action $action –Trigger $trigger


and this is what the runme.ps1 looks like, as you can see you can run dos command and powershell

dir c:\ | export-csv "e:\shares\scripts\result.csv"

somehow trying to to run bat file also generated 0x1 error, some suggested that the account that runs the task needs to be in "logon as a batch" job in local security policy but I have not tried it yet.