Example function to be saved to c:\winrm-profile.ps1
function Get-Hostname
{
return $env:COMPUTERNAME
}To invoke normally:
| 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>" | |
| } |
| xpath downloaded.publishsettings "string(//PublishData/PublishProfile/Subscription[@Name='YOURSUBSCRIPTIONNAME']/@ManagementCertificate)" > mgmtcert.pfx |
| (Select-Xml -Path .\downloaded.publishsettings -XPath '//PublishData/PublishProfile/Subscription[@Name="YOURSUBSCRIPTIONNAME"]/@ManagementCertificate').Node.Value.ToString() | Out-File .\mgmtcert.pfx |
| openssl base64 -d -A -in mgmtcert.pfx -out decoded.der | |
| openssl pkcs12 -in decoded.der -out mgmtcert.pem -nodes |
| [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", |
Example function to be saved to c:\winrm-profile.ps1
function Get-Hostname
{
return $env:COMPUTERNAME
}To invoke normally:
| <# | |
| .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 | |
| { |
I hereby claim:
To claim this, I am signing this object:
| [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"); |