Posts

Showing posts from April, 2017

SCOM 2012 R2 UR9 - SQL scripts failing

When running the update_rollup_mom_db.sql  script from the UR9 update for SCOM 2012 R2 it would always bomb out after a few minutes with this error: (1 row(s) affected) (1 row(s) affected) Msg 1205, Level 13, State 56, Line 1 Transaction (Process ID 152) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Msg 3727, Level 16, State 0, Line 1 Could not drop constraint. See previous errors. Out of interest I decided to keep the DAS, Config and Exchange Correlation Engine services running while doing this as I'd never had a problem before. Getting nowhere I then stopped the Correlation Engine and - looking more promising - the script ran for about 20 minutes then bombed out with the same error. I then stopped the DAS, Config and HealthService services on all management servers as Kevin advises in the article below and the script completed successfully in less than 1 minute. The UR_Datawarehouse.sql script completed s

SC command examples

To run this on remote servers sc \\server <command> Get status of a service sc query spooler Get configuration information of a service sc qc spooler Stop a service sc stop spooler Start a service sc start spooler Get startup account sc qc spooler Change start type to Disabled Note: You might need a space after the equal sign on some computers. sc config spooler start=disabled Change start type to Manual sc config spooler start=demand Change start type to Automatic sc config spooler start=auto Get DisplayName of a service sc GetDisplayName spooler Get ServiceName of a service sc GetKeyName "Print Spooler"

High cpu on lab servers

If you're getting high cpu on lab servers (usually running Win 2012 R2) disable Windows Update in Control Panel and set the 'Windows Modules Installer' service to Manual start with the below command and reboot. Note: The space after the equal sign  is required. sc config TrustedInstaller start= demand

Turn off Windows firewall from cmd

netsh advfirewall set allprofiles state off

Shutdown command

Shutdown local computer shutdown /s /f /t 0 Restart local computer shutdown /r /f /t 0 Shutdown remote computer shutdown \\computer /s /f /t 0 Restart remote computer shutdown \\computer /r /f /t 0

FOR loop (DOS)

Loop through names in file FOR /F %i in (c:\Temp\_Computers.txt) do @echo %i Populate AD group with computer accounts FOR /F %i in (c:\Temp\_Computers.txt) do dsmod group "CN=GPO-Server-Low Criticality,OU=Group Policy Filtering,OU=Privileged Objects,OU=All Resources,DC=lab,DC=com" -addmbr %i

EventCreate

To add an event to the Application log eventcreate /L APPLICATION /T ERROR /SO TestSource /ID 500 /D "Test event using eventcreate.exe" Limitations You can only use the Application log EventID must be in the range of 1 - 1000 EventSource must be unique within all logs so use something like 'TestSource'

Extract contents of .cab files from cmd

For a single file in cab: expand <file.cab> -r If there's multiple files in cab: Note: The "." is the current directory. expand <file.cab> -r -f:* .

Fill up disk space for testing

Here's some options for filling disks up when testing low disk space alerts in SCOM: # 1 - fsutil This will create a 1gb file: fsutil file createnew c:\temp\test.txt 1000000000 # 2 - File copy This will copy the file 1.test nine times: FOR /L %i IN (2,1,10) DO copy 1.test %i.test