Skip to content

Instantly share code, notes, and snippets.

View dalehhirt's full-sized avatar

Dale Hirt dalehhirt

View GitHub Profile
@dalehhirt
dalehhirt / UpdateDW.sql
Created February 5, 2015 17:20
Update the DataWarehouse global setting in the OperationsManager database.
select
mt.TypeName,
mtp.ManagedTypePropertyName,
gs.SettingValue
from GlobalSettings gs
join ManagedTypeProperty mtp
on gs.ManagedTypePropertyId = mtp.ManagedTypePropertyId
join ManagedType mt
on mtp.ManagedTypeId = mt.ManagedTypeId
where mt.TypeName = 'Microsoft.SystemCenter.DataWarehouse'
Function Log-Start{
<#
.SYNOPSIS
Creates log file
.DESCRIPTION
Creates log file with path and name that is passed. Checks if log file exists, and if it does deletes it and creates a new one.
Once created, writes initial logging data
.PARAMETER LogPath
@dalehhirt
dalehhirt / Get-ComputerOwner.ps1
Created September 10, 2015 03:23
Get Computer Owner
$oADObject = Get-ADComputer <ComputerName> -Properties *
$oAceObj = Get-Acl -Path (“ActiveDirectory:://RootDSE/” + $oADObject.DistinguishedName);
$oAceObj.Owner
@dalehhirt
dalehhirt / WMEh802V.py
Last active February 3, 2016 17:32
From http://pastebin.com/WMEh802V Code to get network speed and tweet if it falls below specified values.
#!/usr/bin/python
import os
import sys
import csv
import datetime
import time
import twitter
def test():
@dalehhirt
dalehhirt / TopQueries.sql
Created August 2, 2016 16:32 — forked from BrentOzar/TopQueries.sql
Some of the top StackOverflow queries from http://data.stackexchange.com. Great for demoing wide SELECT workloads.
USE StackOverflow;
GO
IF OBJECT_ID('dbo.usp_Q7521') IS NULL
EXEC ('CREATE PROCEDURE dbo.usp_Q7521 AS RETURN 0;')
GO
ALTER PROC dbo.usp_Q7521 @UserId INT AS
BEGIN
/* Source: http://data.stackexchange.com/stackoverflow/query/7521/how-unsung-am-i */
@dalehhirt
dalehhirt / PS_Script_Template_V2_Logs.ps1
Last active January 24, 2017 18:48 — forked from 9to5IT/PS_Script_Template_V2_Logs.ps1
PowerShell: Script Template Version 2 (with logging)
#requires -version 4
<#
.SYNOPSIS
<Overview of script>
.DESCRIPTION
<Brief description of script>
.PARAMETER <Parameter_Name>
<Brief description of parameter input required. Repeat this attribute if required>
SELECT
id AS [Table ID]
, OBJECT_NAME(id) AS [Table Name]
, name AS [Index Name]
, STATS_DATE(id, indid) AS [LastUpdated]
, rowcnt AS [Row Count]
, rowmodctr AS [Rows Modified]
, FLOOR(500 + (rowcnt * 0.2)) AS [Threshold To AutoUpdate]
, CASE
WHEN rowcnt = 0 THEN 'Not Ready to Update'
SELECT
ar.replica_server_name,
adc.database_name,
ag.name AS ag_name,
drs.is_local,
drs.is_primary_replica,
drs.synchronization_state_desc,
drs.is_commit_participant,
drs.synchronization_health_desc,
drs.recovery_lsn,
function w-h() {
write-host -ForegroundColor Yellow ">>>" (get-date).ToString("yyyMMdd HH:mm:ss") $args
}
function w-e() {
write-host -ForegroundColor Red ">>>" (get-date).ToString("yyyMMdd HH:mm:ss") $args
}
@dalehhirt
dalehhirt / GetAdGroup
Last active December 5, 2021 17:07
Get Ad Group when it can't find a DC
$adGroupName = "Domain Users"
(get-adgroup $adGroupName -Server (Get-ADDomainController -Discover -Service ADWS -DomainName $env:USERDNSDOMAIN) -properties members).members