Skip to content

Instantly share code, notes, and snippets.

@developerprofiles
developerprofiles / exportDatabaseTableToCsv.psm1
Created March 25, 2020 14:13 — forked from Gimly/exportDatabaseTableToCsv.psm1
PowerShell - Export a database table to a CSV file
<#
.SYNOPSIS
Runs a select with on the specified table with the specified columns
and writes the result to a CSV file.
.DESCRIPTION
This function calls the connection passed as a parameter and sends a
SELECT command to it. The table on which the SELECT is run as well as
the selected columns are passed as a parameter.
# Database servername
$Servers = @('server1', 'server2')
# Datbase name
$DatabaseName = "Dbname"
# database select query
$sqlQuery = $("select top 5 * from sys.objects")
# Temporary file name with path
$csvPath = "$env:TEMP\"
cls
Import-Module -Name SqlPs #or SqlServer
Import-Module -Name ImportExcel
# Database servername
$ServerName = "Server"
# Datbase name
$DatabaseName = "AdventureWorksDW2017"
# database select query
$Query = "SELECT TOP (5) [DatabaseLogID],[PostTime],[DatabaseUser],[Event],[Schema],[Object] FROM [AdventureWorksDW2017].[dbo].[DatabaseLog]"
#Docker for Windows requires Hyper-V. This needs to be disabled before you can run VirtualBox.
#And to start using Docker for Windows again, re-enable Hyper-V:
# Run from elevated prompt (admin privileges)
function SwitchDockerorVirtualBox{
[CmdletBinding()]
param(
[switch]$Docker
)
Set-ExecutionPolicy Bypass -Scope Process -Force;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco -?
choco
choco feature enable -n allowGlobalConfirmation
################################ Installation
Set-ExecutionPolicy Unrestricted
# Install Chocolatey
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
# Install Minikube (this also installs kubectl as a dependency)
choco install -y minikube -force
#choco install minikube kubernetes-cli
minikube config set WantUpdateNotification false
cls
$MainFolder = 'E:\Learning\Documents\Phones\OnePlus 1+\Telegram\Telegram Documents\Zip\Zips'
$7zipExecutable = "C:\Program Files\7-Zip\7z.exe"
$shell=new-object -com shell.application
$CurrentLocation = $MainFolder #get-location #
$CurrentPath = $CurrentLocation.path
$Location = $shell.namespace($CurrentPath)
Set-Location $CurrentLocation
@developerprofiles
developerprofiles / Jenkinsfile
Created February 4, 2021 16:41 — forked from merikan/Jenkinsfile
Some Jenkinsfile examples
Some Jenkinsfile examples
@developerprofiles
developerprofiles / docker_start.PS1
Created February 4, 2021 16:44 — forked from BernCarney/docker_start.PS1
Powershell script to start, stop, and restart my jekyll dev container (and clear unsused containers)
#
# Script to start, stop, restart Jekyll Dev Environment container
#
# Set default parameter set
[cmdletbinding(DefaultParameterSetName='container')]
# Intialize parameters
param (
[Parameter(Mandatory = $true)]
@developerprofiles
developerprofiles / docker_start.PS1
Created February 4, 2021 16:44 — forked from BernCarney/docker_start.PS1
Powershell script to start, stop, and restart my jekyll dev container (and clear unsused containers)
#
# Script to start, stop, restart Jekyll Dev Environment container
#
# Set default parameter set
[cmdletbinding(DefaultParameterSetName='container')]
# Intialize parameters
param (
[Parameter(Mandatory = $true)]