Powershell Scripts


Thought Leadership & Events

============================================================================
PowerShell working with Azure Resource Manager RM – Step By Step Changing RM Subscriptions

There are two different types resource modes in Azure.  One is the Service Manager (classic) and the other is the new Resource Manager.   Resource Manager is the new model and much, much better for a bunch of reasons.  Those reasons are beyond the scope of this post but the way to connect to the Resource Manager is different in PowerShell that the Service Manager.  For that reason, I wanted to outline how to connect to Azure Resource Manager in PowerShell.

============================================================================
Create Computer Certificate for Azure Authentication using PowerShell

  • Create, Install and Export a self-signed certificate. I needed to create a self-signed computer certificate to use for authentication between my Windows Server 2012 Server and Windows Azure.

============================================================================
Change or Set ExecutionPolicy to Enable PowerShell Scripts to Run

  • When you start Windows PowerShell on a computer, the default security policy does not allow you to run scripts. The Windows PowerShell security policy for scripting is called an execution policy.

============================================================================
Azure Accounts with PowerShell

  • This scripts demonstrates how Azure Account Authentication works. Shows how to work with changing accounts, and subscriptions in Azure using PowerShell.

See a video of this script in action at https://channel9.msdn.com/Series/GuruPowerShell/Azure-Accounts-with-PowerShell

============================================================================
Azure Subscriptions with PowerShell

  • Demonstrate how Azure Subscriptions work and how to change default and current subscription using PowerShell
    Shows how to work with changing default & Current accounts, and subscriptions in Azure using PowerShell.

See a video of this script in action at https://channel9.msdn.com/Series/GuruPowerShell/Azure-Subscriptions-with-PowerShell

============================================================================
LogIt PowerShell Script to Log to Screen and Text File

  • Demonstrate how to create and work with Log files using PowerShell.Shows how to create log files and create function to log information to screen and text file Includes ability so set colors and other features.

See a video of this script in action at https://channel9.msdn.com/Series/GuruPowerShell/LogIt-Function-with-PowerShell-to-Log-to-Screen-and-Log-file-Super-Simple-and-Elegant

============================================================================
Working with Files & Paths using PowerShell System.IO and Get-Location

  • Show multiple ways to work with location path information. There are several ways to work with files and paths with Powershell.  We will look at some of these in detail.

See a video of this script in action at https://channel9.msdn.com/Series/GuruPowerShell/Working-with-Files-and-Paths-Using-PowerShell

============================================================================
GUI popup Set-Location via File popup dialog using .BrowseForFolder

  • Demonstrate how to change default and current Location (Get-Location; Set-Location) using GUI popup Dialog.

============================================================================
GUI popup FileOpenDialog to collect Filename and Path

  • Demonstrate how to Open a GUI File Open Dialog to collect a filename and path using PowerShell.  Includes setting up file extension filters, writing out the results to screen and checking for OK or Cancel and responding appropriately.

============================================================================
GUI popup FileSaveDialog to collect Filename and Path using PowerShell

  • Demonstrate how to Open a GUI File Save Dialog box to collect a filename and path using PowerShell. How to collect filename and path for a save as operation using GUI popup Dialog in PowerShell.

============================================================================
Collect a Yes or No Response from User using PowerShell; Fully evaluate response.

  • Demonstrate how to ask the user a question with a Yes or No Answer using PowerShell. Collect a Yes or No Response from the user using PowerShell.

============================================================================
Working with Compressed Archive .ZIP Files Using PowerShell

  • Demonstrate how to create a compressed .ZIP file and add files to it using PowerShell. Demonstrate multiple methods to extract files from a .zip. Delete, Create, and add files to a zip file and extract files from a .ZIP.

============================================================================
Downloading Files from Public URL Using PowerShell

  • Demonstrate how to download files from an Online URL using PowerShell. Demonstrates downloading files from an Azure Storage container but same process works for any valid online URL.

============================================================================
Create ContosoDemo Web App on Clean Windows Server using PowerShell

  •  It will Open firewall ports for the server, create folders, download a sample website (ContosoDataWebsite), install IIS, Download and install custom webconfig file, Turn off IE Enhanced Security Configuration and restart IIS.  The end result is a fully deployed sample website on a clean windows server machine.

============================================================================
Create ConsosoDemo SQL Server from Clean Windows Server with SQL installed

  • Download ContosoDemo database and configure SQL server to host the database.  Pass username and passord as a parameter or unremark the static variables in the script.  Configures firewall, (assumes extra data disk is attached) configures data disk, creates folders, downloads neeed files, installs database, sets various SQL preferrences (best practices), create database, change backup default location and change other folders,  create local computer sql login, create sql logins, grant access to DB for new users, turn off IE Enhanced Security (ok, not a best practice), restart SQL.

