Instantly share code, notes, and snippets.

View InstallFromPSGallery.ps1
try {
Find-Module -Name "AzureRM"
}
catch {
Write-Host "No AzureRM, Installing from PSGallery."
Install-PackageProvider -Name NuGet -Force -Scope CurrentUser
Install-Module AzureRM -Force -Scope CurrentUser
}
View InstallNuget.ps1
function Install-MicrosoftDataToolsMSBuild {
[cmdletbinding()]
param (
[parameter(Mandatory)]
[string] $WorkingFolder,
[string] $NuGetPath
)
Write-Verbose "Verbose Folder (with Verbose) : $WorkingFolder"
Write-Verbose "DataToolsVersion : $DataToolsMsBuildPackageVersion"
View InstallNuget.ps1
function Install-MicrosoftDataToolsMSBuild {
[cmdletbinding()]
param (
[parameter(Mandatory)]
[string] $WorkingFolder,
[string] $DataToolsMsBuildPackageVersion,
[string] $NuGetPath
)
Write-Verbose "Verbose Folder (with Verbose) : $WorkingFolder"
View mungemarkDownFiles.ps1
Get-ChildItem "C:\phbx\phbx\phbx\markdown5" -Filter *.md |
Foreach-Object {
$content = Get-Content $_.FullName
ForEach ($line in $content) {
$ignore = $false
if ($line -match "(jpg|png|bmp)" ) {
try {
$sub = $line.SubString(0, $line.IndexOf(">"))
$sub = $sub.Substring(0, $sub.LastIndexOf('"'))
$sub = $sub.trim('<a href="http://phoenixultd.files.wordpress.com')
View MigrateFromWordpressToMarkdown.ps1
[xml]$xml = Get-Content "C:\phbx\phbx\phbx\1.xml"
$folderformarkdown = "C:\phbx\phbx\phbx\markdown4"
$xmlposts = $xml.rss.channel.Item | Where-Object {($_.creator -eq "phoenixultd") -and ($_.status -eq "publish")}
foreach ($xp in $xmlPosts)
{
$content = $xp.content.InnerText
$date = Get-Date $xp.pubDate -Format 'yyyy-MM-dd'
$tags = @()
for ($i = 0; $i -le $xp.category.Count-1; $i++)
View deployment.targets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<SkipCopyBuildProduct>true</SkipCopyBuildProduct>
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<TargetRuntime>None</TargetRuntime>
View ExecutePoshSSDTBuildDeploy.ps1
[cmdletbinding()]
param (
[parameter(Mandatory = $true)] $WorkingFolder,
[parameter(Mandatory = $false)] $serverName,
[parameter(Mandatory = $false)] [string] $sqlAdministratorLogin,
[parameter(Mandatory = $false)] [String] $sqlAdministratorLoginPassword,
[parameter(Mandatory = $false)] [String] $connectionString,
[parameter(Mandatory = $true)] [string] $DatabaseName,
[parameter(Mandatory = $true)] [string] $DacpacPath,
View pester_test_for_poshssdtbuilddeploy_2.ps1
#import module from repo
Import-Module (Join-Path $PSScriptRoot "..\PoshSSDTBuildDeploy") -Force
Describe "Publish-DatabaseDeployment" {
function Get-DbId ($databaseName, $serverInstanceName) {
@(Invoke-Sqlcmd -Query "select db_id('$databaseName') as DbId" -ServerInstance $serverInstanceName) | Select-Object -First 1 -ExpandProperty DbId
}
BeforeAll {
View AzureFunctionsKickOff.ps1
param(
[parameter(Mandatory = $true)] [string]$functionName,
[parameter(Mandatory = $true)] [string]$appName,
[parameter(Mandatory = $true)] [string]$resourceGroup
)
function Get-KuduCredentials($appName, $resourceGroup) {
[xml]$x = Get-AzureRmWebAppPublishingProfile -ResourceGroupName $resourceGroup -Name $appName
$user = $x.publishData.publishProfile[1].userName.Split("\") | Select-Object -Last 1
View manageAzureFunctionKeys.ps1
param(
[parameter(Mandatory=$true)] [string]$functionName,
[parameter(Mandatory=$true)] [string]$appName,
[parameter(Mandatory=$true)] [string]$resourceGroup,
[parameter(Mandatory=$true)] [string]$key
)
function Get-KuduCredentials($appName, $resourceGroup) {
[xml]$x = Get-AzureRmWebAppPublishingProfile -ResourceGroupName $resourceGroup -Name $appName