Skip to content

Instantly share code, notes, and snippets.

View PCfromDCSnippets's full-sized avatar

Patrick Curran PCfromDCSnippets

View GitHub Profile
@PCfromDCSnippets
PCfromDCSnippets / Create-VmUserRole.sql
Created October 25, 2019 19:57
Create-VmUserRole
/** Run on Master DB **/
/** Change variables to name of VM needing Access to Azure DB **/
DECLARE @vmName1 NVARCHAR(20) = 'AzDO-01'
/** Declare query variables **/
DECLARE @query1 NVARCHAR(MAX),
@query2 NVARCHAR(MAX)
/** Update @vmName1 **/
@PCfromDCSnippets
PCfromDCSnippets / Add-VmUserToDatabase.sql
Last active October 25, 2019 19:55
Add-VmUserToDatabase
/** Run this script on all Configuation and Colletion Databases **/
/** Change variables to name of VM needing Access to Azure DB **/
DECLARE @vmName1 NVARCHAR(20) = 'AzDO-01'
/** Declare query variables **/
DECLARE @query1 NVARCHAR(MAX),
@query2 NVARCHAR(MAX),
@query3 NVARCHAR(MAX)
@PCfromDCSnippets
PCfromDCSnippets / Install Azure DevOps Server 2019.ps1
Created October 25, 2019 19:48
Install Azure DevOps Server 2019
#region Install AzDO
$path = "W:\Downloads\Azure DevOps Server\azuredevopsserver2019.0.1.exe"
Start-Process $path -ArgumentList "/Full /Passive" -Wait
#endregion
@PCfromDCSnippets
PCfromDCSnippets / createScheduledTask.ps1
Last active December 15, 2017 20:42
Create Scheduled Task to Run As User
#region Create Scheduled Task as User
$jobName = "Azure S2S IP Checker"
$filePath = 'C:\Scripts\Update S2S and RRAS.ps1'
$cred = Get-Credential -Message "Enter Run As Credentials..."
$sj = Get-ScheduledJob -Name $jobName -ErrorAction SilentlyContinue
if ($sj.count -gt 0) {
Write-Host "$jobName scheduled job already exists..."
}
else {
Write-Host "Creating $jobName scheduled Job..."
@PCfromDCSnippets
PCfromDCSnippets / S2SConnection.ps1
Created December 15, 2017 20:35
Connect RRAS VpnS2SInterface
$connections = (Get-VpnS2SInterface).Name
foreach ($connection in $connections) {
Connect-VpnS2SInterface -Name $connection
}
@PCfromDCSnippets
PCfromDCSnippets / updateLogs.ps1
Created December 15, 2017 20:30
Update Log File
function Update-Logs ($content) {
$logPath = 'C:\S2S Logs'
if (-not (Test-Path -Path $logPath)) {New-Item -Path $logPath -ItemType Directory}
$date = Get-Date
$lastMonth = $date.AddMonths(-1)
$fileName = $date.ToString("yyyy-MM-dd") + "- S2S Log.txt"
$filePath = ($logPath + "\" + $fileName)
$exists = Test-Path $filePath
if ($exists) {
$string = (Get-Date).ToShortTimeString().ToString() + " $content"
@PCfromDCSnippets
PCfromDCSnippets / updateAzureLocalNetworkGateway.ps1
Created December 15, 2017 20:20
Update Azure Local Network Gateway IP
Param (
[string]$resourceGroup = "Networking-US-East-2",
[string]$localGatewayName = "LocalGateway-HQ",
[string]$location = "East US 2",
[string]$lgwSubnetPrefix = "192.168.0.0/21"
)
function Get-LocalIP {
$wc = New-Object net.webclient
$localIP = $wc.downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]"
@PCfromDCSnippets
PCfromDCSnippets / update RBAC.ps1
Created December 15, 2017 16:59
Add User to Azure Access Control
Param (
[string]$subscriptionName = "mySubscription",
[string]$resourceGroupName = "Networking",
[string]$localGatewayName = "LocalGateway",
[string]$userID = "508bb5e1-898e-user-9a71-47de815db2af"
)
Login-AzureRmAccount -SubscriptionName $subscriptionName
$ID = Get-AzureRmResourceGroup $resourceGroup1 | Get-AzureRmLocalNetworkGateway -Name $localGatewayName | select Id
@PCfromDCSnippets
PCfromDCSnippets / Create MSOL User.ps1
Last active December 15, 2017 16:47
Create MSOL User
Param (
[string]$displayName = "SVC-Nework-Gateway-Updater",
[string]$firstName = "Network-Gateway",
[string]$lastName = "Updater-Account",
[string]$upn = "[email protected]",
[string]$password = "MyPassword#12345",
[string]$usageLocation = "US"
)
$oCred = Get-Credential -Message "Enter Admin Credentials for O365..."
@PCfromDCSnippets
PCfromDCSnippets / get-msol.ps1
Created December 15, 2017 12:38
Get Latest MSOL Module
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$false
Install-Module -Name MSOnline -AllowClobber -Confirm:$false