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 Get-IpyVersionFromPath | |
{ | |
.{ | |
$version = '' | |
$ipyPath = Get-Command ipy | Select-Object -ExpandProperty Definition | |
if( [string]::IsNullOrEmpty($ipyPath) ) { return "IPY not in path" } | |
$ipyFolder = split-path $ipyPath | |
$ipyDll = join-path $ipyFolder 'IronPython.dll' | |
[reflection.assembly]::LoadFrom($ipyDll) |
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
$drivediskSpace = Get-PSDrive | | |
## Select the Name, Used amount in GB and Free space in GB | |
Select-Object Name, @{Name="Used";Expression={$_.Used / 1GB}}, @{Name="Free";Expression={$_.Free / 1GB}} | | |
## just pick mounted single letter drives to exclude registry | |
Where {$_.Name.Length -eq 1} | |
$impactedDrives = $drivediskSpace | | |
## Select drives where there is more than 0 bytes | |
## and either more than 80% used or 10GB of disk space remaining | |
Where { (($_.Free + $_.Used) -gt 0) -and (($_.Used/($_.Free + $_.Used) -gt .8) -or ($_.Free -lt 10)) } | | |
Select-Object Name, Used, Free |
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
$target = "https://my.scriptrock.applicance.com/" | |
$apiKey = "api_key" | |
$secretKey = "secret_key" | |
$token = $apiKey + $secretKey | |
$authToken = 'Token token="' + $token + '"' | |
$headers = @{'Authorization'=$authToken;'Content-Type'='application/json'; 'Accept'='application/json'} | |
$page = 0 |
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
$nodes | | |
where { $_.operating_system_family_id -eq 1 } | | |
Foreach { | |
$resource = "/api/v1/nodes/$_.id" | |
$uri = $target + $resource | |
Invoke-RestMethod -Method put -Uri $uri -Headers $headers -Body '{"node": {"connection_manager_group_id": 6}}' | |
} |
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
$target = "https://my.scriptrock.com" | |
$apiKey = "api_key" | |
$secretKey = "secret_key" | |
$nodeName = 'node_name' | |
$ErrorActionPreference = "Stop" | |
# A reuseable enum for meduim types | |
Add-Type -TypeDefinition @" | |
public enum MediumType |
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
# A reuseable enum for meduim types | |
Add-Type -TypeDefinition @" | |
public enum EventStatus | |
{ | |
ERROR = 0, | |
WARNING = 1, | |
OK = 2 | |
} | |
"@ |
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
public class Repository | |
{ | |
private ISqlExecutioner _sqlExecutioner; | |
private string _connectionString; | |
public Repository (ISqlExecutioner sqlExecutioner, string connectionString) | |
{ | |
_sqlExecutioner = sqlExecutioner; | |
_connectionString = connectionString; | |
} |
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
public static DataSet GetSomeStuffFromTheDatabase(int thingId) | |
{ | |
const string PROCEDURE_NAME = "GetMeSomeData"; | |
var parameterLisst = new SqlParameterList(); | |
parameterList.Add("@thing_id", SqlDbType.Int, thingId); | |
var sw = Stopwatch.StartNew(); | |
var results = _sqlExecutioner.ExecuteQuery(_connectionString, PROCEDURE_NAME, parameterList); | |
sw.Stop(); | |
_timeToExecuteGetSomeStuffFromTheDatabase = sw.Elapsed; | |
return results; |
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
public class Repository | |
{ | |
private ISqlExecutioner _sqlExecutioner; | |
private string _connectionString; | |
private long _dbQueryRequestTime; | |
public long DbQueryRequestTime { get { return _dbQueryRequestTime; }} | |
public Repository (ISqlExecutioner sqlExecutioner, string connectionString) | |
{ |
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
const string RETURN_CODE_NAME = "@return_code"; | |
const int SP_RETURN_VALUE = 0; | |
Dictionary<string, SqlParameter> parameterList = null; | |
_mockSqlExecutor = new Mock<ISqlExecutor>(); | |
_mockSqlExecutor.Setup(mdm => | |
mdm | |
.ExecuteNonQuery(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Dictionary<string, SqlParameter>>())) | |
.Callback( | |
(string conn, string procName, Dictionary<string, SqlParameter> plist) => |
OlderNewer