Skip to content

Instantly share code, notes, and snippets.

View Kevin-Bronsdijk's full-sized avatar
😃
Happily writing code!

Kevin Bronsdijk Kevin-Bronsdijk

😃
Happily writing code!
View GitHub Profile
@Kevin-Bronsdijk
Kevin-Bronsdijk / azure-virtual-machine-reset-the-username_1.ps1
Created July 28, 2015 14:17
azure-virtual-machine-reset-the-username
$vmc = Get-AzureVM -ServiceName $serviceName -Name $vmName
$vmc.VM.ProvisionGuestAgent
@Kevin-Bronsdijk
Kevin-Bronsdijk / automatically-remove-azure-rdp-endpoints_1.ps1
Created July 28, 2015 14:24
automatically-remove-azure-rdp-endpoints
$endpointName = "RemoteDesktop"
$vms = Get-AzureVM | SELECT ServiceName, Name
Foreach ($vm in $vms)
{
$vmConfig = Get-AzureVM -ServiceName $vm.ServiceName -Name $vm.Name
# if found, remove and update
if ($vmConfig | Get-AzureEndpoint -Name $endpointName)
{
@Kevin-Bronsdijk
Kevin-Bronsdijk / automatically-deallocate-azure-vms_1.ps
Created July 28, 2015 14:38
automatically-deallocate-azure-vms
workflow Test
{
$Cred = Get-AutomationPSCredential -Name "auto"
Add-AzureAccount -Credential $Cred
Get-AzureVM
}
@Kevin-Bronsdijk
Kevin-Bronsdijk / microsoft-azure-automation-101_1.ps1
Created July 28, 2015 14:44
microsoft-azure-automation-101
workflow Runbook1
{
}
@Kevin-Bronsdijk
Kevin-Bronsdijk / Seek_and_ye_shall_find_sp_what.sql
Created July 28, 2015 14:50
Seek_and_ye_shall_find_sp_what
CREATE PROCEDURE dbo.sp_what
@searchFor nvarchar(50)
AS
-- Find Tables, Views
SELECT
a.name,
a.[object_id],
CAST(a.[schema_id] AS VARCHAR(5)) + ' - '+ s.name AS [schema],
[type_desc],
'EXEC sp_columns [' + a.name + '], [' + s.name +']' AS details,
@Kevin-Bronsdijk
Kevin-Bronsdijk / Move_Azure_Virtual_Machine_to_a_different_data_center_1.ps1
Last active April 25, 2016 22:03
Move_Azure_Virtual_Machine_to_a_different_data_center
Get-AzureVM -ServiceName "name_cloud_service" -Name "vm_name"
Get-AzureVM -ServiceName "name_cloud_service" -Name "vm_name" | Get-AzureEndpoint
@Kevin-Bronsdijk
Kevin-Bronsdijk / database-integrity-history-reports_1.ps1
Created July 28, 2015 15:23
database-integrity-history-reports
Import-Module SQLPS
@Kevin-Bronsdijk
Kevin-Bronsdijk / sql-server-keeping-it-simple-default-to-simple-recovery-model.ps1
Created July 28, 2015 15:34
sql-server-keeping-it-simple-default-to-simple-recovery-model
Import-Module SQLPS -DisableNameChecking
#replace this with your instance name
$instanceName = "server\instance";
$server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName;
$server.ConnectionContext.ConnectTimeout = 2200;
$server.ConnectionContext.StatementTimeout=2200;
$databases = $server.Databases;
@Kevin-Bronsdijk
Kevin-Bronsdijk / automatically-deallocate-azure-vms.ps1
Created July 28, 2015 15:38
automatically-deallocate-azure-vms
#Change VMName, Service Name and min/max values in hours
$ExpectedUptime = 6
$ForceShutdownAfter = 8
$VMName = "name of VM"
$ServiceName = "Name of service"
$Now = Get-Date
$Wmi = Get-WmiObject -ComputerName $Env:COMPUTERNAME -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem"
$LastReboot = $Wmi.ConvertToDateTime($Wmi.LastBootUpTime)
$Uptime = $Now - $LastReboot
@Kevin-Bronsdijk
Kevin-Bronsdijk / management-studio-query-shortcuts.sql
Created July 28, 2015 15:48
management-studio-query-shortcuts
CREATE PROCEDURE Debugging (@value varchar(150))
AS
BEGIN
-- Something interesting
SELECT CONCAT('hello ', @value)
END