Quantcast
Channel: Système informatique, sécurité et Web
Viewing all 187 articles
Browse latest View live

Filtre WMI

$
0
0

Sur_Postes_Windows_7

S’execute sur les postes windows 7 uniquement

Texte de remplacement généré par une machine : Nom. Requête WfrlI
Espace de noms:
Deser _________ Parcourir...
Requête:
Reque
— Select horn Win32_OperatingSystem Where Version like ‘6.1 t” and j
Espc ProductType=”l”
root\
eU
OK Annuler
Enregistrer Annuler

root\CIMv2

Select * from Win32_OperatingSystem Where Version like « 6.1% » and ProductType = « 1 »

 


Test

Select * from Win32_OperatingSystem Where Version like « 6.% » and ProductType = « 1 » or ProductType= »3″


Sur_Serveurs_2012R2_sauf_DC

Filtre pour les OS serveurs Microsoft en version 2012 R2 à l’exception des Controlleur de domaine.

Texte de remplacement généré par une machine : SurServeurs_201 2fl 2_saul_DC
Description:
pour les DS serveurs Microsoft en version 2012 fl2 à exception des Controlleur de domaine.
Requêtes:
Espace de noms Requête ____________________ Ajouter
rooÏSÕMv2 select X From Win32_DperatingSystem where
Version like “6.3%’ and Productïype=”3” S pprimer
Requête WMI
odilier
Espace de noms:
Ir00tM2 Parcourir...
Requête:
________ —] nnuler

root\CIMv2

select * from Win32_OperatingSystem where Version like « 6.3% » and ProductType= »3″


WMI : repair, find KB, log

$
0
0

repaire WMI

1.Stopper le service WMI par la commande net stop winmgmt

2.Supprimer le dossier WMI repository : RD %systemroot%system32wbemRepository /S /Q

3.Puis redémarrer le service WMI, ce qui aura pour effet de recréer le dossier Repository : net start winmgmt

 

winmgmt /verifyrepository – checks the WMI repository for consistency

Winmgmt /resetrepository – resets the WMI repository back to its initial state after the OS was first installed

 

 

cd /d %windir%\system32\wbem

for %i in (*.dll) do RegSvr32 -s %i

for %i in (*.exe) do %i /RegServer

wbemtest

 

 

net stop winmgmt /?

winmgmt /clearadap

winmgmt /kill

winmgmt /unregserver

winmgmt /regserver

winmgmt /resyncperf

regsvr32 c:\windows\system32\wbem\wmiutils.dll

 

  1. Arrêter le service « Infrastructure de gestion Windows »
  2. Supprimez tous les fichiers qui se trouvent dans le dossier c:\Windows\System32\Wbem\Repository
  3. ré enregsitrer les DLL « for %i in (*.dll) do RegSvr32 -s %i »
  4. Redémarrez votre ordinateur

sfc /scannow

https://blogs.technet.microsoft.com/askperf/2009/04/13/wmi-rebuilding-the-wmi-repository/https://blogs.technet.microsoft.com/askperf/2009/04/13/wmi-rebuilding-the-wmi-repository/

  1. Re-register all dlls, recompile the .mofs in the wbem folder and re-registering WMI Service and Provider. You can use the following script by saving to txt file then renaming to .bat and running from command prompt with admin right and changing focus to following directory: C:\Windows\System32\Wbem.

 

@echo off

sc config winmgmt start= disabled

net stop winmgmt /y

%systemdrive%

cd %windir%\system32\wbem

for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s

wmiprvse /regserver

winmgmt /regserver

sc config winmgmt start= auto

net start winmgmt

for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s

 

  1. Reboot the machine and test WMI

 

 

#### LOG ####

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\CIMOM\Logging = 2

The following list lists the logging levels that can be defined in the registry.

 

Logging level :

0 No Logging

1 Log only errors

2 Verbose Logging (default)

https://msdn.microsoft.com/en-us/library/aa392285(v=vs.85).aspx


Trouver hotfix / kb

wmic qfe get hotfixid | find « 981314 »

 

En PowerShell

get-hotfix -id 981314

 

wmic qfe get hotfixid | find « KB99999 »
wmic qfe | find « KB99999 »

 

https://serverfault.com/questions/263847/how-can-i-query-my-system-via-command-line-to-see-if-a-kb-patch-is-installed

Batch : hibernation, SNMP, test cluster MNS

$
0
0

Call-Hibernation.bat

Mise en place des variables

@echo off

set WorkstationName=%1

echo %WorkstationName%

Copy du script vers la machine désignée et exécution du script à distance. Un check est effectué (sans log) et ensuite on supprime le répertoire hibernation qui a été créé à cet effet.

robocopy « . » « \\%WorkstationName%\c$\Hibernation » Hibernation.bat

psexec \\%WorkstationName% cmd /c « call c:\Hibernation\hibernation.bat »

psexec \\%WorkstationName% cmd /c « powercfg /query »

psexec \\%WorkstationName% cmd /c « rmdir /Q /S c:\Hibernation »

 


Hibernation.bat

Mise en place des conditions pour savoir si le poste est configuré sur le mode laptop ou workstation.

S’il est en mode Laptop, on laisse cette configuration, sinon on la change.

@echo off

powercfg /query |find /I « Name Portable/Laptop » > %errorlevel%

if %errorlevel%==0 (echo Portable/Laptop : OK) else (powercfg /SETACTIVE « Portable/Laptop » & echo Policy for Laptop enabled)

On effectue une modification de la stratégie sur les arrêts disques en mode « never ».

powercfg /query « Portable/Laptop » |find /I « Turn off hard disks (AC) Never » > %errorlevel%

if %errorlevel%==0 (echo Settings of DISK : OK) else (powercfg /change « Portable/Laptop » /disk-timeout-ac 00 |find /V « WARNING: System may not support » & echo Disk Settings Changed to Never)

On effectue une modification de la stratégie sur les arrêts des écrans en mode « never ».

powercfg /query « Portable/Laptop » |find /I « Turn off monitor (AC) Not Supported » > %errorlevel%

if %errorlevel%==0 (echo Settings of Monitor : OK) else (powercfg /change « Portable/Laptop » /monitor-timeout-ac 00 |find /V « WARNING: System may not support » & echo Monitor Settings : Changed to Never)

On effectue une modification de la stratégie sur les arrêts des « standby » en mode « never ».

powercfg /query « Portable/Laptop » |find /I « System standby (AC) Never » > %errorlevel%

if %errorlevel%==0 (echo Settings of StandBy : OK) else (powercfg /change « Portable/Laptop » /standby-timeout-ac 00 |find /V « WARNING: System may not support » & echo StandBy Settings : Changed to Never)

On effectue une modification de la stratégie sur les en mode « never ».

powercfg /query « Portable/Laptop » |find /I « System hibernates (AC) Never » > %errorlevel%

if %errorlevel%==0 (echo Settings of Hibernate : OK) else (powercfg /change « Portable/Laptop » /hibernate-timeout-ac 00 |find /V « WARNING: System may not support » & echo Hibernate Settings : Changed to Never)


Hibernation-Modify

Statut batterie

@ECHO OFF

:: Localize variables

SETLOCAL

:: No command line arguments required

IF NOT « %~1″== » » GOTO Syntax

:: Check if WMIC.EXE is available

WMIC.EXE Alias /?:Brief >NUL 2>&1 || GOTO Syntax

:: Use WMI to retrieve battery status information

FOR /F « tokens=* delims= » %%A IN (‘WMIC /NameSpace: »\\root\WMI » Path BatteryStatus Get PowerOnline^,RemainingCapacity /Format:list ^| FIND « = »‘)     DO SET Battery.%%A

IF /I « %Battery.PowerOnline% »== »TRUE » (

) ELSE (

ECHO Remaining capacity %Battery.RemainingCapacity%%%

)

GOTO:EOF

:Syntax

:: End localization


Cluster MNS test batch

@echo off

SET Filer=

SET /p Filer=Hostname/IP du Filer&#58

echo Voici le Filer voulu : %Filer%

SET Chemin=

SET /p Chemin=Chemin local du Share&#58

echo Voici le chemin voulu : %Chemin%

SET NomShare=

SET /p NomShare=Nom du Share&#58

echo Voici le Nom du Share voulu : %NomShare%

pause

cmd /C %~dp0psexec.exe \\%Filer%\c$ %4 « /u:%3 » > nul 2>&1

if ERRORLEVEL=1 goto End

if not exist « %Chemin% » (

mkdir %Chemin%

)

net share %NomShare%=%Chemin%

icacls %Chemin% /save c:\temp\oldACLshare-%nomshare%

icacls %Chemin% /restore ACLshare /C /Q

:End

SET Filer=

SET Chemin=

SET NomShare=


::Affiche la structure des sous-dossiers avec leur chemin relatif à celui de ce BATCH

@ECHO OFF

FOR %%a in (« %CD% » ) DO SET racine=%%~Pna

ECHO.%racine%

SET s=%racine%

:LONG

SET /a L+=1

SET s=%s:~0,-1%

IF « %s% »== » » ECHO.LONGUEUR: %L% &Pause &GOTO SHOW

GOTO LONG

:SHOW

::Affiche le nom des chemins

FOR /F « Delims= » %%f in (‘DIR /b /s /ad « *.* »‘) DO (

CALL :SUB « %%~Pnf »

)

Pause

ECHO.SUITE DU BATCH

::Renvoie une sous chaine

:SUB

SET s=%~1

ECHO.%s:~2%

GOTO :EOF


Exemple test share

  • @echo off

echo make sure computerlist.txt is located in %cd%

for /f %%a in (computerlist.txt) (ping -l 10 -n 1 %%a & if %errorlevel% GTR 0 ^(SET CALLER=OFFLINE^) & IF %ERRORLEVEL%==0 ^(SET CALLER=COPY_FILE^) & set computer=%%a & call :%CALLER%)

:COPY_FILE

XCOPY \\SOMETHING TO \\%COMPUTERNAME% WHEREVER

GOTO :END

:OFFLINE

ECHO %COMPUTER% IS OFFLINE >> OFFLINELIST.TXT

:END

  • @echo off

set PCs= »C:\Users\administrator\Documents\PS\SVComps.csv »

set Logs= »C:\Users\administrator\Documents\PS\Copy.log »

set Source= »C:\Users\administrator\Documents\PS\test »

set Target=c$\DBFolder\

for /F %%a in (PCs.txt) do (

echo Processing %%a

ping %%a | find /i « Reply from » > nul

if ErrorLevel 1 (

echo %%a – Computer offline >> « %Logs% »

) else (

echo %%a – Computer online – Trying to copy >> « %Logs% »

xcopy /y /c /d %Source% \\%%a\%Target% 1>>%Logs% 2>>%Logs%

)

)


Script d’attente

@echo « Internet Explorer va se fermer dans 30s » & choice /t:o,305>nul

tskill iexplore

xcopy /c /y mms.cfg %WINDIR%\SysWOW64\Macromed\Flash\

msiexec /i install_flash_player_11_active_x.msi /quiet /norestart /log C:\WIndows\Temp\flash.log


REM === Add SNMP Windows Feature and Components ===

PowerShell

Add-WindowsFeature RSAT-SNMP,SNMP-Service,SNMP-WMI-Provider

REM === Switch to Command Prompt to use REG ADD command for configure SNMP Community String ===

CMD

REM == Configure SNMP Community Sting for SIN DC ==

REG Query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities

REG Delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities /va /f

REG Add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities /v « Your_Security_SNMP_String » /t REG_DWORD /d 4 /f

REG Query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration

REG Delete « HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\public » /f

REG Add « HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\Your_Security_SNMP_String » /f

REG Add « HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\Your_Security_SNMP_String » /v « Traps » /t REG_SZ /d « SNMPTrapServer_HostNameOrIP » /f

REG Query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers

REG Delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers /va /f

Delete windows.old

$
0
0

Delete windows.old

•        takeown /F c:\Windows.old\* /R /A /D Y

•        cacls c:\Windows.old\*.* /T /grant administrators:F

•        rmdir /S /Q c:\Windows.old

Article 1

$
0
0

voir DC utilisé pour se connecter

echo %LOGONSERVER%

nltest /dsgetdc:<domain_name>

gpresult /R

 

voir dernier reboot / redémarrage

net statistics workstation

 

Get-WmiObject -class « Win32_TSGeneralSetting » -Namespace root\cimv2\terminalservices -Filter « TerminalName=’RDP-tcp’”

 

netsh firewall show state

 

Disable Windows firewall

Netsh advfirewall set allprofiles state off

 

————— hotfix —————–

WMIC

wmic qfe list full /format:htable >C:\Temp\hotfixes.htm

 

1.Open a command prompt. To do so, click Start, type cmd, and press ENTER.

2.Type cd %userprofile% and press ENTER.

3.Type wmic qfe list full /format:htable > hotfixes.htm

4.Type start iexplore %userprofile%\hotfixes.htm

 

PowerShell

1.Open a PowerShell prompt. To do so, click Start, type PowerShell, and press ENTER.

2.Type Get-WmiObject -Class « win32_quickfixengineering » and press ENTER.

Get-WmiObject -Class « win32_quickfixengineering » |

Select-Object -Property « Description », « HotfixID »,

@{Name= »InstalledOn »; Expression={([DateTime]($_.InstalledOn)).ToLocalTime()}}

 

 

Liste des SID

Whoami /all

 

nltest /dsgetdc:domainname

Mountvol T: /P

Mountvol T:test /P

  1. Sur source et destination:

Xpinfo -i

–> copie dans fichiers excel pour taille et LDEV

  1. Sur source :

Ecrire manuellement nom de chaque disque sur excel file entre 2 tableau src et target

Unmount disk mounter via disk mgr (del letter)

 

  1. SAN Team break disk link
  2. Rescan
  3. Repérer les disques (diff pt montage et racines)
  4. Add letter to disk au disque racine
  5. Rename disk
  6. Add mount (via add letter) to all disk mount (via Excel file)

 

Fsutil fsinfo ntfsinfo e:

————————– cmd les plus utilisées ————————

fsutil fsinfo drives

 

pour avoir le type de lecteur (dur, cd) :

fsutil fsinfo drivetype c:

gpresult /R     (rsop)

gpresult /V   (verbose)

wmic alias list full

sc query

 

attrib

compact

cipher

copy, xcopy, robocopy

del

expand

takeown

net use

ftype

diskpart

fsutil hardlink list temp.txt

mklink

symlink

defrag

convert

echo

call

cls

if

for

goto

menu

more

pause

:outofrange

:eof

gtr

%

==

sc

powercfg

mstsc

wecutil

shutdown

systeminfo

whoami

msconfig

cmdkey

wusa

msiexec

mbsacli

netsh

winrm, winrs

wmic

arp

hostname

sfc

sigverif

tasklist

taskkill

driverquery

ipconfig

tracert

ping

pathping -n (no dns resolve)

getmac

bcdedit

chkdsk

repair-bde

Setacl

nslookup

dism

sysprep

oscdimg

imagex

usmt

drvload

wpeutil

Script PowerShell d’extraction AD pour audit sécurité

$
0
0

############################################
#                                          #
#         Script d’extraction AD           #
#                                          #
# PowerShell v4                            #
############################################

$ErrorActionPreference = ‘SilentlyContinue’
#$ErrorActionPreference = « SilentlyContinue » #Erreurs non affichées et exécution se poursuit sans interruption

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#                    Import des modules PowerShell                     #
#//////////////////////////////////////////////////////////////////////#

Import-module -Name ActiveDirectory
Import-module -Name GroupPolicy

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#                   Initialisation des Variables                       #
#//////////////////////////////////////////////////////////////////////#

$dicGroupGPO = @{}
$dicoToken = @{}
$ADDomain = get-addomain
$sDomainName = $ADDomain.DNSRoot
$oLDAPGroups = $oListGroup

# Variables pour les fichiers à  créer
$Pathprojet = « C:\serveur_apps\scripts\projet »
$GroupGPOAD = $Pathprojet + « \GroupGPOAD_SARL.csv »
$sSARLFilePath1 = $Pathprojet + « \UserListAD_SARL.csv »
$sSARLFilePath2 = $Pathprojet + « \UserGroupAD_SARL.csv »
$sSARLFilePath3 = $Pathprojet + « \temp.tmp »
$GPOfileOut = $Pathprojet + « \GPO.txt »

# Variables pour les logs
$dDateCourante = Get-Date
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss »)+  » INFO – Début d’exécution  »
$sLogFile = « C:\serveur_apps\scripts\projetlog\log.txt »

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#                 Initialisation des Fonctions                         #
#//////////////////////////////////////////////////////////////////////#
# Fonction pour convertir un chemin LDAP en canonical / le nom du groupe n’est pas gardé dans la valeur de retour
Function ConverTprojetnonicalName ($strToConvert,$sDomain)
{
$canonicalname = $sDomain + « / »
$liste = $strToConvert -split « , »
For ($i = -1 ; $i -gt -$liste.count; $i — )
{
if (($liste[$i]).substring(0,3) -eq « OU= ») {
$canonicalname +=  ($liste[$i]).substring(3,($liste[$i]).length-3) + « / »

}
if (($liste[$i]).substring(0,3) -eq « CN= ») {
$canonicalname +=  ($liste[$i]).substring(3,($liste[$i]).length-3) + « / »
}
}
return $canonicalname
$canonicalname = $Null
}

# Fonction retournant les sous groupes d’un groupe
function Get-GroupHierarchy ($SearchGroup, $sGPO)
{
If ($searchGroup -ne «  »)
{
If ($dicGroupGPO.ContainsKey($searchGroup))
{
$aGroupMember = $dicGroupGPO.Get_Item($searchGroup)
ForEach ($groupmember in $aGroupMember)
{
$strGroupmember = $groupmember.name
$strGroupmemberDNWithoutGroupName = $groupmember.DistinguishedName
$strGroupmemberCN = ConverTprojetnonicalName $strGroupmemberDNWithoutGroupName $sdomainName
« $strGroupmember;$sGPO;$strGroupmemberCN » | Out-File -Append -FilePath $sSARLFilePath3 -Encoding Unicode
}
}
Else
{
$groupMembers = get-adgroupmember $searchGroup | where {$_.ObjectClass -eq « group »} #| select-object name
If ($groupMembers)
{
$dicGroupGPO.add($searchGroup,$groupMembers)
Foreach ($groupmember in $groupMembers)
{
$strGroupmember = $groupmember.name
$strGroupmemberDNWithoutGroupName = $groupmember.DistinguishedName
$strGroupmemberCN = ConverTprojetnonicalName $strGroupmemberDNWithoutGroupName $sdomainName
« $strGroupmember;$sGPO;$strGroupmemberCN » | Out-File -Append -FilePath $sSARLFilePath3 -Encoding Unicode
Get-GroupHierarchy $strGroupmember $sGPO
} # foreach $groupmembers
} #If $groupMembers
} #else
}#if($dicGroupGPO.ContainsKey($searchGroup))
} # end of function

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#                    Vérification du répertoire                        #
#//////////////////////////////////////////////////////////////////////#

# Répertoire pour les fichiers de log
If(!(Test-Path $sLogFile ))
{
$sresult = New-Item $sLogFile -type directory
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » INFO – SUCCES Le répertoire  » + $Pathprojet +  » a été créé »
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}

# Réroire pour les fichiers d’extraction
If(!(Test-Path $Pathprojet))
{
Try
{
$sresult = New-Item $Pathprojet -type directory
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » INFO – SUCCES Le répertoire  » + $Pathprojet +  » a été créé »
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
Catch
{
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ERREUR – Création du répertoire  » + $Pathprojet +  » impossible »
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
ForEach($ErreurMessage in $Error)
{
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ERREUR –  » + ($ErreurMessage.ToString()).Replace(« `n », » »)
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
$Error.clear()
}
}

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\#
#                      Extraction données                              #
#//////////////////////////////////////////////////////////////////////#

# Vérification de la présence des fichiers, suppressions si « true »
If(Test-Path $sSARLFilePath1){remove-item -path $sSARLFilePath1 -Force}
If(Test-Path $sSARLFilePath2){remove-item -path $sSARLFilePath2 -Force}
If(Test-Path $sSARLFilePath3){remove-item -path $sSARLFilePath3 -Force}
If(Test-Path $GroupGPOAD){remove-item -path $GroupGPOAD -Force}
If(Test-Path $GPOfileOut){remove-item -path $GPOfileOut -Force}

######### Création du fichier groupe GPO #########
# Extraction des GPO dans un fichier puis une variable
$oListGPOS = Get-gpo -all | format-table DisplayName -HideTableHeaders | out-file $GPOfileout
$oListGPOS = Get-Content $GPOfileout
$sResult = New-Item $sSARLFilePath3 -type file -force

# Préparation du fichier GPO, entêtes
$sOutPutMess = « Nom du groupe;Nom de la GPO;OU Group »
$sOutPutMess | Out-File -Append -FilePath $GroupGPOAD  -Encoding Unicode
$Error.clear()

Foreach ($oListGPO in $oListGPOS) # Début de traitement du tableau utilisateur et GPO
{
$Error.clear()
Try
{
$oListGPO = ($oListGPO).trim()
$oListPERMISSIONS = Get-GPPermissions -Name $oListGPO -All -DomainName $sDomainName

# Check des permissions sur chaque GPO
Foreach ($sListPERMISSION in $oListPERMISSIONS )
{
If(($sListPERMISSION.Permission -eq « GpoApply ») -and ($sListPERMISSION.Trustee.Name -ne « Utilisateurs authentifiés »))
{
# S’il y a un utilisateur ou ordinateur directement dans le filtre GPO
If (($sListPERMISSION.Trustee.SIDType -eq « User ») -or ($sListPERMISSION.Trustee.SIDType -eq « Computer »))
{
$sGPOMessage = « ATTENTION  » + $sListPERMISSION.Trustee.SIDType +  »  » + $sListPERMISSION.Trustee.Name + « ; » + $oListGPO
$sGPOMessage | Out-File -Append -FilePath $sSARLFilePath3  -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ATTENTION – Des utilisateurs ou ordinateurs sont directement rattachés à la GPO :’$oListGPO’. Fichier :   » + $sSARLFilePath3
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
ElseIf ($sListPERMISSION.Trustee.SIDType -eq « Unknown »)
{
$sGPOMessage = « ATTENTION Groupe ou utilisateur inexistant; » + $oListGPO
$sGPOMessage | Out-File -Append -FilePath $sSARLFilePath3  -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ATTENTION – Groupe ou utilisateur inexistant pour la GPO : ‘$oListGPO’ Fichier : $sSARLFilePath3″
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
Else
{
$strDSPathGroupe = $sListPERMISSION.Trustee.DSPath
$strCNGroupe = ConverTprojetnonicalName $strDSPathGroupe $sdomainName
$sGPOMessage = $sListPERMISSION.Trustee.Name + « ; » + $oListGPO + « ; » + $strCNGroupe
$sGPOMessage | Out-File -Append -FilePath $sSARLFilePath3  -Encoding Unicode
Get-GroupHierarchy $sListPERMISSION.Trustee.Name $oListGPO
}
}
} #Foreach ($sListPERMISSION in $oListPERMISSIONS )
} # Try
Catch
{
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ERREUR – Problème de traitement du fichier, GPO : ‘$oListGPO’  dans  » + $sSARLFilePath3 +  » pour  » + $GroupGPOAD
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
ForEach($ErreurMessage in $Error)
{
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ERREUR –  » + ($ErreurMessage.ToString()).Replace(« `n », » »)
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
$Error.clear()
}
} #Foreach ($oListGPO in $oListGPOS)

# Tri pour avoir unicite des resultats
# le passage par un fichier temporaire et un tri est preferable à l utilisation d’un tableau pour de nombreuses donnees
Get-Content $sSARLFilePath3 | sort | Get-Unique | out-file -Append -FilePath $GroupGPOAD -Encoding Unicode

######### Requètes des utilisateurs #########
$oLDAPUsers = Get-ADUser -filter * –properties SamAccountName,Surname,GivenName,DistinguishedName,whencreated,Enabled,LockedOut,LastLogonDate,PasswordNeverExpires,PasswordLastSet,CannotChangePassword,PasswordNotRequired,AccountLockoutTime,LockedOut
Get-GroupHierarchy $sListPERMISSION.Trustee.Name $oListGPO

######### Requètes des groupes #########
$oListGroup = Get-ADGroup -filter * -Properties SamAccountName

# Construction des fichiers utilisateurs et groupes : new file ; création des entetes, logs,
If($oLDAPUsers -And $oLDAPGroups)
{
# Création des fichiers, des entetes et écritures dans le log
$sresult = New-Item $sSARLFilePath1 -type file # Création du nouveau fichier ‘SARL_UserListAD.csv’
$sOutPutMess = « Identifiant;Nom;Prenom;DN du compte;Date de creation du compte;Date derniere modification du compte;Statut Actif;Compte verrouillé;Date derniere connexion du compte;Mot de passe expiré;Derniere modification du mot de passe;Mot de passe permanent;Mot de passe optionnel;Date d expiration;Duree depuis le verrouillage;Nombre de mauvais mot de passe ;Mot de passe verrouillé;Changement de mot de passe au prochain demarrage »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath1 -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » INFO – Début de traitement du fichier  » + $sSARLFilePath1
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode

$sresult = New-Item $sSARLFilePath2 -type file # Création du nouveau fichier 2
$sOutPutMess = « Identifiant;Domaine;Ressources »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath2 -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » INFO – Début de traitement du fichier  » + $sSARLFilePath2
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode

$iValue = 0x02
$oCultureInfo = New-Object System.Globalization.CultureInfo(« fr-FR »)

Foreach ($oLDAPUser in $oLDAPUsers) # Début de traitement du tableau utilisateur
{
$Error.clear()
Try
{
$sSAMAcName = $oLDAPUser.samaccountname
$sLastName = $oLDAPUser.sn
$sFirstName = $oLDAPUser.givenname

$sdistinguishedName = $oLDAPUser.distinguishedname
#DN du compte sans le nom de l’utilisateur, valeur ‘DN du compte’ dans le fichier $sSARLFilePath1
$sDistinguishedNameWithoutUserName = ($sdistinguishedName -split(« , »,2))[1]

#En remplacement du ‘Get-ACL’ et ‘récup compte verrouillé’
$sUserProperties = Get-ADUser -SearchScope Base -SearchBase $sdistinguishedName -Filter * -Properties CannotChangePassword,LockedOut,PasswordExpired -Server $sDomainName

$sPwdProtected = $sUserProperties.CannotChangePassword

If($oLDAPUser.whencreated) #format date
{
$sWhenCreated = [datetime]::Parse($oLDAPUser.whencreated.ToString())
$dWhenCreated = ($sWhenCreated.ToLprojetlTime()).ToString(« G », $oCultureInfo)
}
Else {$dWhenCreated = $Null}

If($oLDAPUser.whenchanged) #format date
{
$sWhenChanged = [datetime]::Parse($oLDAPUser.whenchanged.ToString())
$dWhenChanged = ($sWhenChanged.ToLprojetlTime()).ToString(« G », $oCultureInfo)
}
Else {$dWhenChanged = $Null}

If($oLDAPUser.lastlogontimestamp) #format int
{
$dLastLogOn = [datetime]::FromFileTime([Int64]::Parse($oLDAPUser.lastlogontimestamp))
$sLastLogOn = $dLastLogOn.ToString(« G », $oCultureInfo)
}
Else {$sLastLogOn = $Null}

$sUserAccountLocked = $sUserProperties.LockedOut

If($oLDAPUser.lockouttime -gt 0) #format int
{
$sLastlockoutTime = [datetime]::FromFileTime([Int64]::Parse($oLDAPUser.lockouttime))
$dLastlockoutTime = $sLastlockoutTime.ToString(« G », $oCultureInfo)
}
Else {$dLastlockoutTime = «  »}

$sPasswordExpired = $sUserProperties.PasswordExpired

If(($oLDAPUser.pwdlastset -ne 0) -and ($oLDAPUser.pwdlastset -ne $NULL)) #format int
{
$spwdLastSet = [datetime]::FromFileTime([Int64]::Parse($oLDAPUser.pwdlastset))
$dpwdLastSet = $spwdLastSet.ToString(« G », $oCultureInfo)
$spwdToInitialize = « False »
}
Else
{
$spwdToInitialize = « True »
$dpwdLastSet = «  »
}

$DONT_EXPIRE_PASSWORD = 65536
If($oLDAPUser.useraccountcontrol)
{
If($oLDAPUser.useraccountcontrol.Value -band $DONT_EXPIRE_PASSWORD) {$sPwdPermanent = « True »}
Else {$sPwdPermanent = « False »}
}
Else {$sPwdPermanent = « False »}

$PASSWORD_NOT_REQUIRED = 32
If($oLDAPUser.useraccountcontrol)
{
If($oLDAPUser.useraccountcontrol.Value -band $PASSWORD_NOT_REQUIRED) {$sPwdNotRequired = « True »}
Else {$sPwdNotRequired = « False »}
}
Else {$sPwdNotRequired = « False »}

If (($oLDAPUser.accountexpires -ne 0) -and ($oLDAPUser.accountexpires -ne $NULL) -and ($oLDAPUser.accountexpires -le [DateTime]::MaxValue.Ticks))
{
$saccountExpires = [datetime]::FromFileTime([Int64]::Parse($oLDAPUser.accountexpires))
$daccountExpires = $saccountExpires.ToString(« G », $oCultureInfo)
}
Else {$daccountExpires = «  »}

$sbadPwdCount = $oLDAPUser.badpwdcount

$ACCOUNT_DISABLE = 2
If($oLDAPUser.useraccountcontrol)
{
If($oLDAPUser.useraccountcontrol -band $ACCOUNT_DISABLE) {$sUserAcControl = « Disabled »}
Else {$sUserAcControl = « Enabled »}
}
Else {$sUserAcControl = $Null}

$aGroupMembers = Get-ADUser -SearchScope Base -SearchBase $oLDAPUser.distinguishedname -LDAPFilter ‘(objectClass=user)’ -Properties tokenGroups -Server $sDomainName| Select-Object -ExpandProperty tokenGroups | Select-Object -ExpandProperty Value

ForEach($tokenGroup In $aGroupMembers)
{
Try
{
If($sSAMAcName)
{
If ($dicoToken.ContainsKey($tokenGroup))
{
$sGroupPath_strNameTokenGroup = $dicoToken.Get_Item($tokenGroup)
$sOutPutMess = « $sSAMAcName;$sGroupPath_strNameTokenGroup »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath2 -Encoding Unicode
}
Else
{
$strTokenGroupIndentity = Get-ADGroup -Identity $tokenGroup -Server $sDomainName
$strNameTokenGroup = $strTokenGroupIndentity.Name
$strDistNameTokenGroup = $strTokenGroupIndentity.DistinguishedName
$sGroupPath = ConverTprojetnonicalName $strDistNameTokenGroup $sdomainName
$sOutPutMess = « $sSAMAcName;$sGroupPath;$strNameTokenGroup »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath2 -Encoding Unicode
$strGroupForDico = « $sGroupPath;$strNameTokenGroup »
$dicoToken.Add($tokenGroup,$strGroupForDico)
}
}#If($sSAMAcName)
} # try
Catch
{
ForEach($ErreurMessage in $Error)
{
If (!(($ErreurMessage.CategoryInfo.Category -eq « ObjectNotFound ») -and ($ErreurMessage.CategoryInfo.Reason -eq « ADIdentityNotFoundException »)))
{
$sOutPutMess = « ATTENTION PROBLEME sur utilisateur $sSAMAcName et le groupe $tokenGroup (Partie Début de traitement du tableau utilisateur du script) »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath2 -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ATTENTION PROBLEME – sur utilisateur $sSAMAcName dans fichier $sSARLFilePath2″ +  » Partie Début de traitement du tableau utilisateur du script »
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ERREUR NON BLOQUANTE –  » + ($ErreurMessage.ToString()).Replace(« `n », » ») + « Partie Début de traitement du tableau utilisateur du script »
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
Else
{
$objSID = New-Object System.Security.Principal.SecurityIdentifier ($tokenGroup)
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])

$sOutPutMess = « $sSAMAcName;$objUser;$tokenGroup »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath2 -Encoding Unicode
}
} # foreach
$Error.clear()
} #catch
If($sSAMAcName) # Ajout des données de l’utilisateur en cours de traitement dans le fichier 1 SARL
{
$sOutPutMess = « $sSAMAcName;$sLastName;$sFirstName;$sdistinguishedNameWithoutUserName;$dWhenCreated;$dWhenChanged;$sUserAcControl;$sUserAccountLocked;$sLastLogOn;$sPasswordExpired;$dpwdLastSet;$sPwdPermanent;$sPwdNotRequired;$daccountExpires;$dLastlockoutTime;$sbadPwdCount;$sPwdProtected;$spwdToInitialize »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath1 -Encoding Unicode
}
} #ForEach($tokenGroup In $aGroupMembers)
}#Try de Foreach ($oLDAPUser in $oLDAPUsers)
Catch
{
$sOutPutMess = « ATTENTION PROBLEME sur utilisateur $sSAMAcName;$sLastName;$sFirstName;$sdistinguishedNameWithoutUserName;$dWhenCreated;$dWhenChanged;$sUserAcControl;$sUserAccountLocked;$sLastLogOn;$sPasswordExpired;$dpwdLastSet;$sPwdPermanent;$sPwdNotRequired;$daccountExpires;$dLastlockoutTime;$sbadPwdCount;$sPwdProtected;$spwdToInitialize »
$sOutPutMess | Out-File -Append -FilePath $sSARLFilePath1 -Encoding Unicode
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ATTENTION PROBLEME – sur utilisateur $sSAMAcName dans fichier $sSARLFilePath1″
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
ForEach($ErreurMessage in $Error)
{
$sLogMessage = (Get-Date).ToString(« dd/MM/yyyy HH:mm:ss ») +  » ERREUR NON BLOQUANTE –  » + ($ErreurMessage.ToString()).Replace(« `n », » »)
$sLogMessage | Out-File -Append -FilePath $sLogFile -Encoding Unicode
}
$Error.clear()
} # catch
} #Foreach ($oLDAPUser in $oLDAPUsers) # tableau utilisateur
} #If($oLDAPUsers -And $oLDAPGroups)

# Suppresion des fichiers temporaires
$ErrorActionPreference = ‘SilentlyContinue’
If(!(Test-Path $sSARLFilePath3)){Remove-Item $sSARLFilePath3}
If(!(Test-path $GPOfileout)){Remove-Item $GPOfileout}
#If(!(Test-path $sSARLFilePath3)){
Remove-Item $sSARLFilePath3

Framework .Net 3.5 sur Windows Server 2016

$
0
0

Comme pour Windows Server 2012 il faut préciser le chemin de l’ISO sans quoi les binaires ne sont pas disponible et on ne peux pas installer le Framework antérieur.

ATTENTION

Il faut que le service WINRM soit démarré contrairement aux bonnes pratique de sécurité qui demandent de le désactiver ainsi que l’administration à distance :

WINRM article

Commandes WINRM :

winrm help config

get-sservice winrm

start-service winrm

restart-service winrm

Configure-SMRemoting.exe -enable,

 


 

Le Gestionnaire de serveur s’appuie sur les paramètres de l’écouteur WinRM par défaut des serveurs distants que vous voulez gérer. Si le mécanisme d’authentification par défaut ou le numéro de port de l’écouteur WinRM d’un serveur distant a été modifié par rapport au paramètre par défaut, le Gestionnaire de serveur ne peut pas communiquer avec le serveur distant.

La liste ci-dessous indique les paramètres par défaut de l’écouteur WinRM pour une gestion à l’aide du Gestionnaire de serveur.

  • Le service WinRM est en cours d’exécution.
  • Un écouteur WinRM est créé pour accepter les demandes HTTP via le numéro de port 5985.
  • Le numéro de port 5985 est activé dans les paramètres du Pare-feu Windows pour autoriser les demandes via WinRM.
  • Les deux types d’authentification Kerberos et Négocier sont activés.

Port par défaut pour les communications de WinRM avec un ordinateur distant est 5985.

sources winrm

GPO via gpedit.msc :

Computer Configuration\Administrative Templates\Windows Components\Windows Remote Shell\Allow Remote Shell Access

Affichage du contenu du lecteur WSMan:

Cette commande utilise l’applet de commande Get-Childitem pour afficher les magasins WS-Management à l’emplacement des magasins des certificats de Localhost.

get-childitem -path WSMan:\Localhost
https://technet.microsoft.com/fr-fr/library/hh847813.aspx

Filer mgmt Best practice secu

$
0
0

Filer management is a sensitive activity due to the following reasons

  • File servers datas are critical for the business
  • File servers are used by the applications

 

One critical point is also related to the security management (in order to ensures that datas are well protected avoiding rogues access). The security is also part of the disponibility of the service.

 

The aim of this document is to reaffirm the best practices in order to standardize the approach for filer across all CA-CIB offices.

 

Share Naming

The share name should be keep as short as possible without spaces on it and match with the name of the folder on the disk. (For instance D:\SHARE_1 shared as SHARE_1). Of course in case of hidden folder you will need to complete share name with “$”.

 

One folder = one share, do not share again (even under the share). For instance D:\SHARE_1\TEST folder cannot be shared twice (1 time as SHARE_1 at the D:\SHARE_1 level and 1 time as TEST at the D:\SHARE_1 \TEST level

 

For applicative shares the name should allow the identification easyly with :

  1. The name of the application (by using the CASEWISE code)
  2. The environment (PRD, INT,DEV…) è Datas should be segregated across shares for instance one share for Production and another one for preproduction.
  3. In order to enhance the lisibility separate fields with _ for instance CCC_PRD for CCC application share with production datas.

Applicative shares must contain only applicative datas (no mix with corp / group datas or end users datas)

 

Share Usage

The usage of a share must be clearly defined with the client. Usage, purpose… In case of shares for application it’s recommended to ensure:

  • The structure of data
    • Folder tree depth
    • Number of files (hundreds, thousands, millions)
    • Number of simultaneous connections
  • Change/ update frequency

 

Security and ACL management

The use of built-in groups is prohibited for granting access to users

  • No Everyone
  • No Authenticated Users
  • No Anonymous
  • No Domain Users (or default Server\Users group)

 

If you need to grant access to a large set of users by using these groups please refer to your local compliance officer.

 

Active Directory Groups must be created for each share (no reuse of groups across multiple shares) and the share name must be visible in the group name. Never use server local groups to grant access to a share (always domain local or universal groups)

 

The group name must reflect the rights on the share (the group name should ends with _R for Read , _RW for Read/Write, _L for list only).

 

For instance DL_SHARE1_RW for access to Share_1 with Read-Write access.

Note that giving access with Full Control is not allowed to end users. Full control is only permitted to Administrators.

 

When sharing a folder you can change the permission up to 2 levels by using specific groups.

 

 

All access must be secured at the NTFS Level only, Permissions at the share Level must be Everyone Full control only.

 

 

Do not configure permissions at this level; Only NTFS rights must be used.

 

Never grant access directly to a user (Except for home-directories).

 

 

Share management recommendations

When a share is created it’s important to identify the stakeholders that are reliable in the time.

  • For an application identify the owner
  • For a data share the business line associated

 

This will help to identify the validator for granting access and the contact in case of operation over the share.

In case of reorganization in a department the best practice is to try to recreate a new folder structure with appropriate rights:

  • Preventing unwanted access
  • Ensures that only validated users can access to the data
  • Fit with the business needs

 

Even if this could be heavy it’s the best way to avoid historical problems if an audit occurs.

 

When providing a share resource the best practice is to challenge the requester regarding the size.

Quotas must be configured for all shares, according to business needs, if no quota is configured takes the actual size and set a quota at 20% more (for instance if a no quota share have 100GB used set a quota at 120GB).

 

When possible, try to configure an alert by E-Mail to the owner if the quota as reach 85% in order to be proactive and avoid a blocking saturation. The monitoring of disks saturation should be realized on a regular basis (follow of disks usages and quotas occupation). Even if it’s possible to overprovision quotas (for instance allowing 4 shares with 50GB quotas on a 100GB disks) it should be done with caution.

 

Filers infrastructure disponibility and security

The file server infrastructure that hosts the shared folders in production, whatever the solution, must meet the following requirements:

 

  • DR compliant with a RTO at 4hrs MAX and a RPO at 30mins MAX.
  • Security Patch management must be realized at least on a Quarter basis.

 

Backups are mandatory and the strategy must be shared with the client in order to avoid misunderstood (especially regarding the recovery time in case of issue). Try to limit the size of disks / volumes in order to prevent a too large downtime in case of scandisk or partition corruption (less than 2 TB per drives for Windows 2008R2 and up to 4TB per drives with Windows 2012R2 thanks to chkdsk online improvments).

 

Regular IRVS scans must be realized by SIT team in order to identify potentials vulnerability.

 

Whatever the solution retained to host the files servers it must provide an antivirus solution in order to protect the resources against virus.

 

As part of the best practices it’s important to segregate administration in order to ensure that peoples who are performing administration tasks only have the proper level of rights over the system (no need to be full administrator to create a share, change a quota or modifying permissions). Always keep in mind the less privilege principle.

 

All request to access to a file share must be traced, at least through a ticketing tool (such as service center or equivalent solution) or by using GRANT. For each request a validation of the owner of the data (BLAO) or the requester manager is necessary.

A project (DIAM) is currently under deployment to automate GRANT workflow in order to have a fully automated process (up to the user account addition / removal in the resource group) with consistency checks between the declared access in GRANT and the group membership (with dynamic correction).

 

 

The solution providing file server’s services must provide audits in order to retrieve who have make changes over a folder. CA-CIB has standardized VARONIS Datadvantage for this purpose. This solution allow administrator to track users activity for compliance needs but also help administrators to identify old data’s (never accessed since 18 month for instance) for archiving purposes.

 

A review of all shares (at least 1 review by year) to prevent unwanted access is mandatory. The aim of this review is to ensure that no open ACL are configured (Everyone, Authenticated users, Domain users…). SSS team can help local team by providing some home-made tools for that.


Problème de driver contrôleur « Paravirtuel VMware »

$
0
0

Pour l’installation d’une nouvelle VM ou Template Windows 2016 avec un contrôleur « Paravirtuel VMware » il faut les drivers correspondant.

Deux choix s’offrent à nous

  1. Copier le drivers depuis une VM déjà installé en 2016 pour l’ajouter dans notre nouvelle installation lors du choix de la partition
  2. Pas de VM en 2016, mettre son contrôleur en SAS et faire la modification à la fin

 

1 Créer une VM avec un contrôleur SCSI en SAS par exemple

2 Une fois la VM installé avec l’OS WS2016, ajouter un contrôleur SCSI en Paravirtuel VMware et y ajouter un disque

3 Installer les VMtools et redémarrer la VM, ainsi le pilote s’installe car il a besoin de reconnaitre et de monter le nouveau disque.

4 Eteindre la VM pour retirer le VMDK et le second ctrl SCSI

5 Modifier le premier ctrl en Paravirtuel VMware et démarré la VM

Liens MIM, Azure AD, gestion d’identité

$
0
0

Identité hybride : Comparaison des outils d’intégration d’annuaire

Mettre à niveau Microsoft Azure Active Directory Sync et Azure Active Directory Sync

Gérer vos identités en interne et sur le Cloud avec FIM 2010

Documetnation Microsoft Identity Manager

MIM 2016

Guide de prise en main de l’intégration d’Azure Active Directory avec les applications

Gestion de l’authentification unique pour les applications d’entreprise

Gestion de l’accès aux applications

Créer un groupe et ajouter des membres dans Azure Active Directory

Identity and Access Management Support Team Blog

Formation Azure gratuite (vidéos en lignes) Administration, AWS, dév, Azure Stack, Node.Js, Architect Azure…

Gérer les certificats avec ILM 2007 FP1

Images de machine virtuelle Oracle pour Azure

Langage, plateformes, frameworks, CRM, pris en charge

Cognitive services (reco visage, emotios, tag video, geste, intelligence

Stockage

Informations et au développement d’applications, mise en route de Visual Studio Application Insights

Références aux pratiques recommandées concernant les performances

Autres références relatives à la migration vers le cloud

Liens Kerberos SPN et outils AD

$
0
0

Tools

Nslookup http://technet.microsoft.com/en-us/library/cc725991.aspx

Nltest http://technet.microsoft.com/en-us/library/cc731935.aspx

Klist http://technet.microsoft.com/en-US/library/hh134826.aspx

Network tracing (packet sniffing) built-in to Windows Server 2008 R2 and Windows Server 2012. http://blogs.technet.com/b/yongrhee/archive/2012/12/01/network-tracing-packet-sniffing-built-in-to-windows-server-2008-r2-and-windows-server-2012.aspx

Audit Filtering Platform Packet Drop http://technet.microsoft.com/en-us/library/dd941625(v=WS.10).aspx

Download location http://www.microsoft.com/en-us/download/details.aspx?id=39046

Setspn http://technet.microsoft.com/en-us/library/cc731241.aspx

Service Principal Names (SPNs) SetSPN Syntax (Setspn.exe) http://social.technet.microsoft.com/wiki/contents/articles/717.service-principal-names-spns-setspn-syntax-setspn-exe.aspx

 

Tips SPN

Kerberos Authentication problems – Service Principal Name (SPN) issues – Part 1 http://blogs.technet.com/b/askds/archive/2008/05/29/kerberos-authentication-problems-service-principal-name-spn-issues-part-1.aspx

Register a Service Principal Name for Kerberos Connections http://technet.microsoft.com/en-us/library/ms191153(v=sql.110).aspx

Double-hop authentication: Why NTLM fails and Kerberos Works  http://blogs.msdn.com/b/besidethepoint/archive/2010/05/09/double-hop-authentication-why-ntlm-fails-and-kerberos-works.aspx

 

Tips SPN SQL

Collé à partir de <https://blogs.msdn.microsoft.com/sqlupdates/2014/12/05/sql-server-kerberos-and-spn-quick-reference/>

 

Kerberos

Configuring Linked Servers for Delegation http://technet.microsoft.com/en-us/library/ms189580(v=SQL.105).aspx

Ticket Granting Tickets http://msdn.microsoft.com/en-us/library/aa380510.aspx.

Session Tickets http://msdn.microsoft.com/en-us/library/aa380136.aspx.

How the Kerberos Version 5 Authentication Protocol Works http://technet.microsoft.com/en-us/library/4a1daa3e-b45c-44ea-a0b6-fe8910f92f28

kerberos Constrained Delegation Overview http://technet.microsoft.com/en-us/library/jj553400.aspx

Configure Analysis Services for Kerberos constrained delegation http://technet.microsoft.com/en-us/library/dn194199.aspx

Kerberos Survival Guide http://social.technet.microsoft.com/wiki/contents/articles/4209.kerberos-survival-guide.aspx

Kerberos for the Busy Admin http://blogs.technet.com/b/askds/archive/2008/03/06/kerberos-for-the-busy-admin.aspx

Kerberos Troubleshooting http://blogs.msdn.com/b/canberrapfe/archive/2012/01/02/kerberos-troubleshooting.aspx

 

Kerberos+SQL

how to Implement Kerberos Constrained Delegation with SQL Server 2008 http://msdn.microsoft.com/en-us/library/gg723715.aspx

You may experience connectivity issues to SQL Server if SPNs are misconfigured http://support.microsoft.com/kb/2443457

You may experience connectivity issues if SQL Server service account delegation settings are misconfigured http://support.microsoft.com/kb/2443455

All About Kerberos “The Three Headed Dog” with respect to IIS and Sql http://blogs.msdn.com/b/chiranth/archive/2013/09/20/all-about-kerberos-the-three-headed-dog-with-respect-to-iis-and-sql.aspx

Kerberos Configuration Manager for SQL Server is available http://support.microsoft.com/kb/2985455

How to make sure that you are using Kerberos authentication when you create a remote connection to an instance of SQL Server 2005  http://support.microsoft.com/kb/909801

New tool: « Microsoft Kerberos Configuration Manager for SQL Server » is ready to resolve your Kerberos/Connectivity issues  http://blogs.msdn.com/b/farukcelik/archive/2013/05/21/new-tool-quot-microsoft-kerberos-configuration-manager-for-sql-server-quot-is-ready-to-resolve-your-kerberos-connectivity-issues.aspx

 

 

Liens LSA

$
0
0

Azure product announcements and updates

$
0
0

Azure HDInsight: price reductions on all HDInsight workloads and Microsoft R Server add-on
Pricing | HDInsight webpage
Azure HDInsight offers fully managed and supported Apache Hadoop, Spark, HBase, and Storm clusters. HDInsight lets you:

Create optimized clusters.
Process and analyze big data.
Cost-effectively scale your workloads up and down through decoupled compute and storage.

Microsoft R Server is an enterprise class server for hosting and managing parallel and distributed workloads of R processes on servers (Linux and Windows) and clusters (Hadoop and Apache Spark).

Effective January 5, 2018, we’ve reduced prices by up to 52 percent for all workloads on HDInsight and by an additional 80 percent for the Microsoft R Server add-on. As part of this price reduction, the Premium tier cluster will be renamed Enterprise Security Package, which can be optionally added to your HDInsight cluster. Pricing for Enterprise Security Package is currently in preview and is priced the same as the Premium tier. Learn more on the overview and pricing webpages.

Azure Media Services: price reduction for live encoding channels
Pricing | Encoding webpage
Azure Media Services provides encoding, live or on-demand streaming, content protection, and indexing for video and audio content.

With Media Services, you can:

Quickly deploy a live encoding channel in seconds.
Broadcast your live events or always available channels with support for all major streaming formats (HTTP Live Streaming [HLS], MPEG-DASH, and Smooth Streaming).
Use the top digital rights management (DRM) content protection systems (PlayReady, Widevine, and Apple FairPlay).

We’ve reduced prices by up to 38 percent on Standard live encoding channels, effective for billing periods beginning on or after January 5, 2018. Learn more on the overview and pricing webpages.

Microsoft IoT Central in preview
Pricing | Microsoft IoT Central webpage
Microsoft IoT Central is a fully managed software as a service (SaaS) offering that enables powerful Internet of Things (IoT) scenarios without requiring cloud solution expertise. It takes the hassle out of creating an IoT solution by:

Simplifying the complexities of initial setup.
Reducing the management burden, operational costs, and overhead of a typical IoT project.

Microsoft IoT Central is now available along with Azure IoT Suite, which enables deep customization and full control with one of the broadest portfolios of IoT offerings that includes Microsoft IoT Central, IoT Suite, and Azure IoT Edge.

Learn more on the overview and pricing webpages and via the Get started with Microsoft IoT Central webpage.

For a complete list of announcements and updates, visit Azure updates.

Note: As an Azure customer, you are receiving this email because we are required to notify you of product changes that may affect your subscription. This is the only communication that you will receive directly from Microsoft regarding these product changes.

Batch : hibernation, SNMP, test cluster MNS, test share, script d’attente (Workstation)

$
0
0

Call-Hibernation.bat

Mise en place des variables

@echo off

set WorkstationName=%1

echo %WorkstationName%

Copy du script vers la machine désignée et exécution du script à distance. Un check est effectué (sans log) et ensuite on supprime le répertoire hibernation qui a été créé à cet effet.

robocopy « . » « \\%WorkstationName%\c$\Hibernation » Hibernation.bat

psexec \\%WorkstationName% cmd /c « call c:\Hibernation\hibernation.bat »

psexec \\%WorkstationName% cmd /c « powercfg /query »

psexec \\%WorkstationName% cmd /c « rmdir /Q /S c:\Hibernation »

 


Hibernation.bat

Mise en place des conditions pour savoir si le poste est configuré sur le mode laptop ou workstation.

S’il est en mode Laptop, on laisse cette configuration, sinon on la change.

@echo off

powercfg /query |find /I « Name Portable/Laptop » > %errorlevel%

if %errorlevel%==0 (echo Portable/Laptop : OK) else (powercfg /SETACTIVE « Portable/Laptop » & echo Policy for Laptop enabled)

On effectue une modification de la stratégie sur les arrêts disques en mode « never ».

powercfg /query « Portable/Laptop » |find /I « Turn off hard disks (AC) Never » > %errorlevel%

if %errorlevel%==0 (echo Settings of DISK : OK) else (powercfg /change « Portable/Laptop » /disk-timeout-ac 00 |find /V « WARNING: System may not support » & echo Disk Settings Changed to Never)

On effectue une modification de la stratégie sur les arrêts des écrans en mode « never ».

powercfg /query « Portable/Laptop » |find /I « Turn off monitor (AC) Not Supported » > %errorlevel%

if %errorlevel%==0 (echo Settings of Monitor : OK) else (powercfg /change « Portable/Laptop » /monitor-timeout-ac 00 |find /V « WARNING: System may not support » & echo Monitor Settings : Changed to Never)

On effectue une modification de la stratégie sur les arrêts des « standby » en mode « never ».

powercfg /query « Portable/Laptop » |find /I « System standby (AC) Never » > %errorlevel%

if %errorlevel%==0 (echo Settings of StandBy : OK) else (powercfg /change « Portable/Laptop » /standby-timeout-ac 00 |find /V « WARNING: System may not support » & echo StandBy Settings : Changed to Never)

On effectue une modification de la stratégie sur les en mode « never ».

powercfg /query « Portable/Laptop » |find /I « System hibernates (AC) Never » > %errorlevel%

if %errorlevel%==0 (echo Settings of Hibernate : OK) else (powercfg /change « Portable/Laptop » /hibernate-timeout-ac 00 |find /V « WARNING: System may not support » & echo Hibernate Settings : Changed to Never)


Hibernation-Modify

Statut batterie

@ECHO OFF

:: Localize variables

SETLOCAL

:: No command line arguments required

IF NOT « %~1″== » » GOTO Syntax

:: Check if WMIC.EXE is available

WMIC.EXE Alias /?:Brief >NUL 2>&1 || GOTO Syntax

:: Use WMI to retrieve battery status information

FOR /F « tokens=* delims= » %%A IN (‘WMIC /NameSpace: »\\root\WMI » Path BatteryStatus Get PowerOnline^,RemainingCapacity /Format:list ^| FIND « = »‘)     DO SET Battery.%%A

IF /I « %Battery.PowerOnline% »== »TRUE » (

) ELSE (

ECHO Remaining capacity %Battery.RemainingCapacity%%%

)

GOTO:EOF

:Syntax

:: End localization


Cluster MNS test batch

@echo off

SET Filer=

SET /p Filer=Hostname/IP du Filer&#58

echo Voici le Filer voulu : %Filer%

SET Chemin=

SET /p Chemin=Chemin local du Share&#58

echo Voici le chemin voulu : %Chemin%

SET NomShare=

SET /p NomShare=Nom du Share&#58

echo Voici le Nom du Share voulu : %NomShare%

pause

cmd /C %~dp0psexec.exe \\%Filer%\c$ %4 « /u:%3 » > nul 2>&1

if ERRORLEVEL=1 goto End

if not exist « %Chemin% » (

mkdir %Chemin%

)

net share %NomShare%=%Chemin%

icacls %Chemin% /save c:\temp\oldACLshare-%nomshare%

icacls %Chemin% /restore ACLshare /C /Q

:End

SET Filer=

SET Chemin=

SET NomShare=


::Affiche la structure des sous-dossiers avec leur chemin relatif à celui de ce BATCH

@ECHO OFF

FOR %%a in (« %CD% » ) DO SET racine=%%~Pna

ECHO.%racine%

SET s=%racine%

:LONG

SET /a L+=1

SET s=%s:~0,-1%

IF « %s% »== » » ECHO.LONGUEUR: %L% &Pause &GOTO SHOW

GOTO LONG

:SHOW

::Affiche le nom des chemins

FOR /F « Delims= » %%f in (‘DIR /b /s /ad « *.* »‘) DO (

CALL :SUB « %%~Pnf »

)

Pause

ECHO.SUITE DU BATCH

::Renvoie une sous chaine

:SUB

SET s=%~1

ECHO.%s:~2%

GOTO :EOF


Exemple test share

  • @echo off

echo make sure computerlist.txt is located in %cd%

for /f %%a in (computerlist.txt) (ping -l 10 -n 1 %%a & if %errorlevel% GTR 0 ^(SET CALLER=OFFLINE^) & IF %ERRORLEVEL%==0 ^(SET CALLER=COPY_FILE^) & set computer=%%a & call :%CALLER%)

:COPY_FILE

XCOPY \\SOMETHING TO \\%COMPUTERNAME% WHEREVER

GOTO :END

:OFFLINE

ECHO %COMPUTER% IS OFFLINE >> OFFLINELIST.TXT

:END

  • @echo off

set PCs= »C:\Users\administrator\Documents\SVComps.csv »

set Logs= »C:\Users\administrator\Documents\Copy.log »

set Source= »C:\Users\administrator\Documents\test »

set Target=c$\DBFolder\

for /F %%a in (PCs.txt) do (

echo Processing %%a

ping %%a | find /i « Reply from » > nul

if ErrorLevel 1 (

echo %%a – Computer offline >> « %Logs% »

) else (

echo %%a – Computer online – Trying to copy >> « %Logs% »

xcopy /y /c /d %Source% \\%%a\%Target% 1>>%Logs% 2>>%Logs%

)

)


Script d’attente

@echo « Internet Explorer va se fermer dans 30s » & choice /t:o,305>nul

tskill iexplore

xcopy /c /y mms.cfg %WINDIR%\SysWOW64\Editeur\ApplicationName\

msiexec /i Application.msi /quiet /norestart /log C:\WIndows\Temp\app.log


REM === Add SNMP Windows Feature and Components ===

PowerShell

Add-WindowsFeature RSAT-SNMP,SNMP-Service,SNMP-WMI-Provider

REM === Switch to Command Prompt to use REG ADD command for configure SNMP Community String ===

CMD

REM == Configure SNMP Community Sting for SIN DC ==

REG Query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities

REG Delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities /va /f

REG Add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities /v « Your_Security_SNMP_String » /t REG_DWORD /d 4 /f

REG Query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration

REG Delete « HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\public » /f

REG Add « HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\Your_Security_SNMP_String » /f

REG Add « HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\Your_Security_SNMP_String » /v « Traps » /t REG_SZ /d « SNMPTrapServer_HostNameOrIP » /f

REG Query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers

REG Delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\PermittedManagers /va /f

Future article on how to create a real good proxypac

$
0
0

Example of a non optimized proxy pac but functionnal;

/*==================================================================

PROXY AUTO CONFIGURATION FILE

====================================================================

/*==================================================================

PARAMETRAGE

==================================================================*/

/*— definition des adresses IP et du port des serveurs proxy —*/

PROXY0 = « principalProxy.domain.com:8080 »;
PROXYter = « proxyter.domain.com:8080 »;
PROXY2 = « proxy2.domain.com:8080 »;
PROXY_bis = « 192.168.3.3:5555 »;
PROXY_Autre = « 192.168.2.2 »;
PROXY_bis = « 192.168.1.1 »;
PROXY_BC = « 192.168.3.3 »;
Proxy1 = « mydomain.fr:8080″;

/*— liste des adresses IP des serveurs intranet (accès en direct) —*/

var NB_IP = 2;
var INDEX_IP = 0;
LISTE_IP = new Array(NB_IP);

LISTE_IP[0]= »144.211.1.2″;
LISTE_IP[1]= »http://otherExample.net »;

/*— Cas des adresses DNS de l’intranet (accès en direct sauf exception ci-dessous) —*/

DNS_1 = « .intra.domain.com »;
DNS_2 = « .login.domain.net »;

/*—  Office 365 domains —*/

liste_domaine = new Array;
liste_domaine[« autodiscover.labanquepostale.fr »] = Proxy1;
…………….

/*==================================================================

SCRIPT

==================================================================*/
function FindProxyForURL(url, host) {
// Connexions directes pour les adresses IP locales
INDEX_IP = 0;
for (var i = 0; i < NB_IP; i++) {
if (url.indexOf(LISTE_IP[i]) >= 0) {
INDEX_IP = 1;
}
}
if(dnsDomainIs(host, DNS_2)){
return « PROXY  » + PROXY0 + « ; DIRECT »;
}

….

if ((url.substring(0, 45) == « http://bbbbbb ») ||
(url.substring(0, 41) == « http://www.aaaaaa »)) {
return « PROXY  » + PROXYter;
} else {
if ((url.substring(0, 39) == « adresse ») ||
(url.substring(0, 36) == « adresse ») ||

{
return « PROXY  » + PROXY2;
} else {
if ((dnsDomainIs(host, DNS_1)) ||
(INDEX_IP == 1) ||
(url.substring(0, 30) == « http://www.yyyyyyy ») ||
(url.substring(0, 31) == « https://www.tttttt ») ||
(localHostOrDomainIs(host, « serv3. »)) ||
(localHostOrDomainIs(host, « serv2. »)) ||
(localHostOrDomainIs(host, « serv1. »))) {
return « DIRECT »;
} else {
// Domains
for (urlIndex in liste_domaine) {
if (dnsDomainIs(host, urlIndex)) {
if (liste_domaine[urlIndex] == « DIRECT ») {
return « DIRECT »;
} else {
return « PROXY  » + liste_domaine[urlIndex];
}
}
}

// if HTTP => primary
if (url.substring(0, 5) == « http: ») {
return « PROXY  » + PROXY0;

// If HTTPS => primary
} else if (url.substring(0, 6) == « https: ») {
return « PROXY  » + PROXY0;
// Si protocole FTP => proxy primaire
} else if (url.substring(0, 4) == « ftp: ») {
return « PROXY  » + PROXY0;
// Si protocole NNTP => proxy primaire
} else if (url.substring(0, 5) == « nntp: ») {
return « PROXY  » + PROXY0;
}
}
}
}
}


Alerte Patch VMware

Msa : création de compte de service managé en PowerShell pour une base MS SQL

$
0
0
  • •Créer le compte de services en exécutant la commande suivante : 

    New-AdServiceAccount <Nom Du Compte> -AccountPassword (ConvertTo-SecureString –AsPlainText “<mot de passe>” –Force) –Enabled $true –Path “CN=Managed Service Accounts,DC=<Domain Name>,DC=COM”

    •Associer le compte de service à l’ordinateur client en exécutant la commande suivante :

     

    Add-ADComputerServiceAccount –Identity <Nom Ordinateur> –ServiceAccount <Nom du compte>

    •Installer le compte de service sur l’ordinateur client (cette commande soit être exécutée sur le poste qui utilisera le compte de service géré)

     

    Install-ADServiceAccount –Identity <Nom du compte>

    •Vérifier que le compte de service à été bien affecté au compte de la machine au niveau Active Directory en explorant les propriétés de l’objet ordinateur en question avec ADSI Edit et en cherchant l’attribut msDS-HostServiceAccount

     

     

     

    Procédure de mise en place des comptes MSA SQL 2008 R2 2012

    Introduction aux comptes managés

     

     

    1 Commandes en Powershell sur un DC (Valable pour AD 2008 – societe uniquement):

    windir\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command import-module ActiveDirectory

    New-ADServiceAccount -Name ServerName_SQLAdH -Description « Description – SQL Server Active Directory Helper » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLAgn -Description « Description – SQL Server Agent » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLAna -Description « Description – SQL Server Analysis Services » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLBrw -Description « Description – SQL Server Browser » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLIns -Description « Description – Service instance SQL Server » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLInt -Description « Description – SQL Server Integration Services » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLRep -Description « Description – SQL Server Report Server » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLTxt -Description « Description – SQL Server FullText Search » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLVss -Description « Description – SQL Server VSS Writer » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLDrc -Description « Description – SQL Server Distributed Replay Controller » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLDc -Description « Description – SQL Server Distributed Replay Client » -Enabled $true

     

    Commandes en Powershell sur un DC (Valable pour AD 2012 – fourn uniquement):

    windir\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command import-module ActiveDirectory

    New-ADServiceAccount -Name ServerName_SQLAdH -RestrictToSingleComputer -Description « Description – SQL Server Active Directory Helper » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLAgn -RestrictToSingleComputer -Description « Description – SQL Server Agent » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLAna -RestrictToSingleComputer -Description « Description – SQL Server Analysis Services » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLBrw -RestrictToSingleComputer -Description « Description – SQL Server Browser » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLIns -RestrictToSingleComputer -Description « Description – Service instance SQL Server » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLInt -RestrictToSingleComputer -Description « Description – SQL Server Integration Services » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLRep -RestrictToSingleComputer -Description « Description – SQL Server Report Server » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLTxt -RestrictToSingleComputer -Description « Description – SQL Server FullText Search » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLVss -RestrictToSingleComputer -Description « Description – SQL Server VSS Writer » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLDrc -RestrictToSingleComputer -Description « Description – SQL Server Distributed Replay Controller » -Enabled $true

    New-ADServiceAccount -Name ServerName_SQLDc -RestrictToSingleComputer -Description « Description – SQL Server Distributed Replay Client » -Enabled $true

     

    2 Puis les commandes suivantes sont communes à AD 2008 et AD 2012:

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLAdH

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLAgn

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLAna

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLBrw

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLIns

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLInt

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLRep

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLTxt

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLVss

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLDrc

    Add-ADComputerServiceAccount -Identity ServerName -ServiceAccount ServiceName_SQLDc

     

    3 Sur le serveur SQL

    DISM /online /enable-feature /all /featurename=ActiveDirectory-PowerShell

    Commandes en Powershell :

    Install-ADServiceAccount -Identity Name_SQLAdH

    Install-ADServiceAccount -Identity Name_SQLAgn

    Install-ADServiceAccount -Identity Name_SQLAna

    Install-ADServiceAccount -Identity Name_SQLBrw

    Install-ADServiceAccount -Identity Name_SQLIns

    Install-ADServiceAccount -Identity Name_SQLInt

    Install-ADServiceAccount -Identity Name_SQLRep

    Install-ADServiceAccount -Identity Name_SQLTxt

    Install-ADServiceAccount -Identity Name_SQLVss

    Install-ADServiceAccount -Identity Name_SQLDrc

    Install-ADServiceAccount -Identity Name_SQLDc

Active Directory : test et cmdlet utiles

$
0
0

Vérification de la cohérence

Repadmin /kcc ServerName

repadmin /syncall

repadmin /syncall/Aep ServerName

Pour la forêt

Repadmin /replsum

Au niveau des DCs

Repadmin /showrepl

Repadmin /removelingeringobjects ServerName /advisory_mode

  • Réplication du SYSVOL :

SONAR – Ultrasound – Dfsrmon – dfsrmgmt

  • Diagnostique général :

dcdiag /e

  • full test :

dcdiag /c

  • Autre test :

DCDIAG /Test:KCCEvent

repadmin /failcache site:<nomsite>

repadmin /bind <DCname>

repadmin /syncall

 

Topologie

repadmin /kcc

repadmin /prp view <dc1> <dc2>

 

  • Check to see which domain controllers that the Directory Service Agent thinks are holding the roles

DCDIAG /Test:KnowsofRoleHolders /v

  • Check the integrity of a domain controller’s machine account

DCDIAG /Test:MachineAccount

  •  Au niveau des dc:

Repadmin /removelingeringobjects ServerName/advisory_mode

 

  • Rôles FSMO :

Netdom query fsmo

 

Get-ADDomain | Select-Object InfrastructureMaster, RIDMaster, PDCEmulator

Get-ADForest | Select-Object DomainNamingMaster, SchemaMaster

Get-ADDomainController -Filter * | Select-Object Name, Domain, Forest, OperationMasterRoles | Where-Object {$_.OperationMasterRoles} | Ft -AutoSize

  • Test du canal sécurisé

Nltest /server:<ComputerName> /sc_query:<DomainName>

 

  • Réinit compte ordinateur

Dsmod computer <ComputerDN> -reset

Netdom reset <ComputerName> /domain <DomainName> /User0 <UserUPN> /Password0

 

DIVERS

# Base NTDS.dit/performance/service : BPA

# Sauvegarde de l’état du système : repadmin /showbackup

Get-WmiObject -class « Win32_TSGeneralSetting » -Namespace root\cimv2\terminalservices -Filter « TerminalName=’RDP-tcp’”

 

# Identify the ISTG covering each site by running this command : repadmin /istg

 

# Quick test :

DCDIAG /Test:KnowsOfRoleHolders

 

# which domain controllers that the Directory Service Agent thinks are holding the roles

DCDIAG /Test:KnowsofRoleHolders /v

 

# DC’s machine account integrity

DCDIAG /Test:MachineAccount

 

# Naming Context Security Descriptors Test

# If security descriptors are invalid, then replication may fail

DCDIAG /Test:NCSecDesc

 

# NetLogons

# see that replication is not failing because of insufficient logon privileges

DCDIAG /Test:NetLogons

 

# The Objects Replicated Test

#used to confirm that machine accounts have replicated across all of your domain controllers, but it can also be used to check to see if other types of objects have replicated as well.

#If the object that you are looking up is something other than a machine account, then you will also have to know the object’s naming context. The syntax for this test looks something like this:

DCDiag /Test:ObjectsReplicated /ObjectDN:<object’s distinguished name> /N:<object’s naming context>

 

#The Outbound Secure Channels Test

#Secure channel is an authenticated remote procedure call (RPC) connection between two machines in a domain with an established security context used for signing and encrypting RPC packets

DCDIAG /Test:OutboundSecureChannels /TestDomain:<yourdomain>

 

#will only check the domain controllers within the current site. You can force the test to check external sites by adding the /NoRestriction switch to the test.

 

netsh http show sslcert

 

nltest /SC_QUERY:domainname

nltest /SC_reset:domainname /server:dcname

netdom reset hostname /domain:domainname /server:dcname

Réplication DNS

dnslint /ad <ip du dc> /s <ip du dns>

dcdiag /test:DNS -e

–        Base NTDS.dit/performance/service : BPA

 

/FixMachineAccount –> resets the accounts various flags

If that does not correct the problem, then you can always try recreating the machine account –> /RecreateMachineAccount

 

# Naming Context Security Descriptors Test

# If security descriptors are invalid, then replication may fail

DCDIAG /Test:NCSecDesc

 

#NetLogons

# It checks to see that replication is not failing because of insufficient logon privileges

DCDIAG /Test:NetLogons

 

#The Objects Replicated Test

#used to confirm that machine accounts have replicated across all of your domain controllers, but it can also be used to check to see if other types of objects have replicated as well.

#If the object that you are looking up is something other than a machine account, then you will also have to know the object’s naming context

DCDiag /Test:ObjectsReplicated /ObjectDN:<object’s distinguished name> /N:<object’s naming context>

 

# The Outbound Secure Channels Test

# Secure channel is an authenticated remote procedure call (RPC) connection between two machines in a domain with an established security context used for signing and encrypting RPC packets

DCDIAG /Test:OutboundSecureChannels /TestDomain:<yourdomain>

# will only check the domain controllers within the current site. You can force the test to check external sites by adding the /NoRestriction switch to the test.

 

netsh http show sslcert

 

nltest /SC_QUERY:domainname

nltest /SC_reset:domainname /server:dcname

netdom reset hostname /domain:domainname /server:dcname

Reinit SPN : setspn -R hostname

Requête users AD

$users = Get-ADUser -Filter {enabled -eq $True} -SearchBase « OU=utilisateurs,DC=f1nom0a,DC=local »

$users.Count

 

LOCK

get-aduser <UserName> -Properties badpwdcount, lockedout

 

Forcer une réplication non-autoritaire

–        Avec ADSIEDIT.msc, modifier la valeur du distinguished name (DN) :

CN=SYSVOL Subscription,CN=Domain System Volume,CN=DFSR-LocalSettings,CN=<servername>,OU=Domain Controllers,DC=<domain> msDFSR-Enabled=FALSE

–        Forcer une réplication Active Directory, via la commande suivante :

repadmin /syncall /e

–        Vérifier la réplication avec la commande suivante :

DFSRDIAG POLLAD

(Si vous voyez l’évènement ID 4114 dans les event DFRS, cela veut dire que le réplication est terminée)

–        Avec ADSIEDIT, modifier la valeur du distinguished name (DN) :

CN=SYSVOL Subscription,CN=Domain System Volume,CN=DFSR-LocalSettings,CN=<servername>,OU=Domain Controllers,DC=<domain>

msDFSR-Enabled=TRUE

–        Si vous voyez l’évènement ID 4614 et 4604 dans les event DFRS, cela veut dire que la réplication en D2 est initialisée

Repadmin /replicate Server01 Server02 « dc=DomainName,dc=xxx »

 

FSMO roles Transfer

Transfering all roles

Move-ADDirectoryServerOperationMasterRole -Identity « Target-DC » -OperationMasterRole SchemaMaster,RIDMaster,InfrastructureMaster,DomainNamingMaster,PDCEmulator

 

Seizing all roles

Move-ADDirectoryServerOperationMasterRole -Identity « Target-DC » -OperationMasterRole SchemaMaster,RIDMaster,InfrastructureMaster,DomainNamingMaster,PDCEmulator -Force

 

to transfer all roles to another Domain Controller:

Move-ADDirectoryServerOperationMasterRole -Identity « DC1 » -OperationMasterRole SchemaMaster,RIDMaster,InfrastructureMaster,DomainNamingMaster,PDCEmulator

 

to seize all roles from a permanently offline Domain Controller:

Move-ADDirectoryServerOperationMasterRole -Identity « DC1 » -OperationMasterRole SchemaMaster,RIDMaster,InfrastructureMaster,DomainNamingMaster,PDCEmulator -Force

 

Instead of typing the Names of the operations master roles, Numbers may also be specified.

Here is table:

Role Name

Number

PDCEmulator

0

RIDMaster

1

InfrastructureMaster

2

SchemaMaster

3

DomainNamingMaster

4

TOOLS

DSAACLS Visualise et modifie les ACL sur les objets AD
DCAStats Permet de comparer deux arborescences AD et de fournir des statistique
DCDIAG Vérifie la santé d’un DC
DNSCMD Vérifie les enregistrements DNS dynamiques, liste les zones DNS
KLIST Vérifie de bout en bout le réseau et les fonctions de services distribuées
NETDIAG Affiche la topologie de réplication, force la réplication et le recalcul du KCC
REPLMon Teste les relations d’approbation et l’état de réplication d’un DC. Permet également de tester et réinitialiser le canal sécurisé du service NetLogon établi entre le client et le DC NLTest

Add ADMX file for Windows Server 2016 hardening

$
0
0

Pour disposer des nouvelles options proposées par Windows Server 2016 ainsi que des options de sécurisation non présentes par défaut, des ADMX devront être rajoutés :

Il faut copier les fichiers admx  (fichiers de configuration) dans le repertoire ci dessous :

C:\Windows\PolicyDefinitions

et les fichiers ADML (fichiers de langues) dans le sous répertoires qui conviens :

C:\Windows\PolicyDefinitions\EN-us

Idem dans le sysvol :

\\DomainName\SYSVOL\DomainName\Policies\…

 

Ensuite lancer GPMC.msc pour ensuite lancer un gpedit.msc sur une GPO de hardening par exemple.

Développer le nœud Stratégie puis modèles d’administration

 

Autres ADMX :

How to clean a cloned Domain Controller for test lab

$
0
0
 Ce Document a pour but de décrire les décrire les opérations à effectuer en cas de clonage d’un controleur de domaine Active Directory en vue de faire une bulle de test

 

       I.            Introduction

Après avoir fait le clone d’un contrôleur de domaine pour une bulle dans VMware, il faut nettoyer l’annuaire AD qui ne comporte plus qu’un seul serveur, celui que l’on vient de cloner.

Cet article explique comment nettoyer l’annuaire.

 

   II.             Choix du DC à cloner

Choisir le DC contenant le plus de rôles FSMO, ou celui qui impactera le moins la procution lors du clonage à chaud qui fera « freezer » la VM quelques instant.

 

III.            FSMO

Netdom query fsmo

 

Faire une premier fois la commande afin de vérifier les roles FSMO présent sur votre VM, ensuite il faudra passer les commandes si dessous, mais uniquement celles dont il faut récupérer les roles FSMO.

 

Normalement vous devriez avoir à passer celle ci :

Move-ADDirectoryServerOperationMasterRole -Identity "Target-DC" -OperationMasterRole PDCEmulator -Force

Move-ADDirectoryServerOperationMasterRole -Identity "Target-DC" -OperationMasterRole RIDMaster -Force

Move-ADDirectoryServerOperationMasterRole -Identity "Target-DC" -OperationMasterRole DomainNamingMaster -Force

 

Si besoin voici les autres commandes pour récupérer les autres rôles FSMO (non listé ci-dessus car normalement déjà sur le DC cloné)

 

Move-ADDirectoryServerOperationMasterRole -Identity "Target-DC" -OperationMasterRole SchemaMaster -Force

Move-ADDirectoryServerOperationMasterRole -Identity "Target-DC" -OperationMasterRole InfrastructureMaster -Force

 

Lancer de nouveau la commande ci dessous pour verifier.

 

Netdom query fsmo

 

IV.            NTDSutil : meta data clean up

Lancer une invite de commande et saisir les commandes ci dessous pour chacun des DCs non présents dans la bulle (donc x serveurs et x site à supprimer)

Connection

NTDSUTIL

Metadata cleanup

connections

connect to server <ServerName>

Q

Suppression du 1er serveur

select operation target

list domains

select domain <number>

list site

select site <number>

list servers in site

select server <number>

Quit

 

remove selected server

quit

 

 

Confirmer la suppression

  1. Recommencer pour tous les autres serveurs non compris dans la bulle

 

 

  1. Recommencer en supprimant cette fois le site, donc sans préciser de serveur

 

    V.            Nettoyage du DNS

 

Suppression sites dans Sites et Services AD et des autres serveurs.

Avoir les droits suffisants pour le faire (entre admin par exemple)

 

Suppression des enregistrements DNS (sites, servers DC de tous les enregistrements SRV (ldap, kerberos, gc, kpasswd)

 

Dans _msdcs_DomainName.local

Suppression des serveurs de noms

Clic droit sur la zone DNS et choisir « propriété »

Aller dans l’onglet « Servers de Noms »

 

Sélectionner les serveurs

Nettoyer les données DNS obsolètes

Clic droit sur le serveur DNS dans le gestionnaire DNS

Puis choisir l’option « Nettoyer… »

Viewing all 187 articles
Browse latest View live