Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

145

Downloads of v 0.2.6:

145

Last Update:

25 Dec 2014

Package Maintainer(s):

Software Author(s):

  • Manimaran Chandrasekaran

Tags:

azure powershell automation devops windows

AutomateThinkable

Downloads:

145

Downloads of v 0.2.6:

145

Maintainer(s):

Software Author(s):

  • Manimaran Chandrasekaran

AutomateThinkable

  • 1
  • 2
  • 3

Some Checks Have Failed or Are Not Yet Complete

Not All Tests Have Passed


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Unknown

WARNING

This package was rejected on 30 Jan 2016. The reviewer chocolatey-ops has listed the following reason(s):

Thanks for this package.

The package icon looks a bit ugly. Is there a better icon (see our icon guidelines https://github.com/chocolatey/chocolatey/wiki/CreatePackages#package-icon-guidelines)?

If not, please remove the current icon and re-submit the same package version.

Thanks

Tom

chocolatey-ops (reviewer) on 21 Nov 2015 18:48:22 +00:00:

AutomateThinkable has passed testing.
Please visit https://gist.github.com/2f726661143d8bf0fb51 for details.
This is an FYI only. There is no action you need to take.

chocolatey-ops (reviewer) on 20 Dec 2015 08:30:05 +00:00:

AutomateThinkable has passed automated validation.
NOTICE: We are permanently fixing our backlog issues and we want to apologize that it has taken so long - please see http://goo.gl/aYqJy0.

NOTE: No required changes that the validator checks have been flagged! It is appreciated if you fix other items, but only Requirements will hold up a package version from approval. A human review could still turn up issues a computer may not easily find.

Guidelines

Guidelines are strong suggestions that improve the quality of a package version. These are considered something to fix for next time to increase the quality of the package. Over time Guidelines can become Requirements. A package version can be approved without addressing Guideline comments but will reduce the quality of the package.

  • The nuspec has been enhanced to allow packageSourceUrl, pointing to the url where the package source resides. This is a strong guideline because it simplifies collaboration. Please add it to the nuspec. More...
  • Summary (summary) is a short explanation of the software. Please include summary in the nuspec. More...
  • Title (title) is missing. Please consider including title in the nuspec. More...
  • There are more than 3 automation scripts in this package. This is not recommended as it increases the complexity of the package. More...
Suggestions

Suggestions are either newly introduced items that will later become Guidelines or items that are don't carry enough weight to become a Guideline. Either way they should be considered. A package version can be approved without addressing Suggestion comments.

  • The nuspec has been enhanced to allow more information related to the software. More... Please consider adding one or more of the following to the nuspec, if available:
    • docsUrl - points to the location of the wiki or docs of the software
    • mailingListUrl - points to the forum or email list group for the software
    • bugTrackerUrl - points to the location where issues and tickets can be accessed
    • projectSourceUrl - points to the location of the underlying software source
  • As per the packaging guidelines icons should be either a png or svg file. More...
Notes

Notes typically flag things for both you and the reviewer to go over. Sometimes this is the use of things that may or may not be necessary given the constraints of what you are trying to do and/or are harder for automation to flag for other reasons. Items found in Notes might be Requirements depending on the context. A package version can be approved without addressing Note comments.

  • The package maintainer field (owners) matches the software author field (authors) in the nuspec. The reviewer will ensure that the package maintainer is also the software author. More...

chocolatey-ops (reviewer) on 15 Jan 2016 00:02:51 +00:00:

We've found AutomateThinkable v0.2.6 in a submitted status and waiting for your next actions. It has had no updates within 20 days after a reviewer has asked for corrections. Please note that if there is no response or fix of the package within 15 days of this message, this package version will automatically be closed (rejected) due to being stale.

Take action:

  • Log in to the site and respond to the review comments.
  • Resubmit fixes for this version.
  • If the package version is failing automated checks, you can self-reject the package.

If your package is failing automated testing, you can use the chocolatey test environment to manually run the verification and determine what may need to be fixed.

Note: We don't like to see packages automatically rejected. It doesn't mean that we don't value your contributions, just that we can not continue to hold packages versions in a waiting status that have possibly been abandoned. If you don't believe you will be able to fix up this version of the package within 15 days, we strongly urge you to log in to the site and respond to the review comments until you are able to.

chocolatey-ops (reviewer) on 30 Jan 2016 00:07:23 +00:00:

Unfortunately there has not been progress to move AutomateThinkable v0.2.6 towards an approved status within 15 days after the last review message, so we need to close (reject) the package version at this time. If you want to pick this version up and move it towards approval in the future, use the contact site admins link on the package page and we can move it back into a submitted status so you can submit updates.

Status Change - Changed status of package from 'submitted' to 'rejected'.

Description

This Package contains all the scripts required for setting up complete Infrastructure in Azure, configure the servers and deploy the code


azureinfrastructureascode\AzureFileservices.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script sets up the basic framework for all the Azure file and network share services.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : AzureFileservices.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 11/23/2014 07:51:20
    .LINK
        https://azureautomation.wordpress.com/
#>
# create a context for account and key


Function  Uploadfiles
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : Uploadfiles
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 07:55:12
        .LINK
            https://azureautomation.wordpress.com/
    #>
 [CmdletBinding()]
 Param
     (
       [string]$rootfolder = "C:\",
       [string]$basefolder = "publishsite",
       [String]$NWSharefolder = "DiDemoShare",
       [string]$azureStorageaccount = "azurenetworkfileshares",
       [string]$storageAccountKey = "GxAgGBZuxwRUp+JF6DR7QNO/YAoIrckSgLv0jxOi",
       [string]$azurenetworkshare = "stagearea"
     )
 Begin
  {
    $Storagectx=New-AzureStorageContext $azureStorageaccount $storageAccountKey

    $fileShareCtx = Get-AzureStorageShare -Name $azurenetworkshare -Context $Storagectx 

    if (!$fileShareCtx)
    {
    # create a new share if does not exists
    $fileShareCtx = New-AzureStorageShare $azurenetworkshare -Context $Storagectx

    }

     }
 Process
 {

    $Currentfolder = $rootfolder + $basefolder
    If ((Test-Path $Currentfolder))
    {
    # Get all the files including subdirectories
    $files = ls -Path $Currentfolder -File -Recurse
    # Get all the folders/subdfolders 
    $allsubdir = ls -Path $Currentfolder -Directory -Recurse


    # upload a local files/folders to the directory just created in azure file share
    if ($allsubdir.Count -gt 0)
        {
            if (!(Get-AzureStorageFile -Share $fileShareCtx -Path DiDemoShare -Verbose | `
                where {$_.Name -eq $basefolder}))
            {
            New-AzureStorageDirectory -Share $fileShareCtx -Path  DiDemoShare/$basefolder
            }
            Write-Host $allsubdir

                foreach($subdir in $allsubdir)
                {
                    try
                    {
                    $tmpsubdir = '/' + $subdir
                    $tempsubstr1 = Split-Path -Path $subdir.FullName.ToString().`
                        Substring($Currentfolder.Length) -NoQualifier

                    $tempsubstr = $NWSharefolder + $tempsubstr1.Replace("\","/")
                    $rootdirpath = $tempsubstr.Substring(0,$tempsubstr.ToString().LastIndexOf("/"))
                    Write-Host $tempsubstr $rootdirpath
                    if (!(Get-AzureStorageFile -Share $fileShareCtx -Path $rootdirpath -Verbose `
                         | where {$_.Name -eq $subdir}))
                    {
                        New-AzureStorageDirectory -Share $fileShareCtx -Path  $tempsubstr
                    }
                    }
                catch 
                {
                    Write-Error ("This is error message" + $_.Tostring())
                    $warningMessage = "Unable to create directory " + $file.FullName
                    Write-Warning -Message $warningMessage
                 }
             }
          
            
            foreach ($file in $Files) 
            
                {
                try
                {
                $tempstr = Split-Path -Path $file.FullName.ToString().Substring($Currentfolder.Length) -NoQualifier
                $Sharepath = $NWSharefolder + $tempstr.Replace("\","/")
                Set-AzureStorageFileContent -Share $fileShareCtx -Source $file.FullName `
                    -Path $Sharepath -Force -Verbose 
                }

                catch 
                {
                    Write-Error ("This is error message" + $_.Tostring())
                    $warningMessage = "Unable to upload file " + $file.FullName
                    Write-Warning -Message $warningMessage
                }
        
        }
    }
    }
    else
    {
    Write-Warning ("No Local folder exists")
    }
     }
 End
 {
     }
 }
azureinfrastructureascode\AzureVNetSetup.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script sets up the basic framework for all the virtual network configuration in azure cloud service.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : AzureVNetSetup.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 11/23/2014 07:51:20

    .LINK
        https://azureautomation.wordpress.com/
#>
function New-AzureVNetConfiguration 

{
	[CmdletBinding()]
	param 
	(
	[string]$newDnsServerName = 'DiLabs.edu',
	[string]$newDnsServerIP = '172.16.0.4',
	[string]$newVNetName = 'DILabsVNET',
	[string]$newVNetLocation = 'West Europe',
	[string]$newVNetAddressRange = '172.16.0.0/12',
	[string]$newSubnetName = 'Subnet-1',
	[string]$newSubnetAddressRange = '172.16.0.0/15',
	[string]$configFile = "C:\AzureVNetConfig.XML"
	)

	begin
	{

    Write-Host "Deleting $configFile if it exists"
    Del $configFile -ErrorAction:SilentlyContinue
	 
	}

	process 
	{

	        Write-Host "Creating Empty template for Azure Virtual Network"
        $newVNetConfig = [xml] '
        <NetworkConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration">
          <VirtualNetworkConfiguration>
            <Dns>
              <DnsServers>
                <DnsServer name="" IPAddress="" />
              </DnsServers>
            </Dns>
            <VirtualNetworkSites>
              <VirtualNetworkSite name="" Location="">
                <AddressSpace>
                  <AddressPrefix></AddressPrefix>
                </AddressSpace>
                <Subnets>
                  <Subnet name="">
                    <AddressPrefix></AddressPrefix>
                  </Subnet>
                </Subnets>
                <DnsServersRef>
                  <DnsServerRef name="" />
                </DnsServersRef>
              </VirtualNetworkSite>
            </VirtualNetworkSites>
          </VirtualNetworkConfiguration>
        </NetworkConfiguration>
        '

        Write-Host "Add VNet and DNS attribute values to XML template"
        $vmnetattrib = $newVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.VirtualNetworkSites.VirtualNetworkSite
        $vmnetattrib.SetAttribute('name', $newVNetName)
        $vmnetattrib.SetAttribute('Location', $newVNetLocation)
        $vmnetattrib.AddressSpace.AddressPrefix = $newVNetAddressRange
        $vmnetattrib.Subnets.Subnet.SetAttribute('name', $NewSubNetName)
        $vmnetattrib.Subnets.Subnet.AddressPrefix = $newSubnetAddressRange
        $vmnetattrib.DnsServersRef.DnsServerRef.SetAttribute('name', $newDnsServerName)
       
	    $Dnsattrib = $newVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.Dns.DnsServers.DnsServer
        $Dnsattrib.SetAttribute('name', $newDnsServerName)
        $Dnsattrib.SetAttribute('IPAddress', $newDnsServerIP)



        Write-Host "Get Current Cloud Azure VNet configuration from Azure subscription"
        $CurrentCloudVNetConfig = [xml] (Get-AzureVnetConfig).XMLConfiguration

        Write-Host "Identify the Current DNS servers into new VNet XML configuration"
        $CurrentDnsServers = $CurrentCloudVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.Dns.DnsServers
        if ($CurrentDnsServers.HasChildNodes) {
           ForEach ($CurrentDnsServer in $CurrentDnsServers.ChildNodes) { 
                if ($CurrentDnsServer.name -ne $newDnsServerName) {
                    $importedDnsServer = $newVNetConfig.ImportNode($CurrentDnsServer,$True)
                    $newVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.Dns.DnsServers.AppendChild($importedDnsServer) | Out-Null
                }
            }
        }

        Write-Host "Merge existing VNets into new VNet XML configuration"
        $CurrentVNets = $CurrentCloudVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.VirtualNetworkSites
        if ($CurrentVNets.HasChildNodes) {
            ForEach ($CurrentVNet in $CurrentVNets.ChildNodes) { 
                if ($CurrentVNet.name -ne $newVNetName) {
                    $importedVNet = $newVNetConfig.ImportNode($CurrentVNet,$True)
                    $newVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.VirtualNetworkSites.AppendChild($importedVNet) | Out-Null
                }
            }
        }

        Write-Host "Merge existing Local Networks into new VNet XML configuration"
        $CurrentLocalNets = $CurrentCloudVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.LocalNetworkSites
        if ($CurrentLocalNets.HasChildNodes) {
            $dnsNode = $newVNetConfig.NetworkConfiguration.VirtualNetworkConfiguration.Dns
            $importedLocalNets = $newVNetConfig.ImportNode($CurrentLocalNets,$True)
            $newVnetConfig.NetworkConfiguration.VirtualNetworkConfiguration.InsertAfter($importedLocalNets,$dnsNode) | Out-Null
        }

        Write-Host "Saving new VNet XML configuration to $configFile"
        $newVNetConfig.Save($configFile)

        Write-Host "Provisioning new VNet configuration from $configFile"
        Set-AzureVNetConfig -ConfigurationPath $configFile



	}


}
azureinfrastructureascode\CreateWindowsTaskScheduler.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script sets up the the Task scheduler for backup.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : CreateWindowsTaskScheduler.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 12/19/2014 07:51:20

    .LINK
        https://www.devopspractice.com/
#>

#Define all the variables

$TName = "BackupDatabase"
$TDesc = "Run a Backup powershell script through a scheduled task"
$TCmd = "c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"
$TScript = "C:\Users\mani_000\Documents\AzureAutomation\azureinfrastructureascode\Schedulebackup.ps1"
$TArg = "-WindowStyle Hidden -NonInteractive -Executionpolicy unrestricted -file $TScript"
$TaskStartTime = [datetime]::Now.AddHours(1)

$svc = new-object -ComObject("Schedule.Service")
$svc.Connect()
$Folder = $svc.GetFolder("\")

$TaskDef = $svc.NewTask(0) 
$TaskDef.RegistrationInfo.Description = "$TDesc"
$TaskDef.Settings.Enabled = $true
$TaskDef.Settings.AllowDemandStart = $true
#Define triggers just one time in this case
$trgs = $TaskDef.Triggers
$trigger = $trgs.Create(1) 
$trigger.StartBoundary = $TaskStartTime.ToString("yyyy-MM-dd'T'HH:mm:ss")
$trigger.Enabled = $true

$Action = $TaskDef.Actions.Create(0)
$action.Path = "$TCmd"
$action.Arguments = "$TArg"

#Under the root folder reistration
$Folder.RegisterTaskDefinition("$TName",$TaskDef,6,"System",$null,5)
azureinfrastructureascode\MapAzureFileShare.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script sets up the basic framework that I use for all my scripts.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : MapAzureFileShare.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 11/23/2014 07:51:20

    .LINK
        https://azureautomation.wordpress.com/
#>
# Below simple lines of code is used to make the Azure file shares
cmdkey /add:azurenetworkfileshares.file.core.windows.net /user:azurenetworkfileshares /pass:GxAgGBZuxwRUp+JF6DR7QNO/YAoIrckSgLv0jxOiZpS85+wJDLtE8jY7TmEBQHcysXQwxir2++JX5gxsLpIFNw==

$key = "GxAgGBZuxwRUp+JF6DR7QNO/YAoIrckSgLv0jxOiZpS85"
$StorageAccName = "azurenetworkfileshares"
$AzureStorageShareName = "stagearea"
$cmdnetshare = "net use x: \\$StorageAccName.file.core.windows.net\$AzureStorageShareName /u:$StorageAccName $Key"
Invoke-Expression -Command $cmdnetshare

azureinfrastructureascode\Schedulebackup.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script sets up the basic framework that I use for all my scripts.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : ScheduleBackup.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 12/19/2014 07:51:20

    .LINK
        https://www.devopspractice.com/
#>

$key = "GxAgGBZuxwRUp+JF6DR7QNO/YAoIrckSgLv0jxOiZpS85"
$StorageAccName = "azurenetworkfileshares"

# Below simple lines of code is used to make the Azure file shares
cmdkey /add:$StorageAccName.file.core.windows.net /user:$StorageAccName /pass:$key
$AzureStorageShareName = "stagearea"

$cmdnetshare = "net use x: \\$StorageAccName.file.core.windows.net\$AzureStorageShareName"
#Invoke-Expression -Command $cmdnetshare
$from = "C:\DemoSource"
$to = "C:\backups\"
$objSvc = Get-CimInstance -ComputerName $server -Query "SELECT Name, StartName, Status, State FROM Win32_Service WHERE StartName <> 'LocalSystem'" | ? { $_.StartName -notlike 'NT AUTHORITY*' -and $_.StartName -notlike 'NT SERVICE*' } | Select *
    if ($objSvc.Name -eq 'EventStoreService')
    {
        Write-Host "Service is installed on the destination server"
                
    }
    else
    {
        Write-Host "Service is not installed on the destination server"
    }
$timestamp = Get-Date -Format o | foreach {$_ -replace ":", "."}
#Create the backup directory if does not exists
New-Item -ItemType Directory -Path $to\logs
#Backup to the azure file shares
Robocopy $from $to /MT:20 > $to\logs\$timestamp.log


azureinfrastructureascode\StroageAccountBlobActions.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script contains all the functions release to storage actions of blog in the storage account.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : StroageAccountBlobActions.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 11/23/2014 07:51:20
    .LINK
        https://azureautomation.wordpress.com/
#> 
Function CreateStorageContainerinAzure
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : CreateStorageContainerinAzure
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 07:58:48
        .LINK
            https://azureautomation.wordpress.com/
    #>
 [CmdletBinding()]
 Param
     (
     $CreateStorageContainer
     )
 Begin
 {
     }
 Process
 {
     if ($CreateStorageContainer)
    {
        $existingContainer = Get-AzureStorageContainer | 
            Where-Object { $_.Name -like $StorageContainer }

        if ($existingContainer)
        {
            $msg = "Azure Storage container '" + $StorageContainer + "' already exists."
        }
        else
        {
                $newContainer = New-AzureStorageContainer -Name $StorageContainer
                "Azure Storage container '" + $newContainer.Name + "' created."
        }
    }
     }
 End
 {
     }
 }

Function DownloadBlobStorage
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : DownloadBlobStorage
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 07:59:12
        .LINK
            https://azureautomation.wordpress.com/
    #>
 [CmdletBinding()]
 Param
     (
    [string]$localContainerPath="C:\DemoSource\",
    [string]$SourceContainerName="stagearea41container"
     )
 Begin
 {
     }
 Process
{
# Following modifies the Write-Verbose behavior to turn the messages on globally for this session
$VerbosePreference = "Continue"

# Ensure the local path given exists. Create it if switch specified to do so.
if (-not (Test-Path $localContainerPath))
    {
     New-Item -Path $localContainerPath -ItemType Directory
    }

$localContainerPath = ""
if ($SourceContainerName -ne $null -and $SourceContainerName -ne "" )
{
    # Download blobs for the specified container.    
    $DestLocalPath = $localContainerPath + "\" + $SourceContainerName
    
    # Get a reference to the container.
    $container = Get-AzureStorageContainer -Name $SourceContainerName -ErrorAction SilentlyContinue
    if ($container -eq $null)
    {
        throw "Unable to Contact storage container '$SourceContainerName'."
    }

    # Copy blobs from storage container to local file path.
    $blobs = Get-AzureStorageBlob -Container $SourceContainerName
    foreach ($blob in $blobs)
    {
        $sourceBlob = $SourceContainerName + "\" + $blob.Name
        $destFilePath = $DestLocalPath + "\" + $blob.Name

        # Create a sub-directory using the container name.
        $destDirectory = [System.IO.Path]::GetDirectoryName($destFilePath)
        $destFilePath = $destDirectory + "\" + [System.IO.Path]::GetFileName($destFilePath)
        
        if (-not (Test-Path $destDirectory -PathType Container))
        {
            New-Item -Path $destDirectory -ItemType Directory -Force
        }
  
        # Copy blob from container to local path.
            Get-AzureStorageBlobContent `
                -Container $SourceContainerName -Blob $blob.Name -Destination $destFilePath -Force | `
                    Format-Table -Property Length,Name -AutoSize 
    }

}
else
{
    throw "Provide a valid storage container name using the 'SourceContainerName'"
}

 
     }
 End
 {
     }
 }

Function PushFilesToStorageContainer
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : PushFilesToStorageContainer
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 08:57:06
        .LINK
            https://code.google.com/p/mod-posh/wiki/StroageAccountActions#
    #>
 [CmdletBinding()]
 Param
     (
    [string]$LocalPath = 'C:\customscripts',
    [string]$StorageContainer = "scripts"
     )
 Begin
 {
     }
 Process
 {
 
    $VerbosePreference = "Continue"

    # Ensure the local path given exists.
    if (-not (Test-Path $LocalPath -IsValid))
    {
    throw "Source path '$LocalPath' does not exist.  Specify an existing path."
    }

    $files = ls -Path $LocalPath -File -Recurse
    if ($files -ne $null -and $files.Count -gt 0)
    {
   
        $time = [DateTime]::UtcNow
        

    if ($Files.Count -gt 0)
    {
        foreach ($file in $Files) 
        {
            $blobFileName1 = Split-Path -Path $file.FullName -NoQualifier
            $blobFileName = $blobFileName1.Substring($blobFileName1.ToString().LastIndexOf("\")+1)
            try
            {
                Set-AzureStorageBlobContent -Container $StorageContainer `
                    -File $file.FullName -Blob $blobFileName `
                    -Force
            }
            catch
            {
                  Write-Error ("This is error message" + $_.Tostring())
                $warningMessage = "Unable to upload file " + $file.FullName
                Write-Warning -Message $warningMessage
              
            }
        }
    }
    else
    {
    Write-Warning ("No files to upload")
    }
    $duration = [DateTime]::UtcNow - $time
    "Uploaded " + $files.Count + " files to blob container '" + $StorageContainer + "'."
    "Total upload time: " + $duration.TotalMinutes + " minutes."
}

     }
 End
 {
     }
 }
azureinfrastructureascode\VMProvisionActions.ps1
<#
    .SYNOPSIS
        Template script
    .DESCRIPTION
        This script sets up the basic framework for azure virtual machine provision.
    .PARAMETER
    .EXAMPLE
    .NOTES
        ScriptName : VMProvisionActions.ps1
        Created By : Manimaran Chandrasekaran
        Date Coded : 11/23/2014 07:51:20
     .LINK
        https://azureautomation.wordpress.com/
#>


Function CheckVMStatus
 {
    <#
        .SYNOPSIS  
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : CheckVMStatus
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 07:46:28
        .LINK
            https://azureautomation.wordpress.com/
    #>
 [CmdletBinding()]
 Param
     (
    [parameter(Mandatory=$true,ValueFromPipeline=$true)]
	[string]$vmname,
	[parameter(Mandatory=$true,ValueFromPipeline=$true)]
	[string]$vmservice
     )
 Begin
 {
     }
 Process
 {
 $CheckVMStatus = $true
	$VMStatus = Get-AzureVM	
	if ($VMStatus.InstanceName -eq $vmname)
	{
		write-Host "VM Check passed and Virtual Machine is available "
		Write-Host $VMStatus.Status 
		if ($VMStatus.Status -eq "ReadyRole")
		{
			$CheckVMStatus = $false
		}
		elseif ($VMStatus.OperationStatus -eq "StoppedDeallocated")
		{
			$CheckVMStatus = $true
		}
	}
	else
	{
	Write-host $VMStatus.OperationStatus
	}
	return $CheckVMStatus
     }
 End
 {
     }
 }


Function ProvisionVM

 {
    <#
        .SYNOPSIS
        .DESCRIPTION :  Function used to provision the first VM in the Microsft Azure Cloud 
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : ProvisionVM
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 07:48:32
        .LINK
            https://azureautomation.wordpress.com/
    #>
 [CmdletBinding()]
 Param
     (
     		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$vmname,
			[parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$vmservice ,
			[parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$subnetname,
			[parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$vNetName	,
			[parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$un,
			[parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$pwd,
            [parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$vmlocation,
            [parameter(Mandatory=$true,ValueFromPipeline=$true)]
			[string]$vmSize
     )
 Begin
 {
     }
 Process
 {
 	write-host $vmname  "," $vmservice  "," $subnetname ","  $vNetName
	
	Write-Host "Get the Windows Azure Image with Latest Build"
	$Image = Get-AzureVMImage | Select Imagename , label | Where-Object {$_.Label -like 'Windows Server 2012 R2 Datacenter*'} `
	| select -first 1
	$iname = $Image.Imagename
	Write-Host "This is the Windows Image we will be using to provision the VM" + $iname
	
	Write-Host "Check if the Azure Cloud service exists"
	$srvstatus = Get-AzureService -ServiceName $vmservice
	if ($srvstatus)
		{
			Write-Host $vmservice  "   Azure Cloud Service already exists"
		}
		else
		{
			New-AzureService -ServiceName $vmservice -Location $vmlocation
		}
	$vmexists = CheckVMStatus $vmname.ToString()	$vmservice.ToString()
	if ($vmexists)
	{ 
	#Check if VM already exists
	$vm = New-AzureVMConfig -Name $vmname -InstanceSize $vmSize -Image $Image.ImageName
	$vm | Add-AzureProvisioningConfig -Windows -AdminUserName $un -Password $pwd
	$vm | Add-AzureEndpoint -Name "http" -Protocol tcp -LocalPort 80 -PublicPort 80 
	$vm | Set-AzureSubnet -SubnetNames $subnetName
	$vm | New-AzureVM -ServiceName $vmservice	-VnetName $vNetName -WaitForBoot 
	Write-Host $vm
	}
	else
	{
		write-Host "VM Exists, Cannot be recreated with same name, Please change the parameters"
	}
		
     }
 End
 {
     }
 }

Function  CleanUp
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : CleanUp
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 07:50:08
        .LINK
            https://azureautomation.wordpress.com/
    #>
 [CmdletBinding()]
 Param
     (
     $vmname, 
     $vmservice
     )
 Begin
 {
     }
 Process
 {
 Write-Host  $vmname  "------"  $vmservice
	$result = CheckVMStatus $vmname $vmservice
	write-Host $result
	if ($result)
	{	
		write-Host "VM Deallocated"
		$removestatus = Remove-AzureVM -ServiceName $vmservice -Name $vmname -DeleteVHD 
		Write-Host $removestatus.OperationStatus
															  

	}
	else
	{
		$Status = Stop-AzureVM -ServiceName $vmservice -Name $vmname
			If ($Status.OperationStatus -eq "Succeeded")
			{
				Write-host "Shutdown Completed successfully"
				$removestatus = Remove-AzureVM -ServiceName $vmservice -Name $vmname -DeleteVHD 
				
			}
			elseIf ($Status.OperationStatus -eq "StoppedDeallocated")
			{
				Write-Host "VM Already stopped and deallocated"
			}
			else
			{
				Write-Host $Status.OperationStatus
			}	
	}
     }
 End
 {
     }
 }


Function NewVMsInDomain
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : NewVMsInDomain
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 10:26:16
        .LINK
            https://code.google.com/p/mod-posh/wiki/VMProvisionActions#
    #>
 [CmdletBinding()]
 Param
    (
     	[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vmname,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vmservice ,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$subnetname,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vNetName	,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[Int] $noOfVms,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$un,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$pwd,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vmlocation,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$azureDomain,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$fullDomainName,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$ipaddressDns,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vmSize

     )
 Begin
 {
     }
 Process
 {
  	$myDNS = New-AzureDNS -Name $azureDomain -IPAddress $ipaddressDns

	# OS Image to Use
	$Image = Get-AzureVMImage | Select Imagename , label |`
	Where-Object {$_.Label -like 'Windows Server 2012 R2 Datacenter*'}	| select -first 1
	$iname = $Image.Imagename
	Write-Host $iname
	$srvstatus = Get-AzureService -ServiceName $vmservice
	if ($srvstatus)
	{
		Write-Host $vmservice "Service already exists"
	}
	else
	{
		New-AzureService -ServiceName $vmservice -Location $vmlocation
	}
	for ($i=1 ; $i -le $noOfVms; $i++)
	{
		#VM Name Formation
		$vName = $vmname + '0' + $i
		$vmexists = CheckVMStatus $vName.ToString()	$vmservice.ToString()
		if ($vmexists)
		{ 
			# VM Creation  and adding it do the domain
			Write-Host $vName  "started provision"
			$VMC = New-AzureVMConfig -name $vName -InstanceSize $vmSize -ImageName $Image.Imagename 
			$VMC | Add-AzureProvisioningConfig -AdminUserName $un -WindowsDomain -Password $pwd -Domain $azureDomain `
			-DomainPassword $pwd -DomainUserName $un -JoinDomain $fullDomainName 
			$VMC | Set-AzureSubnet -SubnetNames $subnetname 
			New-AzureVM -ServiceName $vmservice -VMs $VMC -DnsSettings $myDNS -VNetName $vNetName -WaitForBoot  
			Write-Host $vName  "Completed provision"  
		}
		
	}
     }
 End
 {
     }
 }


Function EnableADRoles
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : EnableADRoles
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 10:34:22
        .LINK
            https://code.google.com/p/mod-posh/wiki/VMProvisionActions#
    #>
 [CmdletBinding()]
 Param
     (
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vmname,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$vmservice,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$un,
		[parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$pwd,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$azureDomain,
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
		[string]$fullDomainName

     )
 Begin
 {
     }
 Process
 {
  	$SecurePassword = $pwd | ConvertTo-SecureString -AsPlainText -Force
	$credential = new-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $un , $SecurePassword
 	
	# Get the RemotePS/WinRM Uri to connect to	 the virtual machines
	$uri = Get-AzureWinRMUri -ServiceName $vmservice -Name $VMName 
 	# Generate certs 
	InstallWindowsRemoteCertificate $VMName $vmservice 
    Write-Host $azureDomain "Before Invoke command" $fullDomainName
 	# Use native PowerShell Cmdlet to execute a script block on the remote virtual machines					  
	Invoke-Command -ConnectionUri $uri.ToString() -Credential $credential -ScriptBlock {
         param(
        $azureDomain,
        $fullDomainName
        )
		#Generate the log files for future reference
		Write-Host "Generate the log files for future reference"
		$logLabel = $((get-date).ToString("yyyyMMddHHmmss"))
		$logPath = "c:\webservervm_webserver_install_log_$logLabel.txt"
		
		#Enable required windows features
		Write-Host "Enable required windows features"
		Import-Module -Name ServerManager
		Install-WindowsFeature -Name AD-Domain-Services  -IncludeManagementTools -LogPath $logPath
		$SecurePas = $pwd | ConvertTo-SecureString -AsPlainText -Force

		#Install and Configure active directiory and DNS
		Write-Host $pwd  $azureDomain "Install and Configure active directiory and DNS" $fullDomainName
		
        Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath 'C:\Windows\NTDS' -DomainMode 'Win2012' `
		-DomainName $fullDomainName -DomainNetbiosName $azureDomain -ForestMode 'Win2012' -InstallDns:$true -LogPath 'C:\Windows\NTDS' `
		-NoRebootOnCompletion:$true -SysvolPath 'C:\Windows\SYSVOL' -Force:$true  -SafeModeAdministratorPassword $SecurePas
		
        #Reboot the server to finish the active directory installation and configuration
		Write-Host "Reboot the server to finish the active directory installation and configuration"
		shutdown /r		
	} -argumentlist $azureDomain,$fullDomainName
     }
 End
 {
     }
 }

Function InstallWindowsRemoteCertificate
 {
    <#
        .SYNOPSIS
        .DESCRIPTION
        .PARAMETER
        .EXAMPLE
        .NOTES
            FunctionName : InstallWindowsRemoteCertificate
            Created by   : Manimaran Chandrasekaran
            Date Coded   : 11/23/2014 10:38:11
        .LINK
            https://code.google.com/p/mod-posh/wiki/VMProvisionActions#
    #>
 [CmdletBinding()]
 Param
     (
    [parameter(Mandatory=$true,ValueFromPipeline=$true)]
	[string]$vmname,
	[parameter(Mandatory=$true,ValueFromPipeline=$true)]
	[string]$vmservice 
     )
 Begin
 {
     }
 Process
 {
   $winRMCert = (Get-AzureVM -ServiceName $vmservice -Name $vmname | select -ExpandProperty vm).DefaultWinRMCertificateThumbprint
 	$AzureX509cert = Get-AzureCertificate -ServiceName $vmservice -Thumbprint $winRMCert -ThumbprintAlgorithm sha1
 
    $certTempFile = [IO.Path]::GetTempFileName()
    $AzureX509cert.Data | Out-File $certTempFile
 
    # Target The Cert That Needs To Be Imported
    $CertToImport = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 $certTempFile
 
    $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "Root", "LocalMachine"
    $store.Certificates.Count
    $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
    $store.Add($CertToImport)
    $store.Close()
 
    Remove-Item $certTempFile
     }
 End
 {
     }
 }
README.MD
 
softwaredeliveryascode\DIDemoWebsite.ps1
configuration DIDemoWebsite 
{ 
    Import-DscResource -Module xWebAdministration 
    Import-DscResource -Module xPSDesiredStateConfiguration
    WindowsFeature IIS  
    {  
        Ensure          = "Present"  
        Name            = "Web-Server"  
    }  
    WindowsFeature AspNet45  
    {  
        Ensure          = "Present"  
        Name            = "Web-Asp-Net45"  
    }   
    xWebsite DefaultSite   
    {  
        Ensure          = "Present"  
        Name            = "Default Web Site"  
        State           = "Stopped"  
        PhysicalPath    = "C:\inetpub\wwwroot"  
        DependsOn       = "[WindowsFeature]IIS"  
    }  
    File WebContent  
    {  
        Ensure          = "Present"  
        SourcePath      = "Z:\DiDemoShare"
        DestinationPath = "C:\inetpub\DIDemoWebsite" 
        Recurse         = $true  
        Type            = "Directory"  
        DependsOn       = "[WindowsFeature]AspNet45"  
    }   
    xWebsite DiBlogDemo   
    {  
        Ensure          = "Present"  
        Name            = "DIDemoWebsite" 
        State           = "Started"  
        PhysicalPath    = "C:\inetpub\DIDemoWebsite"  
        DependsOn       = "[File]WebContent"  
    }  
}
softwaredeliveryascode\PublishDSC.ps1
# Below Script is mainly used for publishing the DSC configuration and applying them in Azure VM

Publish-AzureVMDscConfiguration `
    C:\Users\mani_000\OneDrive\AzureBootstrap\AzureScripts\BootStrapAzure\BootStrapAzure\DIDemoWebsite.ps1 `
    -ConfigurationArchivePath C:\DemoSource\DIDemoWebsite.ps1.zip -Verbose -Force

Publish-AzureVMDscConfiguration C:\DemoSource\DIDemoWebsite.ps1.zip -Force -Verbose

$vm = Get-AzureVM -Name "DiLabVMClient01" -ServiceName "DiLabVMSvcClient" -Verbose

Set-AzureVMCustomScriptExtension -ContainerName scripts -StorageAccountName `
    azurenetworkfileshares -FileName MapAzureFileShare.ps1 -Run MapAzureFileShare.ps1 -VM $vm | Update-AzureVM -Verbose

#Set-AzureVMCustomScriptExtension -FileUri `
    #https://azurenetworkfileshares.blob.core.windows.net/scripts/MapAzureFileShare.ps1 `
    #-Run MapAzureFileShare.ps1  -VM $vm | Update-AzureVM -Verbose

$vm = Set-AzureVMDSCExtension -VM $vm -ConfigurationArchive "DIDemoWebsite.ps1.zip" -ConfigurationName "DIDemoWebsite"  

$vm | Update-AzureVM -Verbose
tools\ExecBootup.ps1
# Generate the relative path, this makes it easy when you download
$vmProvisonScript =  $PSScriptRoot + "\azureinfrastructureascode\VMProvisionActions.ps1"
$StroageBlobActions =  $PSScriptRoot + "\azureinfrastructureascode\StroageAccountBlobActions.ps1"
$MapAzureFileShare =  $PSScriptRoot + "\azureinfrastructureascode\MapAzureFileShare.ps1"
$AzureVNetSetup =  $PSScriptRoot + "\azureinfrastructureascode\AzureVNetSetup.ps1"
$AzureFileservices =  $PSScriptRoot + "\azureinfrastructureascode\AzureFileservices.ps1"

# Load the scripts to access the functions
. $vmProvisonScript
. $StroageBlobActions
#. $MapAzureFileShare
. $AzureVNetSetup
. $AzureFileservices


# Time to started
$time = [Diagnostics.Stopwatch]::StartNew()
Write-Host "Time Started" (Get-Date).ToString()
#Check if the Azure Subscription and Storage account exists
$azuresub = Get-AzureSubscription | Select CurrentStorageAccountName , SubscriptionName  `
 | Where-Object {$_.SubscriptionName -like 'BizSpark'}
 
 Get-AzureStorageAccount | Select Location, StorageAccountName , Label | `
 Where-Object {$_.StorageAccountName -like $azuresub.CurrentStorageAccountName} 
Write-host $PSScriptRoot

#Setup the Network Configuration 
New-AzureVNetConfiguration 

write-host "Cloud Configuration and Provision Started @" [DateTime]::UtcNow
ProvisionVM	DiLabADVM DiLabVMSvc Subnet-1	DILabsVNET	DITestUser Test@didemo1 'West Europe' Small
write-host "AD Provision Completed @" (Get-Date).ToString()
Sleep 60

EnableADRoles DiLabADVM DiLabVMSvc DITestUser Test@didemo1 DiLabs DiLabs.edu
 write-host "AD Setup and Configuration Completed @" (Get-Date).ToString()

NewVMsInDomain	DiLabVMClient DiLabVMSvcClient Subnet-1 DILabsVNET 1  DITestUser Test@didemo1 'West Europe' DiLabs DiLabs.edu '172.16.0.4' 'Small'
 write-host "Client VMs Created @" (Get-Date).ToString()
 Sleep 60

write-host "Cloud Configuration and Provision completed @"  (Get-Date).ToString()
$time.Stop()
Write-Host "End to End completed in "  $time.Elapsed 

No results available for this package. We are building up results for older packages over time so expect to see results. If this is a new package, it should have results within a day or two.

Add to Builder Version Downloads Last Updated Status

This release is first of the package.


This package has no dependencies.

Discussion for the AutomateThinkable Package

Ground Rules:

  • This discussion is only about AutomateThinkable and the AutomateThinkable package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or AutomateThinkable, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus