SCOM Notes

scxadmin commands:

Usage: scxadmin
Generic options (for all commands)
  [-quiet]      Set quiet mode (no output)

        General Options
scxadmin -version

        Service Management
scxadmin {-start|-stop|-restart|-status}  [all|cimom|provider]

        Providers Management
scxadmin -config-list {RunAs}
scxadmin -config-set {RunAs} {CWD=|ChRootPath=|AllowRoot={true|false}}
scxadmin -config-reset {RunAs} [CWD|ChRootPath|AllowRoot]

        Log Configuration Management
scxadmin {-log-list|-log-rotate|-log-reset} [all|cimom|provider]
scxadmin -log-set [all|cimom|provider] {verbose|intermediate|errors}
scxadmin -log-set provider {{FILE:|STDOUT}:={SUPPRESS|ERROR|WARNING|INFO|TRACE|HYSTERICAL}}
scxadmin {-log-reset|-log-remove} provider [{FILE:|STDOUT}]

Powershell – Concatenate files

Example: To concatenate all .txt files in directory C:\temp and store result in outfile.txt

$ToNatural = { [regex]::Replace($_, '\d+', { $args[0].Value.PadLeft(20) }) }

if (Test-Path "C:\temp\outfile.txt") {
    Remove-Item "C:\temp\outfile.txt"
}

Get-ChildItem "C:\temp" -Filter *.txt|sort-object $ToNatural | `
Foreach-Object{
  Write-Host $_
  #Get-Content $_ >> C:\temp\outfile.txt
}

Powershell – Get restarts and Uptime

gwmi win32_ntlogevent -filter "LogFile='System' and EventCode='1074' and Message like '%restart%'" |select User,@{n="Time";e={$_.
ConvertToDateTime($_.TimeGenerated)}}

</pre>
<pre class="toolbar-overlay:false lang:ps decode:true ">$BootTime = (systeminfo | find "System Boot Time:").Replace("System Boot Time:","").Trim()
$BootTime


$Uptime = (Get-Date) - [datetime]$BootTime
$Uptime