This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Create Log In Task | |
$user = whoami | |
$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..." | |
$sj = Register-ScheduledJob –Name $jobName ` | |
-ScriptBlock $sb ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Create Resource Group | |
$rg = Get-AzureRmResourceGroup -Name $resourceGroup -Location $location -ErrorAction SilentlyContinue | |
if ($rg) { | |
Write-Host "$resourceGroup resource group already exists..." | |
} | |
else { | |
Write-Host "Creating $resourceGroup Resource Group..." | |
$rg = New-AzureRmResourceGroup -Name $resourceGroup -Location $location -Force | |
} | |
#endregion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:!function(e){function a(e,a){var n=/.+\//,o=e.href&&e.href.replace(n,"")||"",r="https://www.yammer.com/api/v1/uploaded_files/"+o+"/download";return r}function n(e){var a=document.createElement("a");a.download="filename",a.target="_blank",a.href=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),delete a}var o=Array.from(e.querySelectorAll(".page-content .yj-tabular-data-name"));o.map(a).forEach(n)}(document); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$restoreDir = "J:\Backups" | |
# Get files in backup directory | |
$files = get-childitem $restoreDir -recurse | |
foreach ($file in $files) | |
{ | |
$query = "RESTORE DATABASE [" + $file.basename + "] | |
FROM DISK = N'" + $restoreDir + $file + "' WITH FILE = 1, | |
MOVE N'" + $file.basename + "' TO N'" + $dataLocation + $file.basename + ".mdf', | |
MOVE N'" + $file.basename + "_log' TO N'" + $logLocation + $file.basename + "_log.LDF', | |
NOUNLOAD, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$bkdir = "\\SQL2012B\Shared\Temp" # Set Backup Path! | |
# SSMS needed to be installed to load the SQL Assemblies | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | out-null | |
$s = new-object ("Microsoft.SqlServer.Management.Smo.Server") $instance | |
# Grabs ALL of the databases | |
$dbs = $s.Databases | |
foreach ($db in $dbs) | |
{ | |
if(($db.Name -ne "tempdb") -and ($db.Name -ne "master") -and ($db.Name -ne "model") -and ($db.Name -ne "msdb")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region wait for 10 then Delete Old Files | |
# wait for 10 | |
for ($i = 10; $i -gt 0; $i--) { | |
Write-Host("Deleting old files in $i seconds") | |
Start-Sleep -Seconds 1 | |
} | |
# delete old files | |
foreach ($item in $items) { | |
Remove-Item -Path $item.CurrentLocation -Force | |
} |