Skip to content

Instantly share code, notes, and snippets.

View adbertram's full-sized avatar

Adam Bertram adbertram

View GitHub Profile
#Requires -Version 3
<#
.SYNOPSIS
This script checks a ConfigMgr site backup to ensure success and performs various post-backup functions that
back up other critical data that the built-in ConfigMgr site backup task does not.
.DESCRIPTION
This script checks any previous backup attempt ran within the last hour of this script running for a
a successful run if backup check is selected. It assumes you also have SSRS installed on the site DB server
and backs up both SSRS databases, exports out the SSRS encryption keys, backs up the export file and the
<#
.NOTES
Created on: 5/22/2014 10:56 AM
Created by: Adam Bertram
Filename: Remove-CMDirectoryMembershipRule.ps1
Credits: http://www.david-obrien.net/2013/02/24/remove-direct-membership-rules-configmgr/
.DESCRIPTION
This script removes all direct membership rules from a specified collection name
.EXAMPLE
.\Remove-CMDirectMembershipRule.ps1 -SiteCode 'CON' -SiteServer 'SERVERNAME' -CollectionName 'NAMEHERE'
## From the adamtheautomator.com blog
Function Get-SccmClientLog ($ComputerName,$LogName) {
try {
Write-Debug "Initiating the $($MyInvocation.MyCommand.Name) function...";
$output_properties = @{'ComputerName'=$ComputerName;'Log'=$LogName}
if ($LogName -ne 'setup') {
$sPath = "\\$ComputerName\admin$\ccm\logs"
$aLogData = @();
@adbertram
adbertram / Get-EventsInTimeframe.ps1
Last active December 14, 2020 16:34
events in timeframe
## Found at https://adamtheautomator.com/get-eventlog-powershell/
<#
.SYNOPSIS
This script searches a Windows computer for all event log or text log entries
between a specified start and end time.
.DESCRIPTION
This script enumerates all event logs within a specified timeframe and all text logs
that have a last write time in the timeframe or contains a line that has a date/time
reference within the timeframe. It records this information to a set of files and copies
---
- hosts: azurevms
gather_facts: no
tasks:
- name: Install IIS features
win_feature:
name:
- Web-Server
- Web-Common-Http
- Web-Mgmt-Service
## Ensure you're using 2.0+ of the azurevm provider to get the azurerm_windows_virtual_machine reosurce and
## the other resources and capabilities
provider "azurerm" {
version = "2.0.0"
features {}
}
## Create an Azure resource group using the value of resource_group and the location of the location variable
## defined in the terraform.tfvars file.
resource "azurerm_resource_group" "monolithRG" {
#region Ensure the WinRm service is running
Set-Service -Name "WinRM" -StartupType Automatic
Start-Service -Name "WinRM"
#endregion
#region Enable PS remoting
if (-not (Get-PSSessionConfiguration) -or (-not (Get-ChildItem WSMan:\localhost\Listener))) {
Enable-PSRemoting -SkipNetworkProfileCheck -Force
}
#endregion
## Define each computer you'd like to run the install on
$computers = 'COMP1','COMP2','COMP3'
## This is the path that contains the installer file for the software you'd like to install on the servers
$softwarePath = '\\MEMBERSRV1\Software'
## Read each of the computers in the $computers array defined above
foreach ($pc in $computers) {
## Copy \\MEMBERSRV1\Software to each target computers' C:\Windows\Temp folder
Copy-Item -Path $softwarePath -Destination "\\$pc\c$\Windows\Temp"
#region Var setup
## Be sure to fill in your values here
$resourceGroupName = 'AcmeApp'
$region = 'xxxxxxx'
$localVMAdminPw = 'I like azure.' ## a single password for demo purposes
$sqlAdminUsername = 'sqladmin'
$sqlAdminPw = 'I like azure.'
$projectName = 'AcmeApp' ## common term used through set up
$resourceGoupName = 'skylinespsdemo'
$azureRegion = 'East US'
$vmName = 'MYVM'
#region Create the resource group
New-AzResourceGroup -Name $resourceGoupName -Location $azureRegion
#endregion
#region Create the vNet for the VM
$newSubnetParams = @{