Skip to content

Instantly share code, notes, and snippets.

View nordineb's full-sized avatar

Nordine Ben Bachir nordineb

  • Bekk
  • Oslo, Norway
View GitHub Profile
@nordineb
nordineb / Restart-WebAppPool.ps1
Created October 26, 2017 14:29
Restart-WebAppPool
# Load IIS module:
Import-Module WebAdministration
# For debugging: Show all w3wp processes
gwmi win32_process -filter "name='w3wp.exe'" | select name,processId,commandLine | Format-List
# will recycle tilsyn apppool
$site = "MySite"
$pool = (Get-Item "IIS:\Sites\$site"| Select-Object applicationPool).applicationPool
@nordineb
nordineb / README.md
Last active October 27, 2017 15:18
Cosmosdb

resourceGroupName='myrg' location='westeurope' name='mycosmos' databaseName='mycosmos-db' collectionName='collection1'

Create a resource group

az group create
--name $resourceGroupName
--location $location

@nordineb
nordineb / NoteToSelf.sh
Last active May 15, 2022 07:51
note to self
http://agiletesting.blogspot.no/2016/02/setting-up-mailinator-like-test-mail.html
# apt-get update
# apt-get install build-essential git mercurial bazaar unzip
# apt-get install postfix mailutils
# cd /root
# wget https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz
# tar xvfz go1.4.3.linux-amd64.tar.gz
# mv go go1.4
# git clone https://go.googlesource.com/go
@nordineb
nordineb / README.md
Created November 1, 2017 21:09
2 ways to generate passwords with powershell

First

$bytes = New-Object Byte[] 32
$rand = [System.Security.Cryptography.RandomNumberGenerator]::Create()
$rand.GetBytes($bytes)
$rand.Dispose()
$password1 = [System.Convert]::ToBase64String($bytes)
@nordineb
nordineb / Install-ARRFromWeb.ps1
Created January 4, 2018 12:53 — forked from anderssonjohan/Install-ARRFromWeb.ps1
A basic PowerShell script used to push IIS 7 Application Request Routing (tl;dr; reverse proxy features for UrlRewrite) to several servers. Assumptions: - cURL is in the path on the source machine - servers are specified as objects on the pipeline with properties telling the unc path and local path to a writable network share on the server - Win…
param(
[parameter(mandatory=$true, valuefrompipeline=$true)]
$TargetHost,
[switch] $force
)
begin {
$packages = @( `
@{ Name = "rewrite.msi"; Url = "http://download.microsoft.com/download/6/7/D/67D80164-7DD0-48AF-86E3-DE7A182D6815/rewrite_2.0_rtw_x64.msi" }, `
@{ Name = "webpi.msi"; Url = "http://download.microsoft.com/download/B/0/0/B00FEF21-79DE-48B0-8731-F9CFE70CE613/WebPlatformInstaller_3_10_amd64_en-US.msi" }, `
@{ Name = "webfarm.msi"; Url = "http://download.microsoft.com/download/3/4/1/3415F3F9-5698-44FE-A072-D4AF09728390/webfarm_amd64_en-US.msi" }, `
@nordineb
nordineb / IMPORT.SQL
Created January 5, 2018 09:27
Import-Export Data With Management Studio
BULK INSERT MyTable
FROM 'c:\dump.txt'
WITH
(
FIELDTERMINATOR = '\t',
ROWTERMINATOR = '\n',
FIRSTROW = 1
)
@nordineb
nordineb / README.md
Last active March 15, 2018 15:39
Sending email with a terminal

Sending emails with powershell

Securely send emails with attachments

$credential = Get-Credential
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { return $true }

Send-MailMessage `
-SmtpServer 172.XXX.XXX.XXX `
-port 587 `
@nordineb
nordineb / RADME.md
Created February 16, 2018 09:21
NPM registry myget

Set privtge NPM registry

npm config get registry
npm add-user	--registry https://www.myget.org/F/myfeed/npm --always-auth
npm login	--registry=https://www.myget.org/F/myfeed/npm
npm config set registry https://www.myget.org/F/myfeed/npm
npm config get registry
npm whoami
npm install
@nordineb
nordineb / README.md
Last active March 26, 2018 15:28
install cygwin

Install Cygwin with powershell

mkdir "%PROGRAMFILES%\cygwinx86" -ErrorAction Ignore
(New-Object Net.WebClient).DownloadFile('https://cygwin.com/setup-x86.exe', "$env:TEMP\setup-x86.exe")
$cmdPath = "$env:TEMP\setup-x86.exe"
& $cmdPath -a x86 -v -q -n -N -d -R c:\cygwin -s http://cygwin.mirror.constant.com -l c:\localPackageDir -P wget,openssh,git,rsync,nano,curl,tar,openssh

Install apt-cyg

@nordineb
nordineb / Shrink.sql
Created February 27, 2018 09:03
SQL snippets
ALTER DATABASE MYDB SET RECOVERY SIMPLE
GO
USE MYDB
GO
DBCC SHRINKFILE ('MYDB_LOG', 1)
GO
DBCC SHRINKFILE ('MYDB', 1)