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 / README.md
Created February 27, 2018 11:40
Extract Msi

Extract an MSI package

msiexec /a f:\zenworks\zfdagent.msi /qb TARGETDIR=c:\zfd701
@nordineb
nordineb / README.md
Created February 27, 2018 12:20
SqlLocalDb

Know Issues

Problem with localsystem

Localdb Automatic intances

MSSQLLocalDB
v12.0

(localdb)\ProjectsV12 instance is created by SQL Server Data Tools (SSDT)

@nordineb
nordineb / DetectDotNetFrameworkVersions.ps1
Created March 1, 2018 09:32
Detect DotNet Framework Versions
# Credits to https://stackoverflow.com/questions/3487265/powershell-script-to-return-versions-of-net-framework-on-a-machine
# Get the text from github
$url = "https://raw.githubusercontent.com/dotnet/docs/master/docs/framework/migration-guide/how-to-determine-which-versions-are-installed.md"
$md = Invoke-WebRequest $url -UseBasicParsing
# Replace the weird text in the tables, and the padding
# Then trim the | off the front and end of lines
$map = $md -split "`n" -replace " installed [^|]+" -replace "\s+\|" -replace "\|$" |
@nordineb
nordineb / template.json
Created March 5, 2018 15:04
import-cert
{
"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion":"1.0.0.0",
"parameters":{
"certificateName":{
"type":"string",
"metadata":{
"description":"User friendly certificate resource name"
}
},
@nordineb
nordineb / README.md
Created March 20, 2018 15:47
Myget NPM registry

Use myget as a NPM registry

npm update npm -g


npm config set strict-ssl true
npm config set ca ""
npm config delete proxy
@nordineb
nordineb / README.md
Last active March 22, 2018 13:51
Run npm install in every folder that contains a package.json file

Run npm install in every folder that contains a package.json file

$originalLocation = Get-Location
$folders = Get-ChildItem $originalLocation -Directory -Recurse -Name `
            | Where {$_ -notlike "*node_modules*"} `
            | Where {$_ -notlike "*jspm_packages*"} `
            | where { test-path (join-path $_ "package.json") }

. npm set progress=false
@nordineb
nordineb / README.md
Last active May 15, 2022 07:53
checking web sites
\sslyze.exe --http_headers   --json_out=JSON_FILE.json xxx.xxx.no:443

@nordineb
nordineb / README.md
Last active July 9, 2018 12:48
Request Just-In-Time access to a VM and then start a powershell remote session

My recipe to:

  1. Request Just in time virtual machine (VM) access
  2. Start a PowerShell remote session to the VM

PowerShell Remoting over HTTP (unsecure!)

On the server

Start a Powershell CLI with elevated rights:

Enable-PSRemoting -SkipNetworkProfileCheck -Force
Set-NetFirewallRule –Name "WINRM-HTTP-In-TCP-PUBLIC" –RemoteAddress 172.0.0.0/8
@nordineb
nordineb / README.md
Created March 21, 2018 19:02
Update the certificate of an Azure ApplicationGateway
$agw = Get-AzureRmApplicationGateway -Name MYGATEWAY -ResourceGroupName MYRESOURCEGROUP
Remove-AzureRmApplicationGatewaySslCertificate -Name CERTIFICATE-NAME-AS-WRITTEN-ON-THE-RESOURCE -ApplicationGateway $agw
Add-AzureRmApplicationGatewaySslCertificate -Name ANY-NAME -CertificateFile C:\CERTIFICATE.PFX -ApplicationGateway $agw
Set-AzureRmApplicationGateway -ApplicationGateway $agw

#WAIT 15 min
@nordineb
nordineb / README.md
Last active June 4, 2018 07:36
Set Windows services to delayed-auto with restart on failure

Given a list of windows services

  • Start each of them
  • Configure each of them to start automatically, but with a delay
  • On failure, restart the service
$services = ("OctopusDeploy Tentacle","seq","tcagent","mailhog","freeFTPdService")
foreach ($service in $services){
 Start-Service -Name $Service