This file contains 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
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; Remove-Item $env:ProgramData\habitat -Recurse -Force -ErrorAction Ignore; $s = "https://api.bintray.com/content/habitat/stable/windows/x86_64/hab-%24latest-x86_64-windows.zip?bt_package=hab-x86_64-windows"; (New-Object System.Net.WebClient).DownloadFile($s, "$env:TEMP\habitat.zip"); Expand-Archive $env:TEMP\habitat.zip -DestinationPath $env:ProgramData -Force; Get-ChildItem -Path $env:ProgramData -Filter "hab-*" -Depth 1 | Select-Object -First 1 | Rename-Item -NewName habitat -Force; [Environment]::SetEnvironmentVariable("PATH", "$env:ProgramData\habitat;$env:SystemDrive\hab\bin;$env:PATH", "Machine"); |
I hereby claim:
- I am stuartpreston on github.
- I am stuartpreston (https://keybase.io/stuartpreston) on keybase.
- I have a public key ASBm1MK8WvOf5nQsBgPTKT5cvEX4njjb0QS6TvcymOvcugo
To claim this, I am signing this object:
This file contains 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
<# | |
.Synopsis | |
Retrieves a token object from the Azure OAUTH2 service without launching a credentials window. | |
.DESCRIPTION | |
Retrieves a token object that can later be used to authorise requests against the Microsoft Azure Resource Manager REST API. | |
.EXAMPLE | |
Get-AzureOauth2Token -username '[email protected]' -password 'P2ssw0rd' | |
#> | |
Function Get-AzureOauth2Token | |
{ |
Example function to be saved to c:\winrm-profile.ps1
function Get-Hostname
{
return $env:COMPUTERNAME
}
To invoke normally:
This file contains 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
[CmdletBinding()] | |
param( | |
[string] $PublishSettingsFile = "pendrica-credentials.publishsettings", | |
[string] $ChefServerUrl = "https://chef.pendrica.com/organizations/azure-env-dev", | |
[string] $ChefValidationKey = ".chef\azure-env-dev-validator.pem", | |
[string] $ChefValidationClientName = "azure-env-dev-validator", | |
[string] $AzureSubscriptionName = "Microsoft Partner Network", | |
[string] $AzureImageName = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-Technical-Preview-201410.01-en.us-127GB.vhd", | |
[string] $AzureInstanceSize = "Standard_D1", | |
[string] $AzureLocation = "North Europe", |
This file contains 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
openssl base64 -d -A -in mgmtcert.pfx -out decoded.der | |
openssl pkcs12 -in decoded.der -out mgmtcert.pem -nodes |
This file contains 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
(Select-Xml -Path .\downloaded.publishsettings -XPath '//PublishData/PublishProfile/Subscription[@Name="YOURSUBSCRIPTIONNAME"]/@ManagementCertificate').Node.Value.ToString() | Out-File .\mgmtcert.pfx |
This file contains 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
xpath downloaded.publishsettings "string(//PublishData/PublishProfile/Subscription[@Name='YOURSUBSCRIPTIONNAME']/@ManagementCertificate)" > mgmtcert.pfx |
This file contains 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
function prompt | |
{ | |
$host.ui.rawui.WindowTitle = (get-location) | |
$lastCommand = Get-History -Count 1 | |
if($lastCommand) { Write-Host ("last command took") ($lastCommand.EndExecutionTime - $lastCommand.StartExecutionTime).TotalMilliseconds ("ms") } | |
return "PS>" | |
} |