Skip to content

Instantly share code, notes, and snippets.

@kmhuglen
kmhuglen / HKCU_Outlook_2013_ForceAcountSelection.reg
Last active August 29, 2015 14:21
Outlook 2013 Force Account Selection
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\15.0\outlook\options]
"forceaccountselection"=dword:00000001
@kmhuglen
kmhuglen / HKCU_Outlook_2010_ForceAcountSelection.reg
Created May 13, 2015 14:31
Outlook 2010 Force Account Selection
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\outlook\options]
"forceaccountselection"=dword:00000001
Param(
$ComputerName
,
$Filter ="*.dwg"
)
IF (-Not($ComputerName)) {$ComputerName = $env:COMPUTERNAME}
$dfsmemberships = Get-DfsrMembership -GroupName * -ComputerName $ComputerName
$dfsrPreservedFiles = $null
@kmhuglen
kmhuglen / HKCU_Outlook_2016_ForceAcountSelection.reg
Created August 3, 2015 11:04
Outlook 2016 Force Account Selection
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\outlook\options]
"forceaccountselection"=dword:00000001
@kmhuglen
kmhuglen / Example_SendMailScript.ps1
Last active August 29, 2015 14:26
Example of how to use Send-MailMessage with conditionally CC and BCC arguments
[string]$MailFrom = "me@domain.com"
[array]$MailTo = "you@domain.com", "other@domain.com"
[string]$MailSubject = "my subject"
[string]$MailBody = @"
<b>Heading</b>
Some text<br>
New Line with more text<br>
"@
[string]$MailServer = "smtp.domain.com"
@kmhuglen
kmhuglen / Assert-AutoShutdownSchedule.ps1
Last active October 28, 2015 05:19
Custom Assert-AutoShutdownSchedule.ps1 with TimeZone parameter
<#
.SYNOPSIS
This Azure Automation runbook automates the scheduled shutdown and startup of virtual machines in an Azure subscription.
.DESCRIPTION
The runbook implements a solution for scheduled power management of Azure virtual machines in combination with tags
on resource groups which define a shutdown schedule. Each time it runs, the runbook looks for all resource groups with
a tag named "AutoShutdownSchedule" having a value defining the schedule, e.g. "10PM -> 6AM". It then checks the current
time against each schedule entry, ensuring that VMs in tagged groups are shut down or started to conform to the schedule.
# Define query criteria
$Class = Get-SCSMClass Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity$
$InProgress = (Get-SCSMEnumeration ActivityStatusEnum.Active).id.guid
$Yesterday = (get-date).AddDays(-1)
$cType = "Microsoft.EnterpriseManagement.Common.EnterpriseManagementObjectCriteria"
$cString = "Status = '$InProgress' and LastModified > '$yesterday'"
$crit = new-object $cType $cString,$Class
# Get activities
$Activities = Get-SCSMObject -criteria $crit
$SMServer = '{Service Manager Server}'
$selectedobjectobjectdisplayname = '{Windows Computer Principal Name}'
### Check if object is selected, if not exit
if($selectedobjectobjectdisplayname -eq $null) {
$Businessservice = "ObjectNotDefined"
exit
}
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputerName = WshNetwork.ComputerName
Set objADSysInfo = CreateObject("ADSystemInfo")
strDNSDomainName = objADSysInfo.DomainDNSName
`###########################################################################
strEmailAddressFROM = strComputerName & "@" & strDNSDomainName
strEmailAddressTO = "example@domain.net"
strSMTPServerName = "smtp.example.net"
strSMTPServerPort = 25
`CheckDiskVolume DiskVolume, MinFreeDiskSpace
Option Explicit
Dim objRootDSE, adoConnection, adoCommand, strQuery
Dim adoRecordset, strDNSDomain, objShell, lngBiasKey
Dim lngBias, k, strDN, dtmDate, objDate
Dim strBase, strFilter, strAttributes, lngHigh, lngLow
Dim objFileSystem, objOutputFile, strOutputFile
strOutputFile = "./" & Split(WScript.ScriptName, ".")(0) & ".csv"
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, TRUE)
` Obtain local Time Zone bias from machine registry.