============================================================================
Install and Deploy Active Directory on a Clean Windows Server using PowerShell

  • On a clean Windows Server machine, script will install Active Driectory Domain Services, install and configure the forest and domain.  Default values are ConstosoAzure.com for the domain but it is very easy to change by changing a couple lines of code or remarking them out and passing parameter values. Also enables Ping in the firewall and sets the DNS client sufix for the domain.

============================================================================
GUI Popup Custom Form with EditBox, ListBox, ComboBox and more Using PowerShell

  • Demonstrate how create and work with GUI Forms using PowerShell. Shows how to create log Forms, add labels, text boxes, panels, comboboxes, PickLists, and more. Shows how to populate all fields including picklists and combobox lists and work with properties. Shows how to populate and work with array objects. Uses Azure commands to populate list data. Shows how to work with the results from the dialog and the changes made to the form objects.

============================================================================
Create Azure Service Using PowerShell

  • Demonstrate how create an Azure Service using PowerShell. Shows how to create log files and create function to log information to screen and text file.

============================================================================
Execute Custom Script Using Azure Set-AzureVMCustomScriptExtension PowerShell

  • Demonstrate how create to execute the use of a Custom Extension in Azure using Powershell.The Script can be local or available via a web URL. Demonstrate the usage of both. Includes URL to download a script to deploy ContosoWeb Application database.

============================================================================
Create Azure Storage Account Using PowerShell

  • Demonstrate how test the name used to create an azure storage account, create an Azure Storage Account, Create Folders, Upload files to the folder using PowerShell.

============================================================================
Working with Azure Storage Accounts with PowerShell

  • Demonstrate how to work with an existing Azure Storage account using PowerShell. Obtain the storage key, and upload files to a particular folder using PowerShell.

============================================================================
Upload to Azure Storage Entire Directory of files Using PowerShell

  • Demonstrate how upload an entire filtered directory of files to an Azure Storage Account using PowerShell. Obtain the storage key, and upload an entire directory of files to a particular folder using PowerShell. Also demonstrates skipping some files based on file extension

============================================================================
Create Azure Network file and Network with PowerShell

  • Demonstrate how to create and work with a network and network files and using it to create or modify Networks in Azure using PowerShell.

============================================================================
Create Azure Virtual Machine VM using PowerShell

  • Demonstrate how to create an Azure VM using Powershell.   Creates an Azure VM using the latest SQL Server Image available in the Gallery. Using variables for hostname and all other options so easy customization.

============================================================================
Add Data Disk to Existing Azure VM using PowerShell

  • Demonstrate how to create an extra hard disk and attach to an Azure VM using Powershell.     Creates an Azure VHD and attaches it to an existing VM. Using variables for VM name so easy customization.

============================================================================
Create a Wait State Loop using PowerShell, uses Azure VM.PowerState

  • Demonstrate how to “Wait” for a process to run using PowerShell.  Uses a loop to check a status.  once the status is the expected value, script processing continues. Uses Azure. Checks the vm.powerstate state of a machine that was created and continues processing once it is “Started”.  Creates and Azure VHD and attaches it to an existing VM. Using variables for VM name so easy customization.

============================================================================
Build 3 Machine Lab in Microsoft Azure using PowerShell

  • Create a Domain Controller, Web Server and SQL Server in Azure using Powershell.  Uses GUI popup dialog to prompt for values. Prompts user through collecting of prerequisite information, Connects to Azure. Allows user to set various variables (computer name, OS Image, Creds, etc). Downloads additional supporting files needed (post configuration scripts). Builds a script to “undo” or “remove” all the infrastructure the script creates(except network, which the code is there but remarked out). Builds the Infrastructure on users Azure account.  Infrastructure includes:  Network, Cloud Service, Storage Account, Storage Container
    3 Virtual Machines:
    DC01 – Post configuration to deploy AD and use Static IP address
    WFE01 – No configuration done YET, Website files are downloaded to SQL Server F:
    SQL01 – SQL Configured with additional users, Adventure works Database (Test),
    Firewall open, SQL security and defaults configured, Drives and folders
    configured.
    Executes Configuration Scripts on servers (which were downloaded from IT-Camp Master site), Opens Azure Cleanup Script using Notepad.exe. Entire environment is built in less than 10 mins script runtime complete configuration is another 10-15 mins for post configuration scripts to run (background).

============================================================================