Skip to content

Instantly share code, notes, and snippets.

View jeffpatton1971's full-sized avatar
😄
Writing code 25 hours a day, 8 days a week!

Jeff Patton jeffpatton1971

😄
Writing code 25 hours a day, 8 days a week!
View GitHub Profile
@jeffpatton1971
jeffpatton1971 / Stop-AzureVM.ps1
Last active April 21, 2017 19:35
A workflow to poweroff/on vm's in a resourcegroup
workflow Stop-AzureVM
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[string[]]$VMList,
[Parameter(Mandatory=$true)]
[string]$ResourceGroupName,
[Parameter(Mandatory=$true)]
@jeffpatton1971
jeffpatton1971 / Get-CloudBlob.ps1
Created March 31, 2017 17:07
A simple script to return the blobs in a container, you will need to be logged into an Azure subscription with Login-AzureRMAccount before this will return anything
param
(
[Parameter(Mandatory=$true,Position=0)]
[string]$ResourceGroupName,
[Parameter(Mandatory=$true,Position=1)]
[string]$StorageAccountName,
[Parameter(Mandatory=$true,Position=2)]
[string]$Container
)
@jeffpatton1971
jeffpatton1971 / README.md
Last active April 1, 2017 16:58
This script is designed to either start or stop a group of VM's in a Resource Group in Azure.

UpdatePowerState

This script and workflow is designed to either start or stop a group of VM's in a Resource Group in Azure. The script/workflow has 3 parameters:

  • AzureConnectionAssetName
  • ResourceGroupName
  • PowerState

AzureConnectionAssetName

This defaults to AzureRunAsConnection which is the default connection name Azure creates when running through the Azure Automation Account wizard.

@jeffpatton1971
jeffpatton1971 / Enable-WinRM.ps1
Created February 4, 2017 15:12
This script will enable WinRM
param
(
[string]$Hostname = $env:COMPUTERNAME
)
try
{
$ErrorActionPreference = 'Stop';
$CertificateThumbprint = (New-SelfSignedCertificate -DnsName $Hostname -CertStoreLocation Cert:\LocalMachine\My).Thumbprint;
New-WSManInstance -ResourceURI 'winrm/config/listener' -SelectorSet @{Address='*';Transport='https'} -ValueSet @{Hostname=$Hostname;CertificateThumbprint=$CertificateThumbprint}
}
@jeffpatton1971
jeffpatton1971 / StorageAccountCopy.ps1
Last active January 31, 2017 15:59
A script to copy Blobs between Azure Storage Accounts
param
(
[string]$SourceStorageAccountName,
[string]$SourceStorageAccountResourcegroupName,
[string]$SourceStorageAccountContainerName,
[string]$DestStorageAccountKey,
[string]$DestStorageAccountContainerName
)
try
@jeffpatton1971
jeffpatton1971 / LinuxConfiguation.ps1
Created December 31, 2016 15:20
Simple configuration, all vm's with role == server should get user01 and all vm's with role == webserver should get apache installed.
Configuration LinuxConf
{
Import-DscResource -ModuleName nx
Node $AllNodes.Where{$_.Role -like "*server"}.NodeName
{
nxUser NewAccount
{
UserName = 'user01'
Ensure = 'Present'
Param
(
[Parameter(Mandatory=$true)]
[string]$VirtualNetworkName,
[Parameter(Mandatory=$false)]
[string]$SubnetName = '',
[Parameter(Mandatory=$true)]
[string]$Location,
[Parameter(Mandatory=$true)]
[string]$ResourceGroupName
@jeffpatton1971
jeffpatton1971 / Update-PowerState.ps1
Last active July 28, 2016 17:36
A modification of the AzureAutomation Start-AzureV2VM script (https://github.com/azureautomation/runbooks/blob/master/Utility/Start-AzureV2VM.ps1). This script takes PowerState as a parameter, and checks to see if the vm is in the properstate before attempting the operation. Added a Workflow version of the same script that should run faster, the…
param
(
[Parameter(Mandatory=$false)]
[string]$AzureConnectionAssetName = 'AzureRunAsConnection',
[Parameter(Mandatory=$false)]
[string]$ResourceGroupName,
[Parameter(Mandatory=$true)]
[ValidateSet('PowerState/running','PowerState/deallocated')]
[string]$PowerState
)
@jeffpatton1971
jeffpatton1971 / Enable-AzureNSGDiagnostics.ps1
Created January 14, 2016 23:06
A script that will enable diagnostics on network security groups. This will add the logs to a specific storage account.
Param
(
[string]$StorageAccountName,
[string]$StorageAccountResourceGroup
)
try
{
$ErrorActionPreference = "Stop"
$Error.Clear()
@jeffpatton1971
jeffpatton1971 / Enable-AzureNSGDiagnostics.ps1
Last active January 15, 2016 17:17
This is my take of the onboarding code for network security groups. There is no armclient dependency, but you will need the latest Azure Powershell Cmdlets installed.
Param
(
[string]$StorageAccountName,
[string]$StorageAccountResourceGroup
)
try
{
$ErrorActionPreference = "Stop"
$Error.Clear()