Skip to content

Instantly share code, notes, and snippets.

View PCfromDC's full-sized avatar

Patrick Curran PCfromDC

View GitHub Profile
@PCfromDC
PCfromDC / Sync AD to SQL.ps1
Last active November 8, 2019 16:55
This is a PowerShell script that grabs all users from AD and puts them into a SQL table.
# Array of Domain Controller Server Names
$DCs = @("DC01","DC02","DC03")
# Database Server
$dbServer = "sql2012-03"
# Database Name
$databaseName = "pcDemo_Personnel"
# Production System User Table Name
@PCfromDC
PCfromDC / 4- Install SQL03.ps1
Last active November 25, 2015 20:38
Ignite 2015 session Using Desired State Configuration to Deploy SQL
$nodeName = "SQL03"
Configuration SQL2014 {
param ($nodeName)
Node $nodeName {
#region Set Parameters
$isoName = "en_sql_server_2014_enterprise_edition_x64_dvd_3932700.iso"
@PCfromDC
PCfromDC / 3- Create AD Accounts.ps1
Last active November 25, 2015 20:38
Ignite 2015 session Using Desired State Configuration to Deploy SQL
# Active Directory Module for PowerShell feature needs to be installed
# spAccounts.csv can be downloaded from: http://1drv.ms/1bHTZC0
Import-Module ActiveDirectory -EA 0
# Create AD Users and Groups
#region Parameters
$file = "C:\DevOps\Microsoft\SQL Server 2014\config\spAccounts.csv"
@PCfromDC
PCfromDC / 2- Add SQL03 to Domain.ps1
Last active November 25, 2015 20:37
Ignite 2015 session Using Desired State Configuration to Deploy SQL
$domain = "contoso.local"
$newName ="SQL03"
$OUPath = # to put computer in specific OU
$prefixLength = 24 # PrefixLength of 24 equals a subnet mask of 255.255.255.0
# Update Description
Write-Host -ForegroundColor Green "Updating server description..."
$desc = Get-WmiObject -Class Win32_OperatingSystem
$desc.Description = $newName
$desc.put()
@PCfromDC
PCfromDC / 1- Create SQL03 VM.ps1
Last active November 25, 2015 20:37
Ignite 2015 session Using Desired State Configuration to Deploy SQL
$serverName = "SQL03"
$vmName = "3- SQL03"
$vmDest= "G:\VMs\$serverName\"
$isoName = "z_Master-Server2012R2-Standard.vhdx"
$isoPath = "D:\_Images\"
# VM Host Name
$computerName = "Host-HP-01"
# Network
$switchName = "pcDemo-1"
@PCfromDC
PCfromDC / 01- sp2016 Enable Windows Features.ps1
Last active November 29, 2017 23:04
sp2016 Enable Windows Features
#region Create Server 2012R2 Features Array
function getServer2012R2Features {
$windows2012R2Features = @(
"Application-Server",
"AS-NET-Framework",
"AS-Web-Support",
"FileAndStorage-Services",
"Storage-Services",
"Web-Server",
"Web-WebServer",
@PCfromDC
PCfromDC / 02- sp2016 Download Prerequisite Files.ps1
Last active November 14, 2017 20:20
sp2016 Download Prerequisite Files
Import-Module BitsTransfer
$destPath = "C:\tempDownloads" # Change this to desired download destination path
$destPath = $destPath.TrimEnd('\')
#region validate download path
function validatePath($destFolder){
## Check that the path entered is valid
If (!(Test-Path $destFolder -Verbose)) {
New-Item -Path $destFolder -ItemType Directory
@PCfromDC
PCfromDC / 03- sp2016 Install Prerequisite Files.ps1
Last active November 14, 2017 20:20
sp2016 Install Prerequisite Files
# set varibles
$sp2016Location = "D:\" # Change to folder location of SharePoint prerequisiteinstaller.exe file
$destPath = "C:\tempDownloads"
$sp2016preReqPath = Get-Content "$destPath\sp2016preReqPath.txt"
Import-Module Servermanager
#region Create variable paths and copy files
$sp2016preReqPath = $sp2016preReqPath.TrimEnd('\')
$sp2016Location = $sp2016Location.TrimEnd('\')
@PCfromDC
PCfromDC / Getting Your SharePoint Farm Information.ps1
Last active June 13, 2016 18:19
This PowerShell script gets all of your SharePoint Farm's information
#Get Backup Path
$bkdir = read-host("Enter Folder Location eg: (C:\temp)") # Get Backup Path!
if ($bkdir.EndsWith("\")){$bkdir = $bkdir.TrimEnd("\")}
# Set Backup Path if you want to hard code your path
#$bkdir = "\\serverName\Shared\Temp" (optional "C:\Temp")
# Verify folder exists
if ((test-path $bkdir) -eq $false ) # Verify folder else create it...
{
@PCfromDC
PCfromDC / 04- sp2016 Continue Install Prerequisite Files.ps1
Created November 25, 2015 20:26
04- sp2016 Continue Install Prerequisite Files
$destPath = "C:\tempDownloads"
$sp2016preReqPath = Get-Content "$destPath\sp2016preReqPath.txt"
Start-Process "$sp2016preReqPath\PrerequisiteInstaller.exe" -ArgumentList ("/continue /unattended") -Wait