I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!
\
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 Invoke-ParameterisedSqlQuery { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string] $ConnectionString, | |
[Parameter(Mandatory)] | |
[string] $Query, | |
[Parameter(ValueFromPipeline)] | |
[PSCustomObject[]] $QueryArgs | |
) |
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
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", | |
"actions": | |
[ | |
{ | |
"command": | |
{ | |
"action": "copy", | |
"singleLine": false | |
}, |
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
#exportReport.ps1 | |
<# | |
.SYNOPSIS | |
Takes a query from a SQL file, adds parameters to it, executes it on a SQL Server and writes the result into an Excel file. Return value 0 indicates successful execution, Return value -1 indicates errors. | |
.DESCRIPTION | |
This script enables exporting query results to excel from a machine, where Excel is not installed. | |
This is done leveraging the module ExcelPSLib. | |
System requirements: | |
- Powershell version 3 or greater with modules dbatools and ImportExcel installed |
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
""" | |
An example of using PyWin32 and the win32com library to interact | |
Microsoft Excel from Python. | |
This can be used instead of Visual Basic for Applications (VBA) | |
(c) Michael Papasimeon | |
""" | |
import win32com.client |
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
#!/usr/bin/env python | |
import argparse | |
import csv | |
import sys | |
from collections import OrderedDict | |
import simplejson as json |
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
# Note that target_env.login and target_env.password is global variables | |
# Maybe I should add this into Fabric project (http://docs.fabfile.org/en/1.4.2/index.html). | |
# This is complicated task for sure but it would be nice if Fabric could use ssh under Linux and PowerShell Remoting under Windows. | |
def remote_sh(target_host, command_text, ignore_error=False): | |
print('run PowerShell script block at {0}: {1}'.format(target_host, command_text)) | |
command_text = command_text.replace('"', '\'') |