Skip to content

Instantly share code, notes, and snippets.

@developerprofiles
developerprofiles / Program.cs
Created September 20, 2021 09:00 — forked from ardalis/Program.cs
A StructureMap Example using a Console Application
using System;
using System.Linq;
using StructureMap;
namespace ConsoleApplication1
{
/// <summary>
/// See http://stackoverflow.com/questions/6777671/setting-up-structure-map-in-a-c-sharp-console-application
/// Updated for SM 4: http://ardalis.com/using-structuremap-4-in-a-console-app
/// </summary>
@developerprofiles
developerprofiles / passfunc.ps1
Created September 15, 2021 07:43 — forked from IISResetMe/passfunc.ps1
Pass function as argument in PowerShell
function Reverse-String {
param(
[string]$instr
)
$chars = $instr.ToCharArray()
[array]::Reverse($chars)
$chars -join ""
}
@developerprofiles
developerprofiles / Jenkinsfile
Created August 26, 2021 14:34 — forked from VladFrost/Jenkinsfile
CheckConfig pipeline script
node {
stage('Создание пустой базы и обновление из хранилища') {
env.RUNNER_V8VERSION='8.3.10.2505'
env.RUNNER_IBNAME="/F${env.WORKSPACE}/build/ib"
cmd("runner init-dev --storage --storage-name tcp://storage.local/master --storage-user Мороз")
}
stage('Проверка логической целостности конфигурации') {
cmd_failsafe('runner checkconfig --junitpath build/out/ConfigLogIntegrity.xml --mode -ConfigLogIntegrity')
step([$class: 'JUnitResultArchiver', testResults: '**/ConfigLogIntegrity.xml'])
@developerprofiles
developerprofiles / gist:7f34d051baf8569cb1d282870e185bfb
Created August 17, 2021 04:48 — forked from rgl/gist:2550634
Example PoC on how to configure WINRM and execute a remote powershell command on Windows
// see PowerShell Remoting on Python at https://www.bloggingforlogging.com/2018/08/14/powershell-remoting-on-python/
// see https://github.com/jborean93/pypsrp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// NB you should add reference to C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0\System.Management.Automation.dll (this is installed by the Windows SDK).
@developerprofiles
developerprofiles / CopyDeployableWebFiles.ps1
Created August 16, 2021 05:38 — forked from tmenier/CopyDeployableWebFiles.ps1
A PowerShell function to copy all deployable files from an ASP.NET Web Application project (WebForms or MVC) to another directory. Takes the path to the project file and the path to the destination folder. Useful in CI environments. In my tests, running this after msbuild has built the project is much faster than including a WebDeploy step in th…
function copy-deployable-web-files($proj_path, $deploy_dir) {
# copy files where Build Action = "Content"
$proj_dir = split-path -parent $proj_path
[xml]$xml = get-content $proj_path
$xml.Project.ItemGroup | % { $_.Content } | % { $_.Include } | ? { $_ } | % {
$from = "$proj_dir\$_"
$to = split-path -parent "$deploy_dir\$_"
if (!(test-path $to)) { md $to }
cp $from $to
}
@developerprofiles
developerprofiles / Program.cs
Created August 5, 2021 12:39 — forked from miteshsureja/Program.cs
How to execute PowerShell script or cmdlets from C# code?
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@developerprofiles
developerprofiles / CreateSite.ps1
Created July 7, 2021 12:47 — forked from alastairtree/CreateSite.ps1
IIS site stop and create website/appPool utility scripts
## FYI: These scripts are now maintained in a proper repository:
## https://github.com/alastairtree/deploy-websites-with-powershell
## Intro: Simple powershell script to install (or replace) a local website and app pool
## Usage: CreateSite.ps1 [WebsiteName] [AppPoolName] [Port] [Path] ([domain\user] [password])
## Note : These scripts require local admin priviliges!
# Load IIS tools
Import-Module WebAdministration
sleep 2 #see http://stackoverflow.com/questions/14862854/powershell-command-get-childitem-iis-sites-causes-an-error
@developerprofiles
developerprofiles / enable-iis-tools.ps1
Created June 28, 2021 13:18 — forked from brlinton/enable-iis-tools.ps1
Enable IIS tools form the command line
# Remove the /all if you receive any errors
& dism /online /get-features | more
& dism /online /enable-feature /FeatureName:IIS-CertProvider /all
& dism /online /enable-feature /FeatureName:IIS-WindowsAuthentication /all
& dism /online /enable-feature /FeatureName:IIS-ClientCertificateMappingAuthentication /all
& dism /online /enable-feature /FeatureName:IIS-StaticContent /all
& dism /online /enable-feature /FeatureName:IIS-DefaultDocument /all
& dism /online /enable-feature /FeatureName:IIS-WebSockets /all
@developerprofiles
developerprofiles / ANSIGreeting.ps1
Created June 14, 2021 17:32 — forked from jdhitsolutions/ANSIGreeting.ps1
PowerShell Candy - my demo files from the PSPowerHour on 26 May, 2020
#requires -version 7.0
$am = @"
_____ __ __ ___ _ __ ______
/ ___/__ ___ ___/ / / |/ /__ _______ (_)__ ___ _ __ / /__ / _/ _/
/ (_ / _ \ _ \ _ / / /|_/ / _ \/ __/ _ \/ / _ \ _ `/ / // / -_) _/ _/
\___/\___\___\_,_/ /_/ /_/\___/_/ /_//_/_/_//_\_, ( ) \___/\__/_//_/
/___/|/
"@
@developerprofiles
developerprofiles / Make-Module.ps1
Created June 14, 2021 17:31 — forked from jdhitsolutions/Make-Module.ps1
My module generation code from my Chicago PowerShell presentation on July 31, 2020.
#requires -version 5.1
#requires -module PowerShellGet
<#
The function assumes you have git installed and use it for source control
This code contains hard-coded references for my environment. This file
is offered as educational and reference material. It will not run for you
without revision.