Skip to content

Instantly share code, notes, and snippets.

View RichieBzzzt's full-sized avatar
🦆
Sirfetch'd

Richie Lee RichieBzzzt

🦆
Sirfetch'd
View GitHub Profile
$my_variable = "this is the value of my_variable"
if (Test-Path variable:my_variable) {
Write-Host $my_variable -ForegroundColor Magenta -BackgroundColor Yellow
}
else {
Write-Host 'Variable $my_variable does not exist.' -ForegroundColor Yellow -BackgroundColor Magenta
}
#note: my_non_existent_variable doesn't exist, so will go to else statement
$msbuild = "C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe"
$MsBuilExists = Test-Path $msbuild
If ($MsBuilExists -ne $true) {write-host "msbuild does not exist at this location. Install Visual Studio 2015 (Community Edition should be adequate)"}
$buildFile = "C:\Users\Richie\Documents\ssis_guy\build_ssis.proj"
& $msbuild $buildFile
Microsoft Visual Studio 2017 Version 15.0.26430.6.
Copyright (C) Microsoft Corp. All rights reserved.
Some errors occurred during migration. For more information, see the migration report:
C:\Users\Richie\Documents\ssis_guy\UpgradeLog3.htm
========== Rebuild All: 0 succeeded, 0 failed, 0 skipped ==========
Build succeeded.
0 Warning(s)
0 Error(s)
<Target Name="AfterGet">
<CallTarget Targets="DevEnvInstaller">
</Target>
cls
$sql_connection_string = "SERVER=.;Integrated Security=True;Database=master"
$sql_connection = new-object System.Data.SqlClient.SqlConnection ($sql_connection_string)
try {
$sql_connection.Open()
return $sql_connection.Database
}
catch {
Write-Error $_.Exception
Function Test-DownloadUri {
<#
.SYNOPSIS
Tests that a url is valid
.DESCRIPTION
Returns a status code from an http request of a url. Used to verify that download links work.
.PARAMETER Uri
The url that we are checking is valid
.INPUTS
N/A
cls
Set-Location "/home/<whatisyourlinuxuser>/sqltoolservice/"
$Assem = (
"Microsoft.SqlServer.Management.Sdk.Sfc",
"Microsoft.SqlServer.Smo",
"Microsoft.SqlServer.ConnectionInfo"
);
cls
Set-Location "/home/richie/sqltoolservice/"
$Assem = (
"Microsoft.SqlServer.Management.Sdk.Sfc",
"Microsoft.SqlServer.Smo",
"Microsoft.SqlServer.ConnectionInfo"
);
function Connect-AzureRmSubscription (
$AzureSubscriptionId,
$AzureSubscriptionUsername,
$AzureSubscriptionPassword
) {
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
if ($null -eq $AzureSubscriptionId -or $null -eq $AzureSubscriptionUsername -or $null -eq $AzureSubscriptionPassword) {
throw "The variable set for Azure Subscription information has not been added or the SubscriptionId, SubscriptionName, AzureSubscriptionUsername and AzureSubscriptionPassword variables have not been set for this environment"
Function Get-FrequencyIntervalValue {
[CmdletBinding()]
param
(
[string[]]
[ValidateNotNullorEmpty()]
$Freq
)
[int]$Value = 0
if (($Freq -contains "Sunday") -eq $True) {$Value = $Value + 1}