Browsed by
Month: July 2016

Massive AD Group Creation using Powershell

Massive AD Group Creation using Powershell

#Parameters 
$InputFile="import.csv"


#Variables
$errors=0
$success=0

#csv file that contains all groups to create 
$InputGroups=Import-csv $InputFile -Delimiter ";"

$InputGroups|
Foreach-Object{
	
	#Importing data
	$GroupName=$_."GroupName"
	$Destination=$_."DESTINATION"
	$Description=$_."DESCRIPTION"
	
	Write-Host "`n Creation du groupe : $GroupName -" -NoNewLine
	
	#AD Group creation
	New-ADGroup -name "$GroupName" -groupscope DomainLocal -GroupCategory Security -Description $Description -path $Destination
	
	#Check if group well created
	$testADGroup=Get-ADGroup $GroupName
	If($testADGroup){
		Write-Host " OK" -ForegroundColor:GREEN
		$success+=1
	}
	Else{
		Write-Host " KO" -ForegroundColor:RED
		$errors+=1
	}	

}

#Final 
$total=$success+$errors
Write-Host "`n `n $total groups created : `n "
Write-Host "           - $success" -NoNewLine -ForegroundColor:GREEN
Write-Host " groups created"
Write-Host "           - $errors" -NoNewLine -ForegroundColor:RED
Write-Host " groupes not created `n `n "

A quick Powershell script, easy to use, to create a lot of groups from a csv file

Vérification des certificats arrivant à expiration

Vérification des certificats arrivant à expiration

Une  mauvaise surprise est un jour arrivé, un certificat de la PKI venait d’expirer, paralysant pas mal de choses.

Voici une fonction permettant de lister les certificats arrivant à expiration dans X jours.

How to C# to Powershell

How to C# to Powershell

A little video tutorial found on youtube that explains how to translate a C# code into Powershell ! Really usefull to C# developpers.

 

Multithreads in Powershell

Multithreads in Powershell

roualin powershell_2 Multithreads in PowershellA heavy Powershell script uses a lot of ram to proceed. There are many ways to avoid that, and also avoid crashes of the server launching that. The easiest way is to use multithreads with job.

Using jobs will open a new thread into your server/remote server to execute a part of the script. Jobs also can be called to work at the same time, reducing the global execution time of the script.

Here below a small script to introduce you using jobs :

Powershell & requêtes SQL

Powershell & requêtes SQL

Effectuer des requêtes SQL via Powershell peut s’avérer très efficace et utile dans bien des domaines.

C’est assez simple en fait :

$conec = "server=;database=;Integrated Security=sspi"
$cmd = "SELECT FROM WHERE "
$da = new-object System.Data.SqlClient.SqlDataAdapter ($cmd, $conec)
$dt = new-object System.Data.DataTable
$da.fill($dt)

L’option “Integrated Security” permet d’utiliser l’authentification Windows, donc le compte lançant le script powershell sera capable de faire des requêtes, si bien sûr il en a les droits !

Powershell parle ! (si si)

Powershell parle ! (si si)

Un petit bout de code qui peut être amusant pour les débutants en Powershell, faire parler son ordinateur à l’aide de la synthèse vocale !

Add-Type -AssemblyName System.speech
$speaker = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speaker.Speak("I am alive !")

Il suffit tout simplement de charger le type system “speech”, puis de charger le synthétiseur vocal, et le tour est joué !

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site