add script
This commit is contained in:
359
Active Directory/Active Directory Health Check/ADHealthCheck.ps1
Normal file
359
Active Directory/Active Directory Health Check/ADHealthCheck.ps1
Normal file
@@ -0,0 +1,359 @@
|
|||||||
|
<#PSScriptInfo
|
||||||
|
.VERSION 1.2
|
||||||
|
.GUID
|
||||||
|
.AUTHOR Hubert Cornet
|
||||||
|
.COMPANYNAME
|
||||||
|
.COPYRIGHT
|
||||||
|
.TAGS
|
||||||
|
.LICENSEURI
|
||||||
|
.PROJECTURI
|
||||||
|
.ICONURI
|
||||||
|
.EXTERNALMODULEDEPENDENCIES
|
||||||
|
.REQUIREDSCRIPTS
|
||||||
|
.EXTERNALSCRIPTDEPENDENCIES
|
||||||
|
.RELEASENOTES h
|
||||||
|
.PRIVATEDATA
|
||||||
|
#>
|
||||||
|
|
||||||
|
<#
|
||||||
|
.DESCRIPTION
|
||||||
|
Date: 18/10/2023
|
||||||
|
Active Directory Health Status Check
|
||||||
|
Satus: Ping,Netlogon,NTDS,DNS,DCdiag Test(Replication,sysvol,Services)
|
||||||
|
#>
|
||||||
|
|
||||||
|
###############################Paramters####################################
|
||||||
|
param (
|
||||||
|
[string]$Smtphost = $(Read-Host "Entrer l'addresse du serveur SMTP : "),
|
||||||
|
[string]$from = $(Read-Host "Entrer l'adresse mail de l'expéditeur : "),
|
||||||
|
[String[]]$MailReport = $(Read-Host "Entrer l'adresse mail du ou des destinataire(s) (séparés par une virgule) pour recevoir le rapport"),
|
||||||
|
$timeout = "120"
|
||||||
|
)
|
||||||
|
|
||||||
|
###########################Define Variables##################################
|
||||||
|
$MailReport = $MailReport -split ','
|
||||||
|
$Report = ".\AD-Report.htm"
|
||||||
|
|
||||||
|
If ((test-path $Report) -like $False) {
|
||||||
|
new-item $Report -type File
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################Get ALL DC Servers#######################
|
||||||
|
$GetForest = [system.directoryservices.activedirectory.Forest]::GetCurrentForest()
|
||||||
|
$DCServers = $getForest.domains | ForEach-Object {$_.DomainControllers} | ForEach-Object {$_.Name}
|
||||||
|
|
||||||
|
###############################HTml Report Content############################
|
||||||
|
Clear-Content $Report
|
||||||
|
|
||||||
|
Add-Content $Report "<html>"
|
||||||
|
Add-Content $Report " <head>"
|
||||||
|
Add-Content $Report " <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"
|
||||||
|
Add-Content $Report ' <title> Rapport Status Active Directory </title>'
|
||||||
|
Add-Content $Report ' <STYLE TYPE="text/css">'
|
||||||
|
Add-Content $Report " <!--"
|
||||||
|
Add-Content $Report " td {"
|
||||||
|
Add-Content $Report " font-family: Tahoma;"
|
||||||
|
Add-Content $Report " font-size: 11px;"
|
||||||
|
Add-Content $Report " border-top: 1px solid #999999;"
|
||||||
|
Add-Content $Report " border-right: 1px solid #999999;"
|
||||||
|
Add-Content $Report " border-bottom: 1px solid #999999;"
|
||||||
|
Add-Content $Report " border-left: 1px solid #999999;"
|
||||||
|
Add-Content $Report " padding-top: 0px;"
|
||||||
|
Add-Content $Report " padding-right: 0px;"
|
||||||
|
Add-Content $Report " padding-bottom: 0px;"
|
||||||
|
Add-Content $Report " padding-left: 0px;"
|
||||||
|
Add-Content $Report " }"
|
||||||
|
Add-Content $Report " body {"
|
||||||
|
Add-Content $Report " margin-left: 5px;"
|
||||||
|
Add-Content $Report " margin-top: 5px;"
|
||||||
|
Add-Content $Report " margin-right: 0px;"
|
||||||
|
Add-Content $Report " margin-bottom: 10px;"
|
||||||
|
Add-Content $Report " }"
|
||||||
|
Add-Content $Report " table {"
|
||||||
|
Add-Content $Report " border: thin solid #000000;"
|
||||||
|
Add-Content $Report " }"
|
||||||
|
Add-Content $Report " -->"
|
||||||
|
Add-Content $Report " </style>"
|
||||||
|
Add-Content $Report " </head>"
|
||||||
|
Add-Content $Report " <body>"
|
||||||
|
Add-Content $Report " <table width='100%'>"
|
||||||
|
Add-Content $Report " <tr bgcolor='Lavender'>"
|
||||||
|
Add-Content $Report " <td colspan='7' height='25' align='center'>"
|
||||||
|
Add-Content $Report " <font face='tahoma' color='#003399' size='4'><strong> Active Directory Check Health </strong></font>"
|
||||||
|
Add-Content $Report " </td>"
|
||||||
|
Add-Content $Report " </tr>"
|
||||||
|
Add-Content $Report " </table>"
|
||||||
|
|
||||||
|
Add-Content $Report " <table width='100%'>"
|
||||||
|
Add-Content $Report " <tr bgcolor='IndianRed'>"
|
||||||
|
Add-Content $Report " <td width='5%' align='center'><B> Identite </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Status du ping </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Service Netlogon </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Service NTDS </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Status Service DNS </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Test Netlogons </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Test Replication </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Test Services </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Test Advertising </B></td>"
|
||||||
|
Add-Content $Report " <td width='10%' align='center'><B> Test Check FSMO </B></td>"
|
||||||
|
Add-Content $Report " </tr>"
|
||||||
|
|
||||||
|
################Ping Test################################################################
|
||||||
|
Foreach ($DC in $DCServers) {
|
||||||
|
$Identity = $DC
|
||||||
|
Add-Content $Report " <tr>"
|
||||||
|
|
||||||
|
If ( Test-Connection -ComputerName $DC -Count 1 -ErrorAction SilentlyContinue ) {
|
||||||
|
Write-Host $DC `t $DC `t Ping Success -ForegroundColor Green
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'GainsBoro' align=center><B> $Identity </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> OkK </B></td>"
|
||||||
|
|
||||||
|
##############Netlogon Service Status################
|
||||||
|
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "Netlogon" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
||||||
|
Wait-Job $serviceStatus -timeout $timeout
|
||||||
|
|
||||||
|
If ($serviceStatus.state -like "Running") {
|
||||||
|
Write-Host $DC `t Netlogon Service TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Netlogon </B></td>"
|
||||||
|
Stop-Job $serviceStatus
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$serviceStatus1 = Receive-job $serviceStatus
|
||||||
|
If ($serviceStatus1.status -eq "Running") {
|
||||||
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
||||||
|
|
||||||
|
$svcName = $serviceStatus1.name
|
||||||
|
$svcState = $serviceStatus1.status
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
||||||
|
|
||||||
|
$svcName = $serviceStatus1.name
|
||||||
|
$svcState = $serviceStatus1.status
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##############NTDS Service Status################
|
||||||
|
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "NTDS" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
||||||
|
Wait-Job $serviceStatus -timeout $timeout
|
||||||
|
|
||||||
|
If ($serviceStatus.state -like "Running") {
|
||||||
|
Write-Host $DC `t NTDS Service TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout NTDS </B></td>"
|
||||||
|
Stop-Job $serviceStatus
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$serviceStatus1 = Receive-job $serviceStatus
|
||||||
|
|
||||||
|
If ($serviceStatus1.status -eq "Running") {
|
||||||
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
||||||
|
|
||||||
|
$svcName = $serviceStatus1.name
|
||||||
|
$svcState = $serviceStatus1.status
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
||||||
|
|
||||||
|
$svcName = $serviceStatus1.name
|
||||||
|
$svcState = $serviceStatus1.status
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
##############DNS Service Status################
|
||||||
|
$serviceStatus = start-job -scriptblock {get-service -ComputerName $($args[0]) -Name "DNS" -ErrorAction SilentlyContinue} -ArgumentList $DC
|
||||||
|
|
||||||
|
Wait-Job $serviceStatus -timeout $timeout
|
||||||
|
|
||||||
|
If ($serviceStatus.state -like "Running") {
|
||||||
|
Write-Host $DC `t DNS Server Service TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout DNS </B></td>"
|
||||||
|
Stop-Job $serviceStatus
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$serviceStatus1 = Receive-job $serviceStatus
|
||||||
|
|
||||||
|
If ($serviceStatus1.status -eq "Running") {
|
||||||
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Green
|
||||||
|
|
||||||
|
$svcName = $serviceStatus1.name
|
||||||
|
$svcState = $serviceStatus1.status
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t $serviceStatus1.name `t $serviceStatus1.status -ForegroundColor Red
|
||||||
|
|
||||||
|
$svcName = $serviceStatus1.name
|
||||||
|
$svcState = $serviceStatus1.status
|
||||||
|
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> $svcState </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
####################Netlogons status##################
|
||||||
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
|
|
||||||
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
|
$sysvol = start-job -scriptblock {dcdiag /test:netlogons /s:$($args[0])} -ArgumentList $DC
|
||||||
|
|
||||||
|
Wait-Job $sysvol -timeout $timeout
|
||||||
|
|
||||||
|
If ($sysvol.state -like "Running") {
|
||||||
|
Write-Host $DC `t Netlogons Test TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Netlogons </B></td>"
|
||||||
|
Stop-Job $sysvol
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$sysvol1 = Receive-job $sysvol
|
||||||
|
|
||||||
|
If ($cmp::instr($sysvol1, "passed test NetLogons")) {
|
||||||
|
Write-Host $DC `t Netlogons Test passed -ForegroundColor Green
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Netlogons OK </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t Netlogons Test Failed -ForegroundColor Red
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Netlogons Echec </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
####################Replications status##################
|
||||||
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
|
|
||||||
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
|
$sysvol = start-job -scriptblock {dcdiag /test:Replications /s:$($args[0])} -ArgumentList $DC
|
||||||
|
|
||||||
|
Wait-Job $sysvol -timeout $timeout
|
||||||
|
If ($sysvol.state -like "Running") {
|
||||||
|
Write-Host $DC `t Replications Test TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Replications </B></td>"
|
||||||
|
Stop-Job $sysvol
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$sysvol1 = Receive-job $sysvol
|
||||||
|
|
||||||
|
If ($cmp::instr($sysvol1, "passed test Replications")) {
|
||||||
|
Write-Host $DC `t Replications Test passed -ForegroundColor Green
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Replications OK </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t Replications Test Failed -ForegroundColor Red
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Replications Echec </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
####################Services status##################
|
||||||
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
|
|
||||||
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
|
$sysvol = start-job -scriptblock {dcdiag /test:Services /s:$($args[0])} -ArgumentList $DC
|
||||||
|
|
||||||
|
Wait-Job $sysvol -timeout $timeout
|
||||||
|
|
||||||
|
If ($sysvol.state -like "Running") {
|
||||||
|
Write-Host $DC `t Services Test TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Services </B></td>"
|
||||||
|
Stop-Job $sysvol
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$sysvol1 = Receive-job $sysvol
|
||||||
|
|
||||||
|
If ($cmp::instr($sysvol1, "passed test Services")) {
|
||||||
|
Write-Host $DC `t Services Test passed -ForegroundColor Green
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Services OK</B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t Services Test Failed -ForegroundColor Red
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Services Echec </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
####################Advertising status##################
|
||||||
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
|
|
||||||
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
|
$sysvol = start-job -scriptblock {dcdiag /test:Advertising /s:$($args[0])} -ArgumentList $DC
|
||||||
|
|
||||||
|
Wait-Job $sysvol -timeout $timeout
|
||||||
|
|
||||||
|
If ($sysvol.state -like "Running") {
|
||||||
|
Write-Host $DC `t Advertising Test TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Advertising Timeout </B></td>"
|
||||||
|
Stop-Job $sysvol
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$sysvol1 = Receive-job $sysvol
|
||||||
|
|
||||||
|
If ($cmp::instr($sysvol1, "passed test Advertising")) {
|
||||||
|
Write-Host $DC `t Advertising Test passed -ForegroundColor Green
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B> Advertising OK </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t Advertising Test Failed -ForegroundColor Red
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Advertising Echec </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
####################FSMOCheck status##################
|
||||||
|
Add-Type -AssemblyName microsoft.visualbasic
|
||||||
|
|
||||||
|
$cmp = "microsoft.visualbasic.strings" -as [type]
|
||||||
|
$sysvol = start-job -scriptblock {dcdiag /test:FSMOCheck /s:$($args[0])} -ArgumentList $DC
|
||||||
|
|
||||||
|
Wait-Job $sysvol -timeout $timeout
|
||||||
|
|
||||||
|
If ($sysvol.state -like "Running") {
|
||||||
|
Write-Host $DC `t FSMOCheck Test TimeOut -ForegroundColor Yellow
|
||||||
|
Add-Content $Report " <td bgcolor= 'Yellow' align=center><B> Timeout Check FSMO </B></td>"
|
||||||
|
Stop-Job $sysvol
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$sysvol1 = Receive-job $sysvol
|
||||||
|
|
||||||
|
If ($cmp::instr($sysvol1, "passed test FsmoCheck")) {
|
||||||
|
Write-Host $DC `t FSMOCheck Test passed -ForegroundColor Green
|
||||||
|
Add-Content $Report " <td bgcolor= 'Aquamarine' align=center><B>Check FSMO OK </B></td>"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t FSMOCheck Test Failed -ForegroundColor Red
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Check FSMO Echec </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host $DC `t $DC `t Ping Fail -ForegroundColor Red
|
||||||
|
Add-Content $Report " <td bgcolor= 'GainsBoro' align=center> <B> $Identity </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
Add-Content $Report " <td bgcolor= 'Red' align=center><B> Ping Echec </B></td>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Add-Content $Report " </tr>"
|
||||||
|
|
||||||
|
############################################Close HTMl Tables###########################
|
||||||
|
Add-Content $Report " </table>"
|
||||||
|
Add-Content $Report " </body>"
|
||||||
|
Add-Content $Report "</html>"
|
||||||
|
|
||||||
|
|
||||||
|
#############################################Send Email#################################
|
||||||
|
If (($Smtphost) -and ($MailReport) -and ($From)) {
|
||||||
|
[string]$body = Get-Content $Report
|
||||||
|
Send-MailMessage -SmtpServer $Smtphost -From $From -To $MailReport -Subject "Active Directory Health Monitor" -Body $body -BodyAsHtml
|
||||||
|
}
|
||||||
|
|
@@ -1176,7 +1176,7 @@ Write-Host "Terminé !" -ForegroundColor White
|
|||||||
|
|
||||||
Write-Progress -Id 5 -Activity "Done" -completed
|
Write-Progress -Id 5 -Activity "Done" -completed
|
||||||
|
|
||||||
$tabarray = @("Tableau de bord", "Groupes", "Unites d Organisation", "Utilisateurs", "Groupe Police Objet", "Ordinateurs")
|
$tabarray = @("Tableau de bord", "Groupes", "Unites d'Organisation", "Utilisateurs", "Groupe Police Objet", "Ordinateurs")
|
||||||
|
|
||||||
Write-Host "Compilation du rapport ........................................................... " -ForegroundColor Green -NoNewline
|
Write-Host "Compilation du rapport ........................................................... " -ForegroundColor Green -NoNewline
|
||||||
|
|
||||||
|
11
Active Directory/README.md
Normal file
11
Active Directory/README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Active Directory
|
||||||
|
|
||||||
|
- Installer les fonctionnalités AD DS, créer une nouvelle forêt.
|
||||||
|
|
||||||
|
<a href="http://www.youtube.com/watch?v=2LEShLkbVvI" target="_blank"><img src="http://img.youtube.com/vi/2LEShLkbVvI/0.jpg"
|
||||||
|
alt="Configurer Active Directory en PowerShell" width="240" height="180" border="10" /></a>
|
||||||
|
|
||||||
|
- Importer des utilisateurs à partir d'un fichier CSV
|
||||||
|
|
||||||
|
<a href="https://www.youtube.com/watch?v=xyP5xpNH2qA" target="_blank"><img src="http://img.youtube.com/vi/xyP5xpNH2qA/0.jpg"
|
||||||
|
alt="Importer des utilisateurs AD par CSV" width="240" height="180" border="10" /></a>
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resetKrbTgtPassword xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<!-- FQDN Of The Mail Server Or Mail Relay -->
|
||||||
|
<smtpServer>REPLACE_WITH_MAIL_SERVER_FQDN</smtpServer>
|
||||||
|
|
||||||
|
<!-- SMTP Port To Use -->
|
||||||
|
<smtpPort>REPLACE_WITH_MAIL_SERVER_SMTP_PORT_NUMERIC_VALUE</smtpPort>
|
||||||
|
|
||||||
|
<!-- SSL FOR SMTP - TRUE OR FALSE -->
|
||||||
|
<useSSLForSMTP>TRUE_OR_FALSE</useSSLForSMTP>
|
||||||
|
|
||||||
|
<!-- SSL TYPE - EXPLICIT OR IMPLICIT, BUT ONLY WHEN useSSLForSMTP = TRUE -->
|
||||||
|
<sslType>IMPLICIT_OR_EXPLICIT</sslType>
|
||||||
|
|
||||||
|
<!-- SMTP Credentials To Use - UserName/Password -->
|
||||||
|
<smtpCredsUserName>LEAVE_EMPTY_OR_LEAVE_AS_IS_OR_REPLACE_WITH_USERNAME_IF_USED</smtpCredsUserName>
|
||||||
|
<smtpCredsPassword>LEAVE_EMPTY_OR_LEAVE_AS_IS_OR_REPLACE_WITH_PASSWORD_IF_USED</smtpCredsPassword>
|
||||||
|
|
||||||
|
<!-- Mail Subject To Use -->
|
||||||
|
<mailSubject>KrbTgt Password Reset Result</mailSubject>
|
||||||
|
|
||||||
|
<!-- The Priority Of The Message: Low, Normal, High -->
|
||||||
|
<mailPriority>High</mailPriority>
|
||||||
|
|
||||||
|
<!-- Mail Body To Use -->
|
||||||
|
<mailBody>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>KrbTgt_Password_Reset</title>
|
||||||
|
<style type="text/css">
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<B><P align="center" style="font-size: 24pt; font-family: Arial Narrow, sans-serif; color: red">!!! ATTENTION | FYI - ACTION REQUIRED !!!</P></B>
|
||||||
|
<hr size=2 width="95%" align=center>
|
||||||
|
<BR>
|
||||||
|
<P style="font-size: 12pt; font-family: Arial Narrow, sans-serif;">Hello,</P>
|
||||||
|
<BR>
|
||||||
|
<P style="font-size: 12pt; font-family: Arial Narrow, sans-serif;">Please review the attached log file.</P>
|
||||||
|
<BR>
|
||||||
|
<P style="font-size: 12pt; font-family: Arial Narrow, sans-serif;">Best regards</P>
|
||||||
|
</body>
|
||||||
|
</html></mailBody>
|
||||||
|
|
||||||
|
<!-- The SMTP Address Used In The FROM Field -->
|
||||||
|
<mailFromSender>sender_Mail_Address@company.com</mailFromSender>
|
||||||
|
|
||||||
|
<!-- The SMTP Address Used In The TO Field -->
|
||||||
|
<mailToRecipient>recipient_To_MailAddress@company.com</mailToRecipient>
|
||||||
|
|
||||||
|
<!-- The SMTP Address Used In The CC Field -->
|
||||||
|
<mailCcRecipients>
|
||||||
|
<!-- For Every Recipient To Be Added In The CC Add A New Line -->
|
||||||
|
<mailCcRecipient>recipient_Cc_MailAddress_1@company.com</mailCcRecipient>
|
||||||
|
<mailCcRecipient>recipient_Cc_MailAddress_2@company.com</mailCcRecipient>
|
||||||
|
</mailCcRecipients>
|
||||||
|
|
||||||
|
<!-- Enable/Disable SMIME signing and encryptionof emails: ON or OFF -->
|
||||||
|
<mailSign>OFF</mailSign>
|
||||||
|
<mailEncrypt>OFF</mailEncrypt>
|
||||||
|
|
||||||
|
<!-- Full path of Cpi.Net.SecureMail.dll -->
|
||||||
|
<!-- Dll Source Code: https://www.codeproject.com/Articles/41727/An-S-MIME-Library-for-Sending-Signed-and-Encrypted -->
|
||||||
|
<mailSignAndEncryptDllFile>REPLACE_WITH_FULL_FOLDER_PATH_TO_COMPILED_DLL_FILE\Cpi.Net.SecureMail.dll</mailSignAndEncryptDllFile>
|
||||||
|
|
||||||
|
<!-- Location Of Cert To Sign/Encrypt The Mail -->
|
||||||
|
<mailSignAndEncryptCertLocation>STORE_OR_PFX</mailSignAndEncryptCertLocation> <!-- Location Of Cert To Sign/Encrypt The Mail - Options Are: PFX or STORE -->
|
||||||
|
<mailEncryptCertLocation>STORE_OR_CER</mailEncryptCertLocation> <!-- Location Of Cert To Encrypt The Mail - Options Are: CER or STORE -->
|
||||||
|
|
||||||
|
<!-- Thumbprint Of Certificate To Sign/Encrypt Mail With - Only Used When Corresponding Value For Location Is STORE -->
|
||||||
|
<mailSignAndEncryptCertThumbprint>LEAVE_EMPTY_OR_LEAVE_AS_IS_OR_REPLACE_WITH_THUMBPRINT_IF_USED</mailSignAndEncryptCertThumbprint> <!-- Thumbprint Of Cert To Sign/Encrypt The Mail By Sender -->
|
||||||
|
<mailEncryptCertThumbprint>LEAVE_EMPTY_OR_LEAVE_AS_IS_OR_REPLACE_WITH_THUMBPRINT_IF_USED</mailEncryptCertThumbprint> <!-- Thumbprint Of Cert To Encrypt The Mail For Recipient -->
|
||||||
|
|
||||||
|
<!-- Full path of a .pfx/.cer certificate file used to sign/encrypt the email message - Only Used When Corresponding Value For Location Is PFX/CER -->
|
||||||
|
<mailSignAndEncryptCertPFXFile>REPLACE_WITH_FULL_FOLDER_PATH_TO_PFX_FILE\cert.pfx</mailSignAndEncryptCertPFXFile> <!-- PFX File Of Cert/Private Key To Sign/Encrypt The Mail By Sender -->
|
||||||
|
<mailEncryptCertCERFile>REPLACE_WITH_FULL_FOLDER_PATH_TO_CER_FILE\cert.cer</mailEncryptCertCERFile> <!-- CER File Of Cert To Encrypt The Mail For Recipient -->
|
||||||
|
|
||||||
|
<!-- The password for the .pfx certificate file - Only Used When Corresponding Value For Location Is PFX -->
|
||||||
|
<mailSignAndEncryptCertPFXPassword>LEAVE_EMPTY_OR_LEAVE_AS_IS_OR_REPLACE_WITH_PFX_PASSWORD_IF_USED</mailSignAndEncryptCertPFXPassword> <!-- Password Of PFX File Of Cert/Private Key To Sign/Encrypt The Mail By Sender -->
|
||||||
|
</resetKrbTgtPassword>
|
6
Active Directory/Templates/Import-AdGroups.csv
Normal file
6
Active Directory/Templates/Import-AdGroups.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Utilisateur;Commun;Commerce;Achats;Direction;Marketing;Technique
|
||||||
|
p.dupont;2;2;2;2;2;2
|
||||||
|
b.durand;2;;2;;2;2
|
||||||
|
d.bellier;2;1;2;;;
|
||||||
|
j.tartas;2;;;;1;2
|
||||||
|
b.canu;2;;;;1;2
|
|
6
Active Directory/Templates/Import-AdUsers.csv
Normal file
6
Active Directory/Templates/Import-AdUsers.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
firstname;lastname;username;email;streetaddress;city;state;department;password;telephone;jobtitle;company;ou
|
||||||
|
Paul;Dupont;p.dupont;p.dupont@hitea.fr;;Agen;;;Test123Test1;;;;OU=Utilisateurs,OU=Agen,DC=dom,DC=hitea,DC=fr
|
||||||
|
Bernard;Durand;b.durand;b.durand@hitea.fr;;Agen;;;Test123Test2;;;;OU=Utilisateurs,OU=Agen,DC=dom,DC=hitea,DC=fr
|
||||||
|
David;Bellier;d.bellier;d.bellier@hitea.fr;;Agen;;;Test123Test3;;;;OU=Utilisateurs,OU=Agen,DC=dom,DC=hitea,DC=fr
|
||||||
|
Joël;Tartas;j.tartas;j.tartas@hitea.fr;;Agen;;;Test123Test4;;;;OU=Utilisateurs,OU=Agen,DC=dom,DC=hitea,DC=fr
|
||||||
|
Benoît;Canu;b.canu;b.canu@hitea.fr;;Agen;;;Test123Test5;;;;OU=Utilisateurs,OU=Agen,DC=dom,DC=hitea,DC=fr
|
|
3
Active Directory/copier groupe ad/copier-groupe-ad.ps1
Normal file
3
Active Directory/copier groupe ad/copier-groupe-ad.ps1
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
Get-ADGroupMember "<GROUPE-DESTINATION>" | Get-ADUser | ForEach-Object {Add-ADGroupMember -Identity "<GROUPE-SOURCE>" -Members $_}
|
453
Ansible/ConfigureRemotingForAnsible.ps1
Normal file
453
Ansible/ConfigureRemotingForAnsible.ps1
Normal file
@@ -0,0 +1,453 @@
|
|||||||
|
#Requires -Version 3.0
|
||||||
|
|
||||||
|
# Configure a Windows host for remote management with Ansible
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
#
|
||||||
|
# This script checks the current WinRM (PS Remoting) configuration and makes
|
||||||
|
# the necessary changes to allow Ansible to connect, authenticate and
|
||||||
|
# execute PowerShell commands.
|
||||||
|
#
|
||||||
|
# All events are logged to the Windows EventLog, useful for unattended runs.
|
||||||
|
#
|
||||||
|
# Use option -Verbose in order to see the verbose output messages.
|
||||||
|
#
|
||||||
|
# Use option -CertValidityDays to specify how long this certificate is valid
|
||||||
|
# starting from today. So you would specify -CertValidityDays 3650 to get
|
||||||
|
# a 10-year valid certificate.
|
||||||
|
#
|
||||||
|
# Use option -ForceNewSSLCert if the system has been SysPreped and a new
|
||||||
|
# SSL Certificate must be forced on the WinRM Listener when re-running this
|
||||||
|
# script. This is necessary when a new SID and CN name is created.
|
||||||
|
#
|
||||||
|
# Use option -EnableCredSSP to enable CredSSP as an authentication option.
|
||||||
|
#
|
||||||
|
# Use option -DisableBasicAuth to disable basic authentication.
|
||||||
|
#
|
||||||
|
# Use option -SkipNetworkProfileCheck to skip the network profile check.
|
||||||
|
# Without specifying this the script will only run if the device's interfaces
|
||||||
|
# are in DOMAIN or PRIVATE zones. Provide this switch if you want to enable
|
||||||
|
# WinRM on a device with an interface in PUBLIC zone.
|
||||||
|
#
|
||||||
|
# Use option -SubjectName to specify the CN name of the certificate. This
|
||||||
|
# defaults to the system's hostname and generally should not be specified.
|
||||||
|
|
||||||
|
# Written by Trond Hindenes <trond@hindenes.com>
|
||||||
|
# Updated by Chris Church <cchurch@ansible.com>
|
||||||
|
# Updated by Michael Crilly <mike@autologic.cm>
|
||||||
|
# Updated by Anton Ouzounov <Anton.Ouzounov@careerbuilder.com>
|
||||||
|
# Updated by Nicolas Simond <contact@nicolas-simond.com>
|
||||||
|
# Updated by Dag Wieërs <dag@wieers.com>
|
||||||
|
# Updated by Jordan Borean <jborean93@gmail.com>
|
||||||
|
# Updated by Erwan Quélin <erwan.quelin@gmail.com>
|
||||||
|
# Updated by David Norman <david@dkn.email>
|
||||||
|
#
|
||||||
|
# Version 1.0 - 2014-07-06
|
||||||
|
# Version 1.1 - 2014-11-11
|
||||||
|
# Version 1.2 - 2015-05-15
|
||||||
|
# Version 1.3 - 2016-04-04
|
||||||
|
# Version 1.4 - 2017-01-05
|
||||||
|
# Version 1.5 - 2017-02-09
|
||||||
|
# Version 1.6 - 2017-04-18
|
||||||
|
# Version 1.7 - 2017-11-23
|
||||||
|
# Version 1.8 - 2018-02-23
|
||||||
|
# Version 1.9 - 2018-09-21
|
||||||
|
|
||||||
|
# Support -Verbose option
|
||||||
|
[CmdletBinding()]
|
||||||
|
|
||||||
|
Param (
|
||||||
|
[string]$SubjectName = $env:COMPUTERNAME,
|
||||||
|
[int]$CertValidityDays = 1095,
|
||||||
|
[switch]$SkipNetworkProfileCheck,
|
||||||
|
$CreateSelfSignedCert = $true,
|
||||||
|
[switch]$ForceNewSSLCert,
|
||||||
|
[switch]$GlobalHttpFirewallAccess,
|
||||||
|
[switch]$DisableBasicAuth = $false,
|
||||||
|
[switch]$EnableCredSSP
|
||||||
|
)
|
||||||
|
|
||||||
|
Function Write-Log
|
||||||
|
{
|
||||||
|
$Message = $args[0]
|
||||||
|
Write-EventLog -LogName Application -Source $EventSource -EntryType Information -EventId 1 -Message $Message
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Write-VerboseLog
|
||||||
|
{
|
||||||
|
$Message = $args[0]
|
||||||
|
Write-Verbose $Message
|
||||||
|
Write-Log $Message
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Write-HostLog
|
||||||
|
{
|
||||||
|
$Message = $args[0]
|
||||||
|
Write-Output $Message
|
||||||
|
Write-Log $Message
|
||||||
|
}
|
||||||
|
|
||||||
|
Function New-LegacySelfSignedCert
|
||||||
|
{
|
||||||
|
Param (
|
||||||
|
[string]$SubjectName,
|
||||||
|
[int]$ValidDays = 1095
|
||||||
|
)
|
||||||
|
|
||||||
|
$hostnonFQDN = $env:computerName
|
||||||
|
$hostFQDN = [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname
|
||||||
|
$SignatureAlgorithm = "SHA256"
|
||||||
|
|
||||||
|
$name = New-Object -COM "X509Enrollment.CX500DistinguishedName.1"
|
||||||
|
$name.Encode("CN=$SubjectName", 0)
|
||||||
|
|
||||||
|
$key = New-Object -COM "X509Enrollment.CX509PrivateKey.1"
|
||||||
|
$key.ProviderName = "Microsoft Enhanced RSA and AES Cryptographic Provider"
|
||||||
|
$key.KeySpec = 1
|
||||||
|
$key.Length = 4096
|
||||||
|
$key.SecurityDescriptor = "D:PAI(A;;0xd01f01ff;;;SY)(A;;0xd01f01ff;;;BA)(A;;0x80120089;;;NS)"
|
||||||
|
$key.MachineContext = 1
|
||||||
|
$key.Create()
|
||||||
|
|
||||||
|
$serverauthoid = New-Object -COM "X509Enrollment.CObjectId.1"
|
||||||
|
$serverauthoid.InitializeFromValue("1.3.6.1.5.5.7.3.1")
|
||||||
|
$ekuoids = New-Object -COM "X509Enrollment.CObjectIds.1"
|
||||||
|
$ekuoids.Add($serverauthoid)
|
||||||
|
$ekuext = New-Object -COM "X509Enrollment.CX509ExtensionEnhancedKeyUsage.1"
|
||||||
|
$ekuext.InitializeEncode($ekuoids)
|
||||||
|
|
||||||
|
$cert = New-Object -COM "X509Enrollment.CX509CertificateRequestCertificate.1"
|
||||||
|
$cert.InitializeFromPrivateKey(2, $key, "")
|
||||||
|
$cert.Subject = $name
|
||||||
|
$cert.Issuer = $cert.Subject
|
||||||
|
$cert.NotBefore = (Get-Date).AddDays(-1)
|
||||||
|
$cert.NotAfter = $cert.NotBefore.AddDays($ValidDays)
|
||||||
|
|
||||||
|
$SigOID = New-Object -ComObject X509Enrollment.CObjectId
|
||||||
|
$SigOID.InitializeFromValue(([Security.Cryptography.Oid]$SignatureAlgorithm).Value)
|
||||||
|
|
||||||
|
[string[]] $AlternativeName += $hostnonFQDN
|
||||||
|
$AlternativeName += $hostFQDN
|
||||||
|
$IAlternativeNames = New-Object -ComObject X509Enrollment.CAlternativeNames
|
||||||
|
|
||||||
|
foreach ($AN in $AlternativeName)
|
||||||
|
{
|
||||||
|
$AltName = New-Object -ComObject X509Enrollment.CAlternativeName
|
||||||
|
$AltName.InitializeFromString(0x3,$AN)
|
||||||
|
$IAlternativeNames.Add($AltName)
|
||||||
|
}
|
||||||
|
|
||||||
|
$SubjectAlternativeName = New-Object -ComObject X509Enrollment.CX509ExtensionAlternativeNames
|
||||||
|
$SubjectAlternativeName.InitializeEncode($IAlternativeNames)
|
||||||
|
|
||||||
|
[String[]]$KeyUsage = ("DigitalSignature", "KeyEncipherment")
|
||||||
|
$KeyUsageObj = New-Object -ComObject X509Enrollment.CX509ExtensionKeyUsage
|
||||||
|
$KeyUsageObj.InitializeEncode([int][Security.Cryptography.X509Certificates.X509KeyUsageFlags]($KeyUsage))
|
||||||
|
$KeyUsageObj.Critical = $true
|
||||||
|
|
||||||
|
$cert.X509Extensions.Add($KeyUsageObj)
|
||||||
|
$cert.X509Extensions.Add($ekuext)
|
||||||
|
$cert.SignatureInformation.HashAlgorithm = $SigOID
|
||||||
|
$CERT.X509Extensions.Add($SubjectAlternativeName)
|
||||||
|
$cert.Encode()
|
||||||
|
|
||||||
|
$enrollment = New-Object -COM "X509Enrollment.CX509Enrollment.1"
|
||||||
|
$enrollment.InitializeFromRequest($cert)
|
||||||
|
$certdata = $enrollment.CreateRequest(0)
|
||||||
|
$enrollment.InstallResponse(2, $certdata, 0, "")
|
||||||
|
|
||||||
|
# extract/return the thumbprint from the generated cert
|
||||||
|
$parsed_cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
|
||||||
|
$parsed_cert.Import([System.Text.Encoding]::UTF8.GetBytes($certdata))
|
||||||
|
|
||||||
|
return $parsed_cert.Thumbprint
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Enable-GlobalHttpFirewallAccess
|
||||||
|
{
|
||||||
|
Write-Verbose "Forcing global HTTP firewall access"
|
||||||
|
# this is a fairly naive implementation; could be more sophisticated about rule matching/collapsing
|
||||||
|
$fw = New-Object -ComObject HNetCfg.FWPolicy2
|
||||||
|
|
||||||
|
# try to find/enable the default rule first
|
||||||
|
$add_rule = $false
|
||||||
|
$matching_rules = $fw.Rules | Where-Object { $_.Name -eq "Windows Remote Management (HTTP-In)" }
|
||||||
|
$rule = $null
|
||||||
|
If ($matching_rules) {
|
||||||
|
If ($matching_rules -isnot [Array]) {
|
||||||
|
Write-Verbose "Editing existing single HTTP firewall rule"
|
||||||
|
$rule = $matching_rules
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
# try to find one with the All or Public profile first
|
||||||
|
Write-Verbose "Found multiple existing HTTP firewall rules..."
|
||||||
|
$rule = $matching_rules | ForEach-Object { $_.Profiles -band 4 }[0]
|
||||||
|
|
||||||
|
If (-not $rule -or $rule -is [Array]) {
|
||||||
|
Write-Verbose "Editing an arbitrary single HTTP firewall rule (multiple existed)"
|
||||||
|
# oh well, just pick the first one
|
||||||
|
$rule = $matching_rules[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
If (-not $rule) {
|
||||||
|
Write-Verbose "Creating a new HTTP firewall rule"
|
||||||
|
$rule = New-Object -ComObject HNetCfg.FWRule
|
||||||
|
$rule.Name = "Windows Remote Management (HTTP-In)"
|
||||||
|
$rule.Description = "Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]"
|
||||||
|
$add_rule = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
$rule.Profiles = 0x7FFFFFFF
|
||||||
|
$rule.Protocol = 6
|
||||||
|
$rule.LocalPorts = 5985
|
||||||
|
$rule.RemotePorts = "*"
|
||||||
|
$rule.LocalAddresses = "*"
|
||||||
|
$rule.RemoteAddresses = "*"
|
||||||
|
$rule.Enabled = $true
|
||||||
|
$rule.Direction = 1
|
||||||
|
$rule.Action = 1
|
||||||
|
$rule.Grouping = "Windows Remote Management"
|
||||||
|
|
||||||
|
If ($add_rule) {
|
||||||
|
$fw.Rules.Add($rule)
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "HTTP firewall rule $($rule.Name) updated"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Setup error handling.
|
||||||
|
Trap
|
||||||
|
{
|
||||||
|
$_
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
# Get the ID and security principal of the current user account
|
||||||
|
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
|
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
|
||||||
|
|
||||||
|
# Get the security principal for the Administrator role
|
||||||
|
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
||||||
|
|
||||||
|
# Check to see if we are currently running "as Administrator"
|
||||||
|
if (-Not $myWindowsPrincipal.IsInRole($adminRole))
|
||||||
|
{
|
||||||
|
Write-Output "ERROR: You need elevated Administrator privileges in order to run this script."
|
||||||
|
Write-Output " Start Windows PowerShell by using the Run as Administrator option."
|
||||||
|
Exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
$EventSource = $MyInvocation.MyCommand.Name
|
||||||
|
If (-Not $EventSource)
|
||||||
|
{
|
||||||
|
$EventSource = "Powershell CLI"
|
||||||
|
}
|
||||||
|
|
||||||
|
If ([System.Diagnostics.EventLog]::Exists('Application') -eq $False -or [System.Diagnostics.EventLog]::SourceExists($EventSource) -eq $False)
|
||||||
|
{
|
||||||
|
New-EventLog -LogName Application -Source $EventSource
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect PowerShell version.
|
||||||
|
If ($PSVersionTable.PSVersion.Major -lt 3)
|
||||||
|
{
|
||||||
|
Write-Log "PowerShell version 3 or higher is required."
|
||||||
|
Throw "PowerShell version 3 or higher is required."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Find and start the WinRM service.
|
||||||
|
Write-Verbose "Verifying WinRM service."
|
||||||
|
If (!(Get-Service "WinRM"))
|
||||||
|
{
|
||||||
|
Write-Log "Unable to find the WinRM service."
|
||||||
|
Throw "Unable to find the WinRM service."
|
||||||
|
}
|
||||||
|
ElseIf ((Get-Service "WinRM").Status -ne "Running")
|
||||||
|
{
|
||||||
|
Write-Verbose "Setting WinRM service to start automatically on boot."
|
||||||
|
Set-Service -Name "WinRM" -StartupType Automatic
|
||||||
|
Write-Log "Set WinRM service to start automatically on boot."
|
||||||
|
Write-Verbose "Starting WinRM service."
|
||||||
|
Start-Service -Name "WinRM" -ErrorAction Stop
|
||||||
|
Write-Log "Started WinRM service."
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# WinRM should be running; check that we have a PS session config.
|
||||||
|
If (!(Get-PSSessionConfiguration -Verbose:$false) -or (!(Get-ChildItem WSMan:\localhost\Listener)))
|
||||||
|
{
|
||||||
|
If ($SkipNetworkProfileCheck) {
|
||||||
|
Write-Verbose "Enabling PS Remoting without checking Network profile."
|
||||||
|
Enable-PSRemoting -SkipNetworkProfileCheck -Force -ErrorAction Stop
|
||||||
|
Write-Log "Enabled PS Remoting without checking Network profile."
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Verbose "Enabling PS Remoting."
|
||||||
|
Enable-PSRemoting -Force -ErrorAction Stop
|
||||||
|
Write-Log "Enabled PS Remoting."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Write-Verbose "PS Remoting is already enabled."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure LocalAccountTokenFilterPolicy is set to 1
|
||||||
|
# https://github.com/ansible/ansible/issues/42978
|
||||||
|
$token_path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
|
||||||
|
$token_prop_name = "LocalAccountTokenFilterPolicy"
|
||||||
|
$token_key = Get-Item -Path $token_path
|
||||||
|
$token_value = $token_key.GetValue($token_prop_name, $null)
|
||||||
|
if ($token_value -ne 1) {
|
||||||
|
Write-Verbose "Setting LocalAccountTOkenFilterPolicy to 1"
|
||||||
|
if ($null -ne $token_value) {
|
||||||
|
Remove-ItemProperty -Path $token_path -Name $token_prop_name
|
||||||
|
}
|
||||||
|
New-ItemProperty -Path $token_path -Name $token_prop_name -Value 1 -PropertyType DWORD > $null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Make sure there is a SSL listener.
|
||||||
|
$listeners = Get-ChildItem WSMan:\localhost\Listener
|
||||||
|
If (!($listeners | Where-Object {$_.Keys -like "TRANSPORT=HTTPS"}))
|
||||||
|
{
|
||||||
|
# We cannot use New-SelfSignedCertificate on 2012R2 and earlier
|
||||||
|
$thumbprint = New-LegacySelfSignedCert -SubjectName $SubjectName -ValidDays $CertValidityDays
|
||||||
|
Write-HostLog "Self-signed SSL certificate generated; thumbprint: $thumbprint"
|
||||||
|
|
||||||
|
# Create the hashtables of settings to be used.
|
||||||
|
$valueset = @{
|
||||||
|
Hostname = $SubjectName
|
||||||
|
CertificateThumbprint = $thumbprint
|
||||||
|
}
|
||||||
|
|
||||||
|
$selectorset = @{
|
||||||
|
Transport = "HTTPS"
|
||||||
|
Address = "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Enabling SSL listener."
|
||||||
|
New-WSManInstance -ResourceURI 'winrm/config/Listener' -SelectorSet $selectorset -ValueSet $valueset
|
||||||
|
Write-Log "Enabled SSL listener."
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Write-Verbose "SSL listener is already active."
|
||||||
|
|
||||||
|
# Force a new SSL cert on Listener if the $ForceNewSSLCert
|
||||||
|
If ($ForceNewSSLCert)
|
||||||
|
{
|
||||||
|
|
||||||
|
# We cannot use New-SelfSignedCertificate on 2012R2 and earlier
|
||||||
|
$thumbprint = New-LegacySelfSignedCert -SubjectName $SubjectName -ValidDays $CertValidityDays
|
||||||
|
Write-HostLog "Self-signed SSL certificate generated; thumbprint: $thumbprint"
|
||||||
|
|
||||||
|
$valueset = @{
|
||||||
|
CertificateThumbprint = $thumbprint
|
||||||
|
Hostname = $SubjectName
|
||||||
|
}
|
||||||
|
|
||||||
|
# Delete the listener for SSL
|
||||||
|
$selectorset = @{
|
||||||
|
Address = "*"
|
||||||
|
Transport = "HTTPS"
|
||||||
|
}
|
||||||
|
Remove-WSManInstance -ResourceURI 'winrm/config/Listener' -SelectorSet $selectorset
|
||||||
|
|
||||||
|
# Add new Listener with new SSL cert
|
||||||
|
New-WSManInstance -ResourceURI 'winrm/config/Listener' -SelectorSet $selectorset -ValueSet $valueset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check for basic authentication.
|
||||||
|
$basicAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq "Basic"}
|
||||||
|
|
||||||
|
If ($DisableBasicAuth)
|
||||||
|
{
|
||||||
|
If (($basicAuthSetting.Value) -eq $true)
|
||||||
|
{
|
||||||
|
Write-Verbose "Disabling basic auth support."
|
||||||
|
Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $false
|
||||||
|
Write-Log "Disabled basic auth support."
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Write-Verbose "Basic auth is already disabled."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
If (($basicAuthSetting.Value) -eq $false)
|
||||||
|
{
|
||||||
|
Write-Verbose "Enabling basic auth support."
|
||||||
|
Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $true
|
||||||
|
Write-Log "Enabled basic auth support."
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Write-Verbose "Basic auth is already enabled."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# If EnableCredSSP if set to true
|
||||||
|
If ($EnableCredSSP)
|
||||||
|
{
|
||||||
|
# Check for CredSSP authentication
|
||||||
|
$credsspAuthSetting = Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq "CredSSP"}
|
||||||
|
If (($credsspAuthSetting.Value) -eq $false)
|
||||||
|
{
|
||||||
|
Write-Verbose "Enabling CredSSP auth support."
|
||||||
|
Enable-WSManCredSSP -role server -Force
|
||||||
|
Write-Log "Enabled CredSSP auth support."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($GlobalHttpFirewallAccess) {
|
||||||
|
Enable-GlobalHttpFirewallAccess
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure firewall to allow WinRM HTTPS connections.
|
||||||
|
$fwtest1 = netsh advfirewall firewall show rule name="Allow WinRM HTTPS"
|
||||||
|
$fwtest2 = netsh advfirewall firewall show rule name="Allow WinRM HTTPS" profile=any
|
||||||
|
If ($fwtest1.count -lt 5)
|
||||||
|
{
|
||||||
|
Write-Verbose "Adding firewall rule to allow WinRM HTTPS."
|
||||||
|
netsh advfirewall firewall add rule profile=any name="Allow WinRM HTTPS" dir=in localport=5986 protocol=TCP action=allow
|
||||||
|
Write-Log "Added firewall rule to allow WinRM HTTPS."
|
||||||
|
}
|
||||||
|
ElseIf (($fwtest1.count -ge 5) -and ($fwtest2.count -lt 5))
|
||||||
|
{
|
||||||
|
Write-Verbose "Updating firewall rule to allow WinRM HTTPS for any profile."
|
||||||
|
netsh advfirewall firewall set rule name="Allow WinRM HTTPS" new profile=any
|
||||||
|
Write-Log "Updated firewall rule to allow WinRM HTTPS for any profile."
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Write-Verbose "Firewall rule already exists to allow WinRM HTTPS."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test a remoting connection to localhost, which should work.
|
||||||
|
$httpResult = Invoke-Command -ComputerName "localhost" -ScriptBlock {$env:COMPUTERNAME} -ErrorVariable httpError -ErrorAction SilentlyContinue
|
||||||
|
$httpsOptions = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
|
||||||
|
|
||||||
|
$httpsResult = New-PSSession -UseSSL -ComputerName "localhost" -SessionOption $httpsOptions -ErrorVariable httpsError -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
If ($httpResult -and $httpsResult)
|
||||||
|
{
|
||||||
|
Write-Verbose "HTTP: Enabled | HTTPS: Enabled"
|
||||||
|
}
|
||||||
|
ElseIf ($httpsResult -and !$httpResult)
|
||||||
|
{
|
||||||
|
Write-Verbose "HTTP: Disabled | HTTPS: Enabled"
|
||||||
|
}
|
||||||
|
ElseIf ($httpResult -and !$httpsResult)
|
||||||
|
{
|
||||||
|
Write-Verbose "HTTP: Enabled | HTTPS: Disabled"
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Write-Log "Unable to establish an HTTP or HTTPS remoting session."
|
||||||
|
Throw "Unable to establish an HTTP or HTTPS remoting session."
|
||||||
|
}
|
||||||
|
Write-VerboseLog "PS Remoting has been successfully configured for Ansible."
|
8
Applications/AWS-CLI/Force-Update.ps1
Normal file
8
Applications/AWS-CLI/Force-Update.ps1
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html
|
||||||
|
$dlurl = "https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi"
|
||||||
|
$installerPath = Join-Path $env:TEMP (Split-Path $dlurl -Leaf)
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
Invoke-WebRequest $dlurl -OutFile $installerPath
|
||||||
|
Start-Process -FilePath msiexec -Args "/i $installerPath /passive" -Verb RunAs -Wait
|
||||||
|
Remove-Item $installerPath
|
||||||
|
$env:Path += ";C:\Program Files\Amazon\AWSCLI\bin"
|
28
Applications/Acrobat Reader DC/Force-Update.ps1
Normal file
28
Applications/Acrobat Reader DC/Force-Update.ps1
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# Silently install Adobe Reader DC with Microsoft Intune
|
||||||
|
# In order to distribute Adobe Acrobat Reader DC software you need to have
|
||||||
|
# a valid Adobe Acrobat Reader DC Distribution Agreement in place.
|
||||||
|
# See http://www.adobe.com/products/acrobat/distribute.html?readstep for details.
|
||||||
|
|
||||||
|
# Check if Software is installed already in registry.
|
||||||
|
$CheckADCReg = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | where {$_.DisplayName -like "Adobe Acrobat Reader DC*"}
|
||||||
|
# If Adobe Reader is not installed continue with script. If it's istalled already script will exit.
|
||||||
|
If ($CheckADCReg -eq $null) {
|
||||||
|
|
||||||
|
# Path for the temporary downloadfolder. Script will run as system so no issues here
|
||||||
|
$Installdir = "c:\temp\install_adobe"
|
||||||
|
New-Item -Path $Installdir -ItemType directory
|
||||||
|
|
||||||
|
# Download the installer from the Adobe website. Always check for new versions!!
|
||||||
|
$source = "ftp://ftp.adobe.com/pub/adobe/reader/win/AcrobatDC/1800920044/AcroRdrDC1800920044_fr_FR.exe"
|
||||||
|
$destination = "$Installdir\AcroRdrDC1800920044_fr_FR.exe"
|
||||||
|
Invoke-WebRequest $source -OutFile $destination
|
||||||
|
|
||||||
|
# Start the installation when download is finished
|
||||||
|
Start-Process -FilePath "$Installdir\AcroRdrDC1800920044_fr_FR.exe" -ArgumentList "/sAll /rs /rps /msi /norestart /quiet EULA_ACCEPT=YES"
|
||||||
|
|
||||||
|
# Wait for the installation to finish. Test the installation and time it yourself. I've set it to 240 seconds.
|
||||||
|
Start-Sleep -s 240
|
||||||
|
|
||||||
|
# Finish by cleaning up the download. I choose to leave c:\temp\ for future installations.
|
||||||
|
rm -Force $Installdir\AcroRdrDC*
|
||||||
|
}
|
236
Applications/Edge/Force-Update.ps1
Normal file
236
Applications/Edge/Force-Update.ps1
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Get-EdgeEnterpriseMSI
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Imports all device configurations in a folder to a specified tenant
|
||||||
|
|
||||||
|
.PARAMETER Channel
|
||||||
|
Channel to download, Valid Options are: Dev, Beta, Stable, EdgeUpdate, Policy.
|
||||||
|
|
||||||
|
.PARAMETER Platform
|
||||||
|
Platform to download, Valid Options are: Windows or MacOS, if using channel "Policy" this should be set to "any"
|
||||||
|
Defaults to Windows if not set.
|
||||||
|
|
||||||
|
.PARAMETER Architecture
|
||||||
|
Architecture to download, Valid Options are: x86, x64, arm64, if using channel "Policy" this should be set to "any"
|
||||||
|
Defaults to x64 if not set.
|
||||||
|
|
||||||
|
.PARAMETER Version
|
||||||
|
If set the script will try and download a specific version. If not set it will download the latest.
|
||||||
|
|
||||||
|
.PARAMETER Folder
|
||||||
|
Specifies the Download folder
|
||||||
|
|
||||||
|
.PARAMETER Force
|
||||||
|
Overwrites the file without asking.
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version: 1.2
|
||||||
|
Author: Mattias Benninge
|
||||||
|
Creation Date: 2020-07-01
|
||||||
|
|
||||||
|
Version history:
|
||||||
|
|
||||||
|
1.0 - Initial script development
|
||||||
|
1.1 - Fixes and improvements by @KarlGrindon
|
||||||
|
- Script now handles multiple files for e.g. MacOS Edge files
|
||||||
|
- Better error handling and formating
|
||||||
|
- URI Validation
|
||||||
|
1.2 - Better compability on servers (force TLS and remove dependency to IE)
|
||||||
|
|
||||||
|
|
||||||
|
https://docs.microsoft.com/en-us/mem/configmgr/apps/deploy-use/deploy-edge
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
|
||||||
|
Download the latest version for the Beta channel and overwrite any existing file
|
||||||
|
.\Get-EdgeEnterpriseMSI.ps1 -Channel Beta -Folder D:\SourceCode\PowerShell\Div -Force
|
||||||
|
|
||||||
|
#>
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $True, HelpMessage = 'Channel to download, Valid Options are: Dev, Beta, Stable, EdgeUpdate, Policy')]
|
||||||
|
[ValidateSet('Dev', 'Beta', 'Stable', 'EdgeUpdate', 'Policy')]
|
||||||
|
[string]$Channel = "Stable",
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $True, HelpMessage = 'Folder where the file will be downloaded')]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$Folder = "C:\temp",
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false, HelpMessage = 'Platform to download, Valid Options are: Windows or MacOS')]
|
||||||
|
[ValidateSet('Windows', 'MacOS', 'any')]
|
||||||
|
[string]$Platform = "Windows",
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false, HelpMessage = "Architecture to download, Valid Options are: x86, x64, arm64, any")]
|
||||||
|
[ValidateSet('x86', 'x64', 'arm64', 'any')]
|
||||||
|
[string]$Architecture = "x64",
|
||||||
|
|
||||||
|
[parameter(Mandatory = $false, HelpMessage = "Specifies which version to download")]
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[string]$ProductVersion,
|
||||||
|
|
||||||
|
[parameter(Mandatory = $false, HelpMessage = "Overwrites the file without asking")]
|
||||||
|
[Switch]$Force
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
$edgeEnterpriseMSIUri = 'https://edgeupdates.microsoft.com/api/products?view=enterprise'
|
||||||
|
|
||||||
|
# Validating parameters to reduce user errors
|
||||||
|
if ($Channel -eq "Policy" -and ($Architecture -ne "Any" -or $Platform -ne "Any")) {
|
||||||
|
Write-Warning ("Channel 'Policy' requested, but either 'Architecture' and/or 'Platform' is not set to 'Any'.
|
||||||
|
Setting Architecture and Platform to 'Any'")
|
||||||
|
|
||||||
|
$Architecture = "Any"
|
||||||
|
$Platform = "Any"
|
||||||
|
}
|
||||||
|
elseif ($Channel -ne "Policy" -and ($Architecture -eq "Any" -or $Platform -eq "Any")) {
|
||||||
|
throw "If Channel isn't set to policy, architecture and/or platform can't be set to 'Any'"
|
||||||
|
}
|
||||||
|
elseif ($Channel -eq "EdgeUpdate" -and ($Architecture -ne "x86" -or $Platform -eq "Windows")) {
|
||||||
|
Write-Warning ("Channel 'EdgeUpdate' requested, but either 'Architecture' is not set to x86 and/or 'Platform'
|
||||||
|
is not set to 'Windows'. Setting Architecture to 'x86' and Platform to 'Windows'")
|
||||||
|
|
||||||
|
$Architecture = "x86"
|
||||||
|
$Platform = "Windows"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Enabling connection over TLS for better compability on servers" -ForegroundColor Green
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
|
# Test if HTTP status code 200 is returned from URI
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest $edgeEnterpriseMSIUri -UseBasicParsing | Where-Object StatusCode -match 200 | Out-Null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Unable to get HTTP status code 200 from $edgeEnterpriseMSIUri. Does the URL still exist?"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Getting available files from $edgeEnterpriseMSIUri" -ForegroundColor Green
|
||||||
|
|
||||||
|
# Try to get JSON data from Microsoft
|
||||||
|
try {
|
||||||
|
$response = Invoke-WebRequest -Uri $edgeEnterpriseMSIUri -Method Get -ContentType "application/json" -UseBasicParsing -ErrorVariable InvokeWebRequestError
|
||||||
|
$jsonObj = ConvertFrom-Json $([String]::new($response.Content))
|
||||||
|
Write-Host "Succefully retrived data" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Could not get MSI data: $InvokeWebRequestError"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Alternative is to use Invoke-RestMethod to get a Json object directly
|
||||||
|
# $jsonObj = Invoke-RestMethod -Uri "https://edgeupdates.microsoft.com/api/products?view=enterprise" -UseBasicParsing
|
||||||
|
|
||||||
|
$selectedIndex = [array]::indexof($jsonObj.Product, "$Channel")
|
||||||
|
|
||||||
|
if (-not $ProductVersion) {
|
||||||
|
try {
|
||||||
|
Write-host "No version specified, getting the latest for $Channel" -ForegroundColor Green
|
||||||
|
$selectedVersion = (([Version[]](($jsonObj[$selectedIndex].Releases |
|
||||||
|
Where-Object { $_.Architecture -eq $Architecture -and $_.Platform -eq $Platform }).ProductVersion) |
|
||||||
|
Sort-Object -Descending)[0]).ToString(4)
|
||||||
|
|
||||||
|
Write-Host "Latest Version for channel $Channel is $selectedVersion`n" -ForegroundColor Green
|
||||||
|
$selectedObject = $jsonObj[$selectedIndex].Releases |
|
||||||
|
Where-Object { $_.Architecture -eq $Architecture -and $_.Platform -eq $Platform -and $_.ProductVersion -eq $selectedVersion }
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Unable to get object from Microsoft. Check your parameters and refer to script help."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Matching $ProductVersion on channel $Channel" -ForegroundColor Green
|
||||||
|
$selectedObject = ($jsonObj[$selectedIndex].Releases |
|
||||||
|
Where-Object { $_.Architecture -eq $Architecture -and $_.Platform -eq $Platform -and $_.ProductVersion -eq $ProductVersion })
|
||||||
|
|
||||||
|
if (-not $selectedObject) {
|
||||||
|
throw "No version matching $ProductVersion found in $channel channel for $Architecture architecture."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Found matching version`n" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Test-Path $Folder) {
|
||||||
|
foreach ($artifacts in $selectedObject.Artifacts) {
|
||||||
|
# Not showing the progress bar in Invoke-WebRequest is quite a bit faster than default
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
|
||||||
|
Write-host "Starting download of: $($artifacts.Location)" -ForegroundColor Green
|
||||||
|
# Work out file name
|
||||||
|
$fileName = Split-Path $artifacts.Location -Leaf
|
||||||
|
|
||||||
|
if (Test-Path "$Folder\$fileName" -ErrorAction SilentlyContinue) {
|
||||||
|
if ($Force) {
|
||||||
|
Write-Host "Force specified. Will attempt to download and overwrite existing file." -ForegroundColor Green
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $artifacts.Location -OutFile "$Folder\$fileName" -UseBasicParsing
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Attempted to download file, but failed: $error[0]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# CR-someday: There should be an evaluation of the file version, if possible. Currently the function only
|
||||||
|
# checks if a file of the same name exists, not if the versions differ
|
||||||
|
Write-Host "$Folder\$fileName already exists!" -ForegroundColor Yellow
|
||||||
|
|
||||||
|
do {
|
||||||
|
$overWrite = Read-Host -Prompt "Press Y to overwrite or N to quit."
|
||||||
|
}
|
||||||
|
# -notmatch is case insensitive
|
||||||
|
while ($overWrite -notmatch '^y$|^n$')
|
||||||
|
|
||||||
|
if ($overWrite -match '^y$') {
|
||||||
|
Write-Host "Starting Download" -ForegroundColor Green
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $artifacts.Location -OutFile "$Folder\$fileName" -UseBasicParsing
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Attempted to download file, but failed: $error[0]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "File already exists and user chose not to overwrite, exiting script." -ForegroundColor Red
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "Starting Download" -ForegroundColor Green
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $artifacts.Location -OutFile "$Folder\$fileName" -UseBasicParsing
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Attempted to download file, but failed: $error[0]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (((Get-FileHash -Algorithm $artifacts.HashAlgorithm -Path "$Folder\$fileName").Hash) -eq $artifacts.Hash) {
|
||||||
|
Write-Host "Calculated checksum matches known checksum`n" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Warning "Checksum mismatch!"
|
||||||
|
Write-Warning "Expected Hash: $($artifacts.Hash)"
|
||||||
|
Write-Warning "Downloaded file Hash: $((Get-FileHash -Algorithm $($artifacts.HashAlgorithm) -Path "$Folder\$fileName").Hash)`n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
throw "Folder $Folder does not exist"
|
||||||
|
}
|
||||||
|
Write-Host "-- Script Completed: File Downloaded -- " -ForegroundColor Green
|
||||||
|
|
||||||
|
Write-Host "Installing..." -ForegroundColor Green
|
||||||
|
|
||||||
|
cmd /c start /wait msiexec /i "$Folder\$fileName" /qn /norestart
|
||||||
|
|
||||||
|
Set-Service edgeupdate -StartupType Manual -ErrorAction SilentlyContinue
|
||||||
|
Set-Service edgeupdatem -StartupType Manual -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Unregister-ScheduledTask -TaskName MicrosoftEdgeUpdateTaskMachineCore -Confirm:$false -ErrorAction SilentlyContinue
|
||||||
|
Unregister-ScheduledTask -TaskName MicrosoftEdgeUpdateTaskMachineUA -Confirm:$false -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Write-Host "Installed Microsoft Edge" -ForegroundColor Green
|
2175
Applications/Firefox/Force-Update.ps1
Normal file
2175
Applications/Firefox/Force-Update.ps1
Normal file
File diff suppressed because it is too large
Load Diff
126
Applications/Flash Player/Force-Remove.ps1
Normal file
126
Applications/Flash Player/Force-Remove.ps1
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<#
|
||||||
|
===========================================================================
|
||||||
|
Created on: 0/01/2021 13:06
|
||||||
|
Created by: Ben Whitmore
|
||||||
|
Organization: -
|
||||||
|
Filename: Install_Flash_Removal_KB4577586.ps1
|
||||||
|
Target System: Windows 10 , Windows Server 2012/R2 | 2016 | 2019 | 1903 | 1909 | 2004
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
Version:
|
||||||
|
1.2.1 - 22/01/2021
|
||||||
|
Added support for Server OS - Thanks @Hoorge for the suggestion
|
||||||
|
|
||||||
|
1.2 - 04/01/2021
|
||||||
|
Fixed 20H2 coding error - Credit @AndyUpperton
|
||||||
|
|
||||||
|
1.1 02/01/2021
|
||||||
|
Basic Transcript Logging added
|
||||||
|
|
||||||
|
1.0 - 01/01/2021
|
||||||
|
Release
|
||||||
|
#>
|
||||||
|
|
||||||
|
#Set Current Directory
|
||||||
|
$ScriptPath = $MyInvocation.MyCommand.Path
|
||||||
|
$CurrentDir = Split-Path $ScriptPath
|
||||||
|
|
||||||
|
$Log = Join-Path $ENV:TEMP "Flash_Uninstall.log"
|
||||||
|
Start-Transcript $Log
|
||||||
|
|
||||||
|
#Set WUSA.EXE Variable
|
||||||
|
$WUSA = "$env:systemroot\System32\wusa.exe"
|
||||||
|
|
||||||
|
#Get OS Product Name
|
||||||
|
$OS_ProductName = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' ProductName).ProductName
|
||||||
|
|
||||||
|
#Build OS Version String
|
||||||
|
Switch ($OS_ProductName) {
|
||||||
|
{ $_.StartsWith("Windows 10") } { $OS_String = ($OS_ProductName -split "\s+" | Select-Object -First 2) -Join ' ' }
|
||||||
|
{ $_.StartsWith("Windows Server 2012 R2") } { $OS_String = ($OS_ProductName -split "\s+" | Select-Object -First 4) -Join ' ' }
|
||||||
|
{ ($_.StartsWith("Windows Server") -and (!($_.Contains("R2")))) } { $OS_String = ($OS_ProductName -split "\s+" | Select-Object -First 3) -Join ' ' }
|
||||||
|
}
|
||||||
|
|
||||||
|
#Get OS Release ID for valid OS's
|
||||||
|
If (!($OS_String -match "Server 2012")) {
|
||||||
|
$OS_ReleaseID = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' ReleaseId).ReleaseId
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Output "Skipping check of Release ID for $($OS_ProductName)"
|
||||||
|
}
|
||||||
|
|
||||||
|
#Rename $OS_ReleaseID variable for "Windows 10 20H2" and "Windows Server, version 1909" because the same KB update is used for both 2004 and 2009
|
||||||
|
If (($OS_ReleaseID -eq "2009" -and $OS_ProductName -match "Windows 10")) {
|
||||||
|
$OS_ReleaseID = "2004"
|
||||||
|
}
|
||||||
|
|
||||||
|
#Build OS Version Name variable
|
||||||
|
Switch ($OS_String) {
|
||||||
|
{ $_.Equals("Windows 10") } { $Version_String = $OS_String + " Version " + $OS_ReleaseID }
|
||||||
|
{ $_.StartsWith("Windows Server 2") } { $Version_String = $OS_String }
|
||||||
|
{ $_.StartsWith("Windows Server,") } { $Version_String = $OS_String + $OS_ReleaseID }
|
||||||
|
}
|
||||||
|
|
||||||
|
#Get OS Architecture
|
||||||
|
$OS_Architecture = Switch (Get-CIMInstance -Namespace "ROOT\CIMV2" -Class "Win32_Processor" | Select-Object -Unique -ExpandProperty Architecture) {
|
||||||
|
9 { 'x64-based' }
|
||||||
|
0 { 'x86-based' }
|
||||||
|
5 { 'ARM64-based' }
|
||||||
|
}
|
||||||
|
|
||||||
|
$PatchRequired = "Update for Removal of Adobe Flash Player for " + $Version_String + " for " + $OS_Architecture + " systems (KB4577586)"
|
||||||
|
|
||||||
|
#Get Patch Titles
|
||||||
|
$PatchNames = Get-ChildItem $CurrentDir | Where-Object { $_.PSIsContainer } | Foreach-Object { $_.Name }
|
||||||
|
|
||||||
|
#Check if the patch has been downloaded for the current system
|
||||||
|
$PatchFound = $False
|
||||||
|
|
||||||
|
#Check Installation
|
||||||
|
$Patch = Get-Hotfix | Where-Object { $_.HotFixID -match "KB4577586" }
|
||||||
|
If ($Patch) {
|
||||||
|
Write-Host "Patch Already Installed"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Foreach ($Patch in $PatchNames) {
|
||||||
|
If ($Patch -eq $PatchRequired) {
|
||||||
|
$PatchFound = $True
|
||||||
|
|
||||||
|
#Get MSU from the correct Directory
|
||||||
|
$MSU = Get-ChildItem (Join-Path $CurrentDir $Patch) -Recurse | Where-Object { $_.Extension -eq ".msu" }
|
||||||
|
$MSUFullPath = Join-Path (Join-Path $CurrentDir $PatchRequired) $MSU.Name
|
||||||
|
|
||||||
|
#Set WUSA Args
|
||||||
|
$Args = @(
|
||||||
|
"""$MSUFullPath"""
|
||||||
|
"/quiet"
|
||||||
|
"/norestart"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Patch detection determines outcome
|
||||||
|
If ($PatchFound) {
|
||||||
|
Write-Host "Patch found for this system"
|
||||||
|
Write-Host "Patch Required: $($PatchRequired)"
|
||||||
|
Write-Host "Patch Name: $($MSU.Name)"
|
||||||
|
Write-Host "Installing Update..."
|
||||||
|
|
||||||
|
#Install Patch
|
||||||
|
Start-Process -FilePath $WUSA -ArgumentList $Args -Wait
|
||||||
|
|
||||||
|
#Check Installation
|
||||||
|
$Patch = Get-Hotfix | Where-Object { $_.HotFixID -match "KB4577586" }
|
||||||
|
If ($Patch) {
|
||||||
|
Write-Host "Patch Installed Successfully"
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Warning "Patch Installation Failed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host "Patch not found for this system"
|
||||||
|
Write-Host "Patch Required: $($PatchRequired)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Stop-Transcript
|
2268
Applications/Java/Force-Update.ps1
Normal file
2268
Applications/Java/Force-Update.ps1
Normal file
File diff suppressed because it is too large
Load Diff
24
Applications/Notepad++/Force-Update.ps1
Normal file
24
Applications/Notepad++/Force-Update.ps1
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Modern websites require TLS 1.2
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
|
#requires -RunAsAdministrator
|
||||||
|
|
||||||
|
# Let's go directly to the website and see what it lists as the current version
|
||||||
|
$BaseUri = "https://notepad-plus-plus.org"
|
||||||
|
$BasePage = Invoke-WebRequest -Uri $BaseUri -UseBasicParsing
|
||||||
|
$ChildPath = $BasePage.Links | Where-Object { $_.outerHTML -like '*Current Version*' } | Select-Object -ExpandProperty href
|
||||||
|
# Now let's go to the latest version's page and find the installer
|
||||||
|
$DownloadPageUri = $BaseUri + $ChildPath
|
||||||
|
$DownloadPage = Invoke-WebRequest -Uri $DownloadPageUri -UseBasicParsing
|
||||||
|
# Determine bit-ness of O/S and download accordingly
|
||||||
|
if ( [System.Environment]::Is64BitOperatingSystem ) {
|
||||||
|
$DownloadUrl = $DownloadPage.Links | Where-Object { $_.outerHTML -like '*npp.*.Installer.x64.exe"*' } | Select-Object -ExpandProperty href -Unique
|
||||||
|
} else {
|
||||||
|
$DownloadUrl = $DownloadPage.Links | Where-Object { $_.outerHTML -like '*npp.*.Installer.exe"*' } | Select-Object -ExpandProperty href -Unique
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Downloading the latest Notepad++ to the temp folder"
|
||||||
|
Invoke-WebRequest -Uri $DownloadUrl -OutFile "$env:TEMP\$( Split-Path -Path $DownloadUrl -Leaf )" | Out-Null
|
||||||
|
|
||||||
|
Write-Host "Installing the latest Notepad++"
|
||||||
|
Start-Process -FilePath "$env:TEMP\$( Split-Path -Path $DownloadUrl -Leaf )" -ArgumentList "/S" -Wait
|
437
Applications/Zoom/Force-Remove.ps1
Normal file
437
Applications/Zoom/Force-Remove.ps1
Normal file
@@ -0,0 +1,437 @@
|
|||||||
|
<#
|
||||||
|
tes
|
||||||
|
.SYNOPSIS
|
||||||
|
Uninstalls all Zoom applications registered with the Windows installer.
|
||||||
|
Whether they are installed to the local computer or the users profile.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Searches registry for applications registered with 'Zoom' as publisher.
|
||||||
|
If any found, the uninstall string is retrieved and used to uninstall the application.
|
||||||
|
If applications are found to be installed in the users profile, the users context is invoked and the application is uninstalled coming from SYSTEM context.
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Filename: Uninstall-EverythingZoom.ps1
|
||||||
|
Version: 1.0
|
||||||
|
Author: Martin Bengtsson
|
||||||
|
Blog: www.imab.dk
|
||||||
|
Twitter: @mwbengtsson
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.imab.dk/uninstall-all-zoom-applications-in-a-jiffy-using-configuration-manager-and-powershell/
|
||||||
|
#>
|
||||||
|
|
||||||
|
function Execute-AsLoggedOnUser($Command,$Hidden=$true) {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Function that can execute powershell in the context of the logged-in user.
|
||||||
|
.DESCRIPTION
|
||||||
|
This function will use advanced API's to get the access token of the currently logged-in user, in order to execute a script in the users context.
|
||||||
|
This is useful for scripts that are run in the local system users context.
|
||||||
|
.REQUIREMENTS
|
||||||
|
This script myst be run from the context of the SYSTEM account.
|
||||||
|
Designes to be run by Intune or SCCM Agent.
|
||||||
|
Absolute paths required.
|
||||||
|
.EXAMPLE
|
||||||
|
Running a powershell script visible to the user
|
||||||
|
$userCommand = '-file c:\windows\temp\script.ps1'
|
||||||
|
executeAsLoggedOnUser -Command $userCommand -Hidden $false
|
||||||
|
.EXAMPLE
|
||||||
|
Running a powershell command hidden from the user (hidden is default true)
|
||||||
|
$userCommand = '-command &{remove-item c:\temp\secretfile.txt}'
|
||||||
|
executeAsLoggedOnUser -Command $userCommand
|
||||||
|
.COPYRIGHT
|
||||||
|
MIT License, feel free to distribute and use as you like, please leave author information.
|
||||||
|
.AUTHOR
|
||||||
|
Michael Mardahl - @michael_mardahl on twitter - BLOG: https://www.iphase.dk
|
||||||
|
C# borrowed from the awesome Justin Myrray (https://github.com/murrayju/CreateProcessAsUser)
|
||||||
|
.DISCLAIMER
|
||||||
|
This function is provided AS-IS, with no warranty - Use at own risk!
|
||||||
|
#>
|
||||||
|
|
||||||
|
$csharpCode = @"
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace murrayju.ProcessExtensions
|
||||||
|
{
|
||||||
|
public static class ProcessExtensions
|
||||||
|
{
|
||||||
|
#region Win32 Constants
|
||||||
|
|
||||||
|
private const int CREATE_UNICODE_ENVIRONMENT = 0x00000400;
|
||||||
|
private const int CREATE_NO_WINDOW = 0x08000000;
|
||||||
|
|
||||||
|
private const int CREATE_NEW_CONSOLE = 0x00000010;
|
||||||
|
|
||||||
|
private const uint INVALID_SESSION_ID = 0xFFFFFFFF;
|
||||||
|
private static readonly IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DllImports
|
||||||
|
|
||||||
|
[DllImport("advapi32.dll", EntryPoint = "CreateProcessAsUser", SetLastError = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
||||||
|
private static extern bool CreateProcessAsUser(
|
||||||
|
IntPtr hToken,
|
||||||
|
String lpApplicationName,
|
||||||
|
String lpCommandLine,
|
||||||
|
IntPtr lpProcessAttributes,
|
||||||
|
IntPtr lpThreadAttributes,
|
||||||
|
bool bInheritHandle,
|
||||||
|
uint dwCreationFlags,
|
||||||
|
IntPtr lpEnvironment,
|
||||||
|
String lpCurrentDirectory,
|
||||||
|
ref STARTUPINFO lpStartupInfo,
|
||||||
|
out PROCESS_INFORMATION lpProcessInformation);
|
||||||
|
|
||||||
|
[DllImport("advapi32.dll", EntryPoint = "DuplicateTokenEx")]
|
||||||
|
private static extern bool DuplicateTokenEx(
|
||||||
|
IntPtr ExistingTokenHandle,
|
||||||
|
uint dwDesiredAccess,
|
||||||
|
IntPtr lpThreadAttributes,
|
||||||
|
int TokenType,
|
||||||
|
int ImpersonationLevel,
|
||||||
|
ref IntPtr DuplicateTokenHandle);
|
||||||
|
|
||||||
|
[DllImport("userenv.dll", SetLastError = true)]
|
||||||
|
private static extern bool CreateEnvironmentBlock(ref IntPtr lpEnvironment, IntPtr hToken, bool bInherit);
|
||||||
|
|
||||||
|
[DllImport("userenv.dll", SetLastError = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
private static extern bool DestroyEnvironmentBlock(IntPtr lpEnvironment);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern bool CloseHandle(IntPtr hSnapshot);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern uint WTSGetActiveConsoleSessionId();
|
||||||
|
|
||||||
|
[DllImport("Wtsapi32.dll")]
|
||||||
|
private static extern uint WTSQueryUserToken(uint SessionId, ref IntPtr phToken);
|
||||||
|
|
||||||
|
[DllImport("wtsapi32.dll", SetLastError = true)]
|
||||||
|
private static extern int WTSEnumerateSessions(
|
||||||
|
IntPtr hServer,
|
||||||
|
int Reserved,
|
||||||
|
int Version,
|
||||||
|
ref IntPtr ppSessionInfo,
|
||||||
|
ref int pCount);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Win32 Structs
|
||||||
|
|
||||||
|
private enum SW
|
||||||
|
{
|
||||||
|
SW_HIDE = 0,
|
||||||
|
SW_SHOWNORMAL = 1,
|
||||||
|
SW_NORMAL = 1,
|
||||||
|
SW_SHOWMINIMIZED = 2,
|
||||||
|
SW_SHOWMAXIMIZED = 3,
|
||||||
|
SW_MAXIMIZE = 3,
|
||||||
|
SW_SHOWNOACTIVATE = 4,
|
||||||
|
SW_SHOW = 5,
|
||||||
|
SW_MINIMIZE = 6,
|
||||||
|
SW_SHOWMINNOACTIVE = 7,
|
||||||
|
SW_SHOWNA = 8,
|
||||||
|
SW_RESTORE = 9,
|
||||||
|
SW_SHOWDEFAULT = 10,
|
||||||
|
SW_MAX = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum WTS_CONNECTSTATE_CLASS
|
||||||
|
{
|
||||||
|
WTSActive,
|
||||||
|
WTSConnected,
|
||||||
|
WTSConnectQuery,
|
||||||
|
WTSShadow,
|
||||||
|
WTSDisconnected,
|
||||||
|
WTSIdle,
|
||||||
|
WTSListen,
|
||||||
|
WTSReset,
|
||||||
|
WTSDown,
|
||||||
|
WTSInit
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct PROCESS_INFORMATION
|
||||||
|
{
|
||||||
|
public IntPtr hProcess;
|
||||||
|
public IntPtr hThread;
|
||||||
|
public uint dwProcessId;
|
||||||
|
public uint dwThreadId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum SECURITY_IMPERSONATION_LEVEL
|
||||||
|
{
|
||||||
|
SecurityAnonymous = 0,
|
||||||
|
SecurityIdentification = 1,
|
||||||
|
SecurityImpersonation = 2,
|
||||||
|
SecurityDelegation = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct STARTUPINFO
|
||||||
|
{
|
||||||
|
public int cb;
|
||||||
|
public String lpReserved;
|
||||||
|
public String lpDesktop;
|
||||||
|
public String lpTitle;
|
||||||
|
public uint dwX;
|
||||||
|
public uint dwY;
|
||||||
|
public uint dwXSize;
|
||||||
|
public uint dwYSize;
|
||||||
|
public uint dwXCountChars;
|
||||||
|
public uint dwYCountChars;
|
||||||
|
public uint dwFillAttribute;
|
||||||
|
public uint dwFlags;
|
||||||
|
public short wShowWindow;
|
||||||
|
public short cbReserved2;
|
||||||
|
public IntPtr lpReserved2;
|
||||||
|
public IntPtr hStdInput;
|
||||||
|
public IntPtr hStdOutput;
|
||||||
|
public IntPtr hStdError;
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum TOKEN_TYPE
|
||||||
|
{
|
||||||
|
TokenPrimary = 1,
|
||||||
|
TokenImpersonation = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct WTS_SESSION_INFO
|
||||||
|
{
|
||||||
|
public readonly UInt32 SessionID;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
public readonly String pWinStationName;
|
||||||
|
|
||||||
|
public readonly WTS_CONNECTSTATE_CLASS State;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Gets the user token from the currently active session
|
||||||
|
private static bool GetSessionUserToken(ref IntPtr phUserToken)
|
||||||
|
{
|
||||||
|
var bResult = false;
|
||||||
|
var hImpersonationToken = IntPtr.Zero;
|
||||||
|
var activeSessionId = INVALID_SESSION_ID;
|
||||||
|
var pSessionInfo = IntPtr.Zero;
|
||||||
|
var sessionCount = 0;
|
||||||
|
|
||||||
|
// Get a handle to the user access token for the current active session.
|
||||||
|
if (WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, ref pSessionInfo, ref sessionCount) != 0)
|
||||||
|
{
|
||||||
|
var arrayElementSize = Marshal.SizeOf(typeof(WTS_SESSION_INFO));
|
||||||
|
var current = pSessionInfo;
|
||||||
|
|
||||||
|
for (var i = 0; i < sessionCount; i++)
|
||||||
|
{
|
||||||
|
var si = (WTS_SESSION_INFO)Marshal.PtrToStructure((IntPtr)current, typeof(WTS_SESSION_INFO));
|
||||||
|
current += arrayElementSize;
|
||||||
|
|
||||||
|
if (si.State == WTS_CONNECTSTATE_CLASS.WTSActive)
|
||||||
|
{
|
||||||
|
activeSessionId = si.SessionID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If enumerating did not work, fall back to the old method
|
||||||
|
if (activeSessionId == INVALID_SESSION_ID)
|
||||||
|
{
|
||||||
|
activeSessionId = WTSGetActiveConsoleSessionId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WTSQueryUserToken(activeSessionId, ref hImpersonationToken) != 0)
|
||||||
|
{
|
||||||
|
// Convert the impersonation token to a primary token
|
||||||
|
bResult = DuplicateTokenEx(hImpersonationToken, 0, IntPtr.Zero,
|
||||||
|
(int)SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation, (int)TOKEN_TYPE.TokenPrimary,
|
||||||
|
ref phUserToken);
|
||||||
|
|
||||||
|
CloseHandle(hImpersonationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool StartProcessAsCurrentUser(string cmdLine, bool visible, string appPath = null, string workDir = null)
|
||||||
|
{
|
||||||
|
var hUserToken = IntPtr.Zero;
|
||||||
|
var startInfo = new STARTUPINFO();
|
||||||
|
var procInfo = new PROCESS_INFORMATION();
|
||||||
|
var pEnv = IntPtr.Zero;
|
||||||
|
int iResultOfCreateProcessAsUser;
|
||||||
|
|
||||||
|
startInfo.cb = Marshal.SizeOf(typeof(STARTUPINFO));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!GetSessionUserToken(ref hUserToken))
|
||||||
|
{
|
||||||
|
throw new Exception("StartProcessAsCurrentUser: GetSessionUserToken failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint dwCreationFlags = CREATE_UNICODE_ENVIRONMENT | (uint)(visible ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW);
|
||||||
|
startInfo.wShowWindow = (short)(visible ? SW.SW_SHOW : SW.SW_HIDE);
|
||||||
|
startInfo.lpDesktop = "winsta0\\default";
|
||||||
|
|
||||||
|
if (!CreateEnvironmentBlock(ref pEnv, hUserToken, false))
|
||||||
|
{
|
||||||
|
throw new Exception("StartProcessAsCurrentUser: CreateEnvironmentBlock failed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CreateProcessAsUser(hUserToken,
|
||||||
|
appPath, // Application Name
|
||||||
|
cmdLine, // Command Line
|
||||||
|
IntPtr.Zero,
|
||||||
|
IntPtr.Zero,
|
||||||
|
false,
|
||||||
|
dwCreationFlags,
|
||||||
|
pEnv,
|
||||||
|
workDir, // Working directory
|
||||||
|
ref startInfo,
|
||||||
|
out procInfo))
|
||||||
|
{
|
||||||
|
throw new Exception("StartProcessAsCurrentUser: CreateProcessAsUser failed.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
iResultOfCreateProcessAsUser = Marshal.GetLastWin32Error();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseHandle(hUserToken);
|
||||||
|
if (pEnv != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
DestroyEnvironmentBlock(pEnv);
|
||||||
|
}
|
||||||
|
CloseHandle(procInfo.hThread);
|
||||||
|
CloseHandle(procInfo.hProcess);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
# Compiling the source code as csharp
|
||||||
|
$compilerParams = [System.CodeDom.Compiler.CompilerParameters]::new()
|
||||||
|
$compilerParams.ReferencedAssemblies.AddRange(('System.Runtime.InteropServices.dll', 'System.dll'))
|
||||||
|
$compilerParams.CompilerOptions = '/unsafe'
|
||||||
|
$compilerParams.GenerateInMemory = $True
|
||||||
|
Add-Type -TypeDefinition $csharpCode -Language CSharp -CompilerParameters $compilerParams
|
||||||
|
# Adding powershell executeable to the command
|
||||||
|
$Command = '{0}\System32\WindowsPowerShell\v1.0\powershell.exe -executionPolicy bypass {1}' -f $($env:windir),$Command
|
||||||
|
# Adding double slashes to the command paths, as this is required.
|
||||||
|
$Command = $Command.Replace("\","\\")
|
||||||
|
# Execute a process as the currently logged on user.
|
||||||
|
# Absolute paths required if running as SYSTEM!
|
||||||
|
if($Hidden) { #running the command hidden
|
||||||
|
$runCommand = [murrayju.ProcessExtensions.ProcessExtensions]::StartProcessAsCurrentUser($Command,$false)
|
||||||
|
}else{ #running the command visible
|
||||||
|
$runCommand = [murrayju.ProcessExtensions.ProcessExtensions]::StartProcessAsCurrentUser($Command,$true)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($runCommand) {
|
||||||
|
return "Executed `"$Command`" as loggedon user"
|
||||||
|
} else {
|
||||||
|
throw "Something went wrong when executing process as currently logged-on user"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Uninstall-ZoomLocalMachine() {
|
||||||
|
|
||||||
|
Write-Verbose -Verbose -Message "Running Uninstall-ZoomLocalMachine function"
|
||||||
|
$registryPath = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||||
|
if (Test-Path -Path $registryPath) {
|
||||||
|
$installedZoomApps = Get-ChildItem -Path $registryPath -Recurse | Get-ItemProperty | Where-Object {$_.Publisher -like "Zoom*" } | Select-Object Displayname,UninstallString
|
||||||
|
if ($installedZoomApps) {
|
||||||
|
Write-Verbose -Verbose -Message "Installed Zoom applications found in HKLM"
|
||||||
|
foreach ($zoomApp in $installedZoomApps) {
|
||||||
|
if ($zoomApp.UninstallString) {
|
||||||
|
# Regular expression for format of MSI product code
|
||||||
|
$msiRegEx = "\w{8}-\w{4}-\w{4}-\w{4}-\w{12}"
|
||||||
|
# Formatting the productcode in a creative way.
|
||||||
|
# Needed this separately, as the uninstall string retrieved from registry sometimes wasn't formatted properly
|
||||||
|
$a = $zoomApp.Uninstallstring.Split("{")[1]
|
||||||
|
$b = $a.Split("}")[0]
|
||||||
|
# Only continuing if the uninstall string matches a regular MSI product code
|
||||||
|
if ($b -match $msiRegEx) {
|
||||||
|
$productCode = "{" + $b + "}"
|
||||||
|
if ($productCode) {
|
||||||
|
try {
|
||||||
|
Write-Verbose -Verbose -Message "Uninstalling application: $($zoomApp.DisplayName)"
|
||||||
|
Start-Process "C:\Windows\System32\msiexec.exe" -ArgumentList ("/x" + $productCode + " /passive") -Wait
|
||||||
|
}
|
||||||
|
|
||||||
|
catch {
|
||||||
|
Write-Error -Message "Failed to uninstall application: $($zoomApp.DisplayName)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose -Verbose -Message "No Zoom applications found in HKLM"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose -Verbose -Message "Registry path not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Uninstall-ZoomCurrentUser() {
|
||||||
|
|
||||||
|
Write-Verbose -Verbose -Message "Running Uninstall-ZoomCurrentUser function"
|
||||||
|
# Getting all user profiles on the computer
|
||||||
|
$userProfiles = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" | Where-Object {$_.PSChildName -match "S-1-5-21-(\d+-?){4}$"} | Select-Object @{Name="SID"; Expression={$_.PSChildName}}, @{Name="UserHive";Expression={"$($_.ProfileImagePath)\NTuser.dat"}}
|
||||||
|
foreach ($userProfile in $userProfiles) {
|
||||||
|
# Formatting the username in a separate variable
|
||||||
|
$userName = $userProfile.UserHive.Split("\")[2]
|
||||||
|
$registryPath = "Registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||||
|
if (Test-Path -Path $registryPath) {
|
||||||
|
$installedZoomApps = Get-ChildItem -Path $registryPath -Recurse | Get-ItemProperty | Where-Object {$_.Publisher -like "Zoom*" } | Select-Object Displayname,UninstallString
|
||||||
|
if ($installedZoomApps) {
|
||||||
|
Write-Verbose -Verbose -Message "Installed Zoom applications found in HKCU for user: $userName"
|
||||||
|
foreach ($zoomApp in $installedZoomApps) {
|
||||||
|
if ($zoomApp.UninstallString) {
|
||||||
|
$userCommand = '-command &{Start-Process "C:\Users\USERNAME\AppData\Roaming\Zoom\uninstall\Installer.exe" -ArgumentList "/uninstall" -Wait}'
|
||||||
|
# Replacing the placeholder: USERNAME with the actual username retrieved from the userprofile
|
||||||
|
# This can probably be done smarter, but I failed to find another method
|
||||||
|
$userCommand = $userCommand -replace "USERNAME",$userName
|
||||||
|
try {
|
||||||
|
Write-Verbose -Verbose -Message "Uninstalling application: $($zoomApp.DisplayName) as the logged on user: $userName"
|
||||||
|
Execute-AsLoggedOnUser -Command $userCommand
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error -Message "Failed to uninstall application: $($zoomApp.DisplayName) for user: $userName"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose -Verbose -Message "No Zoom applications found in HKCU for user: $userName"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Verbose -Verbose -Message "Registry path not found for user: $userName"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Write-Verbose -Verbose -Message "Script is running"
|
||||||
|
Uninstall-ZoomLocalMachine
|
||||||
|
Uninstall-ZoomCurrentUser
|
||||||
|
}
|
||||||
|
|
||||||
|
catch {
|
||||||
|
Write-Verbose -Verbose -Message "Something went wrong during running of the script"
|
||||||
|
}
|
||||||
|
|
||||||
|
finally {
|
||||||
|
Write-Verbose -Verbose -Message "Script is done running"
|
||||||
|
}
|
34
Azure Active Directory/Get-AadGroups.ps1
Normal file
34
Azure Active Directory/Get-AadGroups.ps1
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
$creduser = Read-Host "Admin email"
|
||||||
|
$credpassword = Read-Host "Admin Password"
|
||||||
|
|
||||||
|
[securestring]$secStringPassword = ConvertTo-SecureString $credpassword -AsPlainText -Force
|
||||||
|
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($creduser, $secStringPassword)
|
||||||
|
|
||||||
|
Connect-AzureAD -Credential $credObject
|
||||||
|
|
||||||
|
$Table = New-Object 'System.Collections.Generic.List[System.Object]'
|
||||||
|
|
||||||
|
$Groups = Get-AzureAdGroup -All $True | Where-Object { $_.MailEnabled -eq $false -and $_.SecurityEnabled -eq $true } | Sort-Object DisplayName
|
||||||
|
|
||||||
|
$obj1 = [PSCustomObject]@{
|
||||||
|
'Name' = 'Security Group'
|
||||||
|
'Count' = $Groups.count
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj1
|
||||||
|
|
||||||
|
Foreach ($Group in $Groups) {
|
||||||
|
$Users = (Get-AzureADGroupMember -ObjectId $Group.ObjectID | Sort-Object DisplayName | Select-Object -ExpandProperty DisplayName) -join ", "
|
||||||
|
$GName = $Group.DisplayName
|
||||||
|
|
||||||
|
$hash = New-Object PSObject -property @{ Name = "$GName"; Members = "$Users" }
|
||||||
|
|
||||||
|
$obj = [PSCustomObject]@{
|
||||||
|
'Name' = $GName
|
||||||
|
'Members' = $users
|
||||||
|
}
|
||||||
|
|
||||||
|
$table.add($obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
$table | Export-Csv -Path "Groupe-SharePoint.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation
|
12
Azure Active Directory/Get-MsolUser.ps1
Normal file
12
Azure Active Directory/Get-MsolUser.ps1
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Demande un nom d'utilisateur
|
||||||
|
$User = read-host -Prompt "User Name"
|
||||||
|
|
||||||
|
# Obtenir les infos de l'utilisateur
|
||||||
|
$user_dn = (get-mailbox $user).distinguishedname
|
||||||
|
|
||||||
|
# Liste des liste de distribution
|
||||||
|
"User " + $User + " is a member of the following groups:"
|
||||||
|
foreach ($group in get-distributiongroup -resultsize unlimited) {
|
||||||
|
if ((get-distributiongroupmember $group.identity | select -expand distinguishedname) -contains $user_dn) { $group.name }
|
||||||
|
|
||||||
|
}
|
37
Azure Active Directory/Import-MsolUsers.ps1
Normal file
37
Azure Active Directory/Import-MsolUsers.ps1
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Import active directory module for running AD cmdlets
|
||||||
|
Import-Module MSOnline
|
||||||
|
|
||||||
|
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||||
|
$AADUsers = Import-csv "Templates\Import-MsolUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||||
|
|
||||||
|
#Loop through each row containing user details in the CSV file
|
||||||
|
foreach ($User in $AADUsers) {
|
||||||
|
|
||||||
|
$FullName = "$($User.firstname) $($User.lastname)"
|
||||||
|
|
||||||
|
if ((Get-MsolUser -UserPrincipalName $User.username -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Warning "A user account with UPN $($User.username) already exist in Azure Active Directory."
|
||||||
|
}
|
||||||
|
elseif (([string]::IsNullOrEmpty($User.password))) {
|
||||||
|
Write-Warning "The password for $($User.username) is nul or empty."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
New-MsolUser -DisplayName $FullName `
|
||||||
|
-FirstName $User.FirstName `
|
||||||
|
-LastName $User.LastName `
|
||||||
|
-UserPrincipalName $User.Username `
|
||||||
|
-UsageLocation $User.UsageLocation `
|
||||||
|
-LicenseAssignment $User.AccountSkuId `
|
||||||
|
-Password $user.password `
|
||||||
|
-City $User.City `
|
||||||
|
-Department $User.Department `
|
||||||
|
-PasswordNeverExpires $true `
|
||||||
|
-ForceChangePassword $False
|
||||||
|
Write-Host "The user $($User.firstname) $($User.lastname) ($($User.username)) was created."
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "The user $($User.firstname) $($User.lastname) ($($User.username)) was not created."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
Azure Active Directory/MSolLicences.ps1
Normal file
29
Azure Active Directory/MSolLicences.ps1
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
$License = 'hitea:STANDARDPACK'
|
||||||
|
$EnabledPlans = @(
|
||||||
|
'TEAMS1'
|
||||||
|
'WHITEBOARD_PLAN1'
|
||||||
|
)
|
||||||
|
$Exclusions = @(
|
||||||
|
'Sync_ADCONNECT1@hitea.onmicrosoft.com'
|
||||||
|
)
|
||||||
|
$AllPlans = (Get-MsolAccountSku | Where-Object { $_.AccountSkuId -eq $License } | Select-Object -ExpandProperty ServiceStatus).ServicePlan.ServiceName
|
||||||
|
$DisabledPlans = $AllPlans | Where-Object { $EnabledPlans -notcontains $_ }
|
||||||
|
$E1CustomizedLicense = New-MsolLicenseOptions -AccountSkuId $License -DisabledPlans $DisabledPlans
|
||||||
|
$Users = Get-MsolUser -UnlicensedUsersOnly -All -EnabledFilter EnabledOnly
|
||||||
|
foreach ($User in $Users) {
|
||||||
|
if ($User.UsageLocation -ne 'FR') {
|
||||||
|
Set-MsolUser -UserPrincipalName $User.UserPrincipalName -UsageLocation PL
|
||||||
|
}
|
||||||
|
if ($User.IsLicensed -eq $false -and $Exclusions -notcontains $User.UserPrincipalName) {
|
||||||
|
Set-MsolUserLicense -UserPrincipalName $User.UserPrincipalName -AddLicenses $License -LicenseOptions $E1CustomizedLicense
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$LicensePlans = Get-MsolAccountSku | ForEach-Object {
|
||||||
|
[PSCustomObject] @{
|
||||||
|
LicenseName = $_.AccountSkuId
|
||||||
|
Plans = $_.ServiceStatus.ServicePlan.ServiceName -join ', '
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$LicensePlans | Format-Table -AutoSize
|
1370
Azure Active Directory/O365HTMLReport.ps1
Normal file
1370
Azure Active Directory/O365HTMLReport.ps1
Normal file
File diff suppressed because it is too large
Load Diff
1
Azure Active Directory/README.md
Normal file
1
Azure Active Directory/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Azure Active Directory
|
10
Azure Active Directory/Set-MsolUsersPassword.ps1
Normal file
10
Azure Active Directory/Set-MsolUsersPassword.ps1
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Import active directory module for running AD cmdlets
|
||||||
|
Import-Module MSOnline
|
||||||
|
|
||||||
|
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||||
|
$AADUsers = Import-csv "Templates\Import-MsolUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||||
|
|
||||||
|
#Loop through each row containing user details in the CSV file
|
||||||
|
foreach ($User in $AADUsers) {
|
||||||
|
Set-MsolUserPassword -UserPrincipalName $User.Username -NewPassword $user.password -ForceChangePassword $false
|
||||||
|
}
|
17
Azure Active Directory/Set-Upn.ps1
Normal file
17
Azure Active Directory/Set-Upn.ps1
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
$creduser = Read-Host "Admin email"
|
||||||
|
$credpassword = Read-Host "Admin Password"
|
||||||
|
|
||||||
|
[securestring]$secStringPassword = ConvertTo-SecureString $credpassword -AsPlainText -Force
|
||||||
|
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($creduser, $secStringPassword)
|
||||||
|
|
||||||
|
$Users = Import-Csv -Path "Set-Upn.csv" -Delimiter ";" -Encoding UTF8
|
||||||
|
|
||||||
|
Connect-MsolService -Credential $credObject
|
||||||
|
|
||||||
|
foreach ($User in $Users) {
|
||||||
|
|
||||||
|
Write-host "Changement de $($User.Upn) pour $($User.NewUpn)"
|
||||||
|
|
||||||
|
Set-MsolUserPrincipalName -UserPrincipalName $($User.Upn) -NewUserPrincipalName $($User.NewUpn)
|
||||||
|
|
||||||
|
}
|
26
Azure Active Directory/Set-UsersLIcences.ps1
Normal file
26
Azure Active Directory/Set-UsersLIcences.ps1
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Importer le fichier CSV
|
||||||
|
$users = Import-csv "Templates\Import-MsolUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||||
|
|
||||||
|
# Get-MsolAccountSku
|
||||||
|
|
||||||
|
# Renseigner le SKU de la licence
|
||||||
|
$accountSkuId = "reseller-account:O365_BUSINESS_PREMIUM"
|
||||||
|
|
||||||
|
# Renseigner les options déactivées
|
||||||
|
# Get-MsolAccountSku | select -ExpandProperty ServiceStatus
|
||||||
|
$BannedList = @("MICROSOFTBOOKINGS", "KAIZALA_O365_P2", "Deskless", "PROJECTWORKMANAGEMENT", "POWERAPPS_O365_P1", "DYN365BC_MS_INVOICING", "O365_SB_Relationship_Management", "STREAM_O365_SMB", "SWAY", "YAMMER_ENTERPRISE")
|
||||||
|
|
||||||
|
$licenseOptions = New-MsolLicenseOptions -AccountSkuId $accountSkuId -DisabledPlans $BannedList
|
||||||
|
|
||||||
|
# Définir les licences pour les utilisateurs
|
||||||
|
ForEach ($user in $users) {
|
||||||
|
|
||||||
|
$upn = $user.Username
|
||||||
|
|
||||||
|
Set-MsolUserLicense -UserPrincipalName $upn -AddLicenses $accountSkuId
|
||||||
|
|
||||||
|
Start-Sleep -Seconds 2
|
||||||
|
|
||||||
|
Set-MsolUserLicense -UserPrincipalName $upn -LicenseOptions $licenseOptions
|
||||||
|
|
||||||
|
}
|
6
Azure Active Directory/Templates/Import-MsolUsers.csv
Normal file
6
Azure Active Directory/Templates/Import-MsolUsers.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FirstName;LastName;AccountSkuId;UsageLocation;Username;Password;City;Department
|
||||||
|
Paul;Dupont;reseller-account:O365_BUSINESS_PREMIUM;FR;p.dupont@hitea.fr;Test123Test1;AGEN;
|
||||||
|
Bernard;Durand;reseller-account:O365_BUSINESS_PREMIUM;FR;b.durand@hitea.fr;Test123Test2;AGEN;
|
||||||
|
David;Bellier;reseller-account:O365_BUSINESS_PREMIUM;FR;d.bellier@hitea.fr;Test123Test3;AGEN;
|
||||||
|
Joël;Tartas;reseller-account:O365_BUSINESS_PREMIUM;FR;j.tartas@hitea.fr;Test123Test4;AGEN;
|
||||||
|
Benoît;Canu;reseller-account:O365_BUSINESS_PREMIUM;FR;b.canu@hitea.fr;Test123Test5;AGEN;
|
|
4
Azure Active Directory/Templates/Set-Upn.csv
Normal file
4
Azure Active Directory/Templates/Set-Upn.csv
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Upn;NewUpn
|
||||||
|
user1@olddomain.com;user1@newdomain.com
|
||||||
|
user2@olddomain.com;user2@newdomain.com
|
||||||
|
user3@olddomain.com;user3@newdomain.com
|
|
22
Centreon/Generation CLAPI.ps1
Normal file
22
Centreon/Generation CLAPI.ps1
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach($line in Get-Content "D:\TEMP\Centreon\liste-2.txt") {
|
||||||
|
if($line -match $regex){
|
||||||
|
|
||||||
|
$ParamsCLAPI = @"
|
||||||
|
|
||||||
|
cd /
|
||||||
|
|
||||||
|
cd /usr/share/centreon/bin
|
||||||
|
|
||||||
|
./centreon -u admin -p 17-F1ch/0rga-20 -o SERVICE -a add -v "SRV-CLUSTER;CRPCEN : Fichier Libs Authentic;Tomcat_Authentic_:_Fichiers"
|
||||||
|
./centreon -u admin -p 17-F1ch/0rga-20 -o SERVICE -a setparam -v "SRV-CLUSTER;CRPCEN : Fichier Libs Authentic;check_command_arguments;!D:/Data/Client/NO05026/AppsRedact/WEB-INF/lib!268!1"
|
||||||
|
|
||||||
|
|
||||||
|
"@
|
||||||
|
|
||||||
|
New-Item "D:\TEMP\Centreon\$line-STATES.sh" -type file -force -value $ParamsCLAPI
|
||||||
|
(Get-Content "D:\TEMP\Centreon\$line-STATES.sh") -replace "CRPCEN","$line" | Set-Content "D:\TEMP\Centreon\$line-STATES.sh"
|
||||||
|
}
|
||||||
|
}
|
104
DNS/Check Server DNS Settings.ps1
Normal file
104
DNS/Check Server DNS Settings.ps1
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : <Date>
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
param
|
||||||
|
(
|
||||||
|
[alias("i")]
|
||||||
|
[string]$inputfile = $(read-host -Prompt "Enter the full path to the list of the CSV input file")
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Bibliothèques de fonctions requises
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "<script_name>.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#------------------------------------------------------------[Script]--------------------------------------------------------------
|
||||||
|
|
||||||
|
cls
|
||||||
|
|
||||||
|
#Initialized the output file
|
||||||
|
$TimeStamp1 = $(((get-date).ToUniversalTime()).ToString("yyyyMMddTHHmmssZ"))
|
||||||
|
$output = "C:\temp\ExportedDNSSetting$TimeStamp1.csv"
|
||||||
|
|
||||||
|
Write-Host "--->Generating the new output file now...... $output "
|
||||||
|
New-Item -Path $output -ItemType File > $null
|
||||||
|
Add-Content -Path $output -Value '"Hostname","Adapter Index","IP Address","DNSServerSetting"'
|
||||||
|
|
||||||
|
|
||||||
|
#Generate the DNS settings output
|
||||||
|
Import-Csv $inputfile | foreach {
|
||||||
|
|
||||||
|
$AdapaterSettings = Get-wmiobject -ClassName Win32_NetworkAdapterConfiguration -ComputerName $_.hostname -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
if($AdapaterSettings -eq $null) {
|
||||||
|
|
||||||
|
Write-Host "--->Collect the DNS Configuration Failed for server -" $_.hostname -ForegroundColor Red
|
||||||
|
|
||||||
|
$NewLine = "{0},{1},{2},{3}" `
|
||||||
|
-f $_.hostname,`
|
||||||
|
$null,`
|
||||||
|
$null,`
|
||||||
|
"This server cannot be connected!!!"
|
||||||
|
|
||||||
|
$NewLine | Add-Content -Path $output
|
||||||
|
|
||||||
|
}else {
|
||||||
|
|
||||||
|
Write-Host "--->Collect the DNS Configuration successfully for server -" $_.hostname -ForegroundColor Green
|
||||||
|
|
||||||
|
Foreach ($ThisAdapaterSetting in $AdapaterSettings) {
|
||||||
|
|
||||||
|
$NewLine = "{0},{1},{2},{3}" `
|
||||||
|
-f $_.hostname,`
|
||||||
|
$ThisAdapaterSetting.Index,`
|
||||||
|
[string]$ThisAdapaterSetting.IPAddress,`
|
||||||
|
[string]$ThisAdapaterSetting.DNSServerSearchOrder
|
||||||
|
|
||||||
|
$NewLine | Add-Content -Path $output
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "--->Data Collection is completed, the result is at $output"
|
33
Exchange Online/Import-SharedMailbox.ps1
Normal file
33
Exchange Online/Import-SharedMailbox.ps1
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Importer le module Exchange Online
|
||||||
|
Import-Module ExchangeOnlineManagement
|
||||||
|
|
||||||
|
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||||
|
$Mailboxes = Import-csv "Templates\Import-SharedMailbox.csv" -Delimiter ";" -Encoding UTF8
|
||||||
|
|
||||||
|
#Loop through each row containing user details in the CSV file
|
||||||
|
foreach ($Mailbox in $Mailboxes) {
|
||||||
|
|
||||||
|
if ((Get-MsolUser -UserPrincipalName $Mailbox.username -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Warning "A Shared Mailbox with UPN $($Mailbox.username) already exist in Azure Active Directory."
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
New-Mailbox -Shared -Name $Mailbox.Name -DisplayName $Mailbox.Name -Alias $Mailbox.Alias -PrimarySmtpAddress $Mailbox.username
|
||||||
|
Write-Host "The Shared Mailbox $($Mailbox.Name) ($($Mailbox.username)) was created." -ForegroundColor Green
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "The Shared Mailbox $($Mailbox.Name) ($($Mailbox.username)) was not created."
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($Member in ($Mailbox.Members).split(",")) {
|
||||||
|
try {
|
||||||
|
Add-MailboxPermission $Mailbox.username -User $Member -AccessRights FullAccess -InheritanceType all
|
||||||
|
Write-Host "$($Members) added to the Shared Mailbox $($Mailbox.username)."
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "$($Members) not added to the Shared Mailbox $($Mailbox.username)."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
6
Exchange Online/Init-MailBox.ps1
Normal file
6
Exchange Online/Init-MailBox.ps1
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Connexion Exchange Online
|
||||||
|
Connect-ExchangeOnline
|
||||||
|
|
||||||
|
# Définir les options de base comme la langue et le fuseau horaire
|
||||||
|
|
||||||
|
Get-Mailbox -ResultSize unlimited | Set-MailboxRegionalConfiguration -Language fr-FR -TimeZone "Romance Standard Time" -DateFormat "dd/MM/yyyy" -LocalizeDefaultFolderName:$true
|
39
Exchange Online/Manage-Calendar.ps1
Normal file
39
Exchange Online/Manage-Calendar.ps1
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
$Compte = Read-Host "Choisir un compte (user@domaine.fr)"
|
||||||
|
$Action = Read-Host "V pour voir ou M pour voir et modifier"
|
||||||
|
# $Excluded = Read-Host "Compte Exclus séparé par des virgules"
|
||||||
|
# Where-Object Identity -notlike "*Meeting4Display*" | Where-Object Identity -notlike "*notification*"
|
||||||
|
$Excluded = @('*Meeting4Display*', '*notification*')
|
||||||
|
|
||||||
|
$AuditMailboxe = Get-Mailbox -Identity $Compte
|
||||||
|
$Mailboxes = Get-Mailbox -ResultSize Unlimited | Where-Object RecipientTypeDetails -eq "UserMailbox" | Where-Object { $Excluded -notcontains $_.Identity }
|
||||||
|
|
||||||
|
foreach ($Bal in $Mailboxes) {
|
||||||
|
|
||||||
|
if ($BAL.Languages -like "*FR*") {
|
||||||
|
$Calendar = Get-MailboxFolderPermission -Identity "$($BAL.PrimarySMTPAddress):\Calendrier" -ErrorAction SilentlyContinue | Select Identity, User, AccessRights
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$Calendar = Get-MailboxFolderPermission -Identity "$($BAL.PrimarySMTPAddress):\Calendar" -ErrorAction SilentlyContinue | Select Identity, User, AccessRights
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Calendar.User.DisplayName -notcontains $AuditMailboxe.Identity) {
|
||||||
|
Write-Host "$($AuditMailboxe.Identity) n'a pas acces au Calendrier de $($Bal.Identity)" -ForegroundColor Yellow
|
||||||
|
if ($Action -eq "M") {
|
||||||
|
|
||||||
|
if ($BAL.Languages -like "*FR*") {
|
||||||
|
|
||||||
|
Add-MailboxFolderPermission -Identity ($Bal.Identity + ":\Calendrier") -User $AuditMailboxe.UserPrincipalName -AccessRights Reviewer
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
Add-MailboxFolderPermission -Identity ($Bal.Identity + ":\Calendar") -User $AuditMailboxe.UserPrincipalName -AccessRights Reviewer
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "$($AuditMailboxe.Identity) a acces au Calendrier de $($Bal.Identity)" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
1
Exchange Online/README.md
Normal file
1
Exchange Online/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Exchange Online
|
4
Exchange Online/Templates/Import-SharedMailbox.csv
Normal file
4
Exchange Online/Templates/Import-SharedMailbox.csv
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Name;alias;username;members
|
||||||
|
Contact ;contact;contact@hitea.fr;p.dupont@hitea.fr
|
||||||
|
SAV;sav;sav@hitea.fr;p.dupont@hitea.fr,d.bellier@hitea.fr
|
||||||
|
Marketing;marketing;marketing@hitea.fr;b.canu@hitea.fr,j.tartas@hitea.fr
|
|
16
Exchange Online/Upload-Pst.ps1
Normal file
16
Exchange Online/Upload-Pst.ps1
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#Il faut installer l'outil AZCopy
|
||||||
|
|
||||||
|
#Se rendre dans le repertoire d'AZCopy
|
||||||
|
cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
|
||||||
|
|
||||||
|
#Définir la source des PST
|
||||||
|
$PSTFile = "\\SRV01\PSTImport"
|
||||||
|
|
||||||
|
#Définir l'URL du blob Azure
|
||||||
|
$AzureStore = "AZ_BLOB_URL"
|
||||||
|
|
||||||
|
#Définir le chemin du fichier log
|
||||||
|
$LogFile = "C:\importPST_log.txt"
|
||||||
|
|
||||||
|
#Lancer l'upload vers Azure
|
||||||
|
& .\AzCopy.exe /Source:$PSTFile /Dest:$AzureStore /V:$LogFile /Y
|
45
Exchange Online/audit_mail.ps1
Normal file
45
Exchange Online/audit_mail.ps1
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
param ([PARAMETER(Mandatory = $TRUE, ValueFromPipeline = $FALSE)]
|
||||||
|
[string]$Mailbox,
|
||||||
|
[PARAMETER(Mandatory = $TRUE, ValueFromPipeline = $FALSE)]
|
||||||
|
[string]$StartDate,
|
||||||
|
[PARAMETER(Mandatory = $TRUE, ValueFromPipeline = $FALSE)]
|
||||||
|
[string]$EndDate,
|
||||||
|
[PARAMETER(Mandatory = $FALSE, ValueFromPipeline = $FALSE)]
|
||||||
|
[string]$Subject,
|
||||||
|
[PARAMETER(Mandatory = $False, ValueFromPipeline = $FALSE)]
|
||||||
|
[switch]$IncludeFolderBind,
|
||||||
|
[PARAMETER(Mandatory = $False, ValueFromPipeline = $FALSE)]
|
||||||
|
[switch]$ReturnObject)
|
||||||
|
BEGIN {
|
||||||
|
[string[]]$LogParameters = @('Operation', 'LogonUserDisplayName', 'LastAccessed', 'DestFolderPathName', 'FolderPathName', 'ClientInfoString', 'ClientIPAddress', 'ClientMachineName', 'ClientProcessName', 'ClientVersion', 'LogonType', 'MailboxResolvedOwnerName', 'OperationResult')
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if ($ReturnObject)
|
||||||
|
{ return $SearchResults }
|
||||||
|
elseif ($SearchResults.count -gt 0) {
|
||||||
|
$Date = get-date -Format yyMMdd_HHmmss
|
||||||
|
$OutFileName = "AuditLogResults$Date.csv"
|
||||||
|
write-host
|
||||||
|
write-host -fore green "Posting results to file: $OutfileName"
|
||||||
|
$SearchResults | export-csv $OutFileName -notypeinformation -encoding UTF8 -Delimiter ";"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PROCESS {
|
||||||
|
write-host -fore green 'Searching Mailbox Audit Logs...'
|
||||||
|
$SearchResults = @(search-mailboxAuditLog $Mailbox -StartDate $StartDate -EndDate $EndDate -LogonTypes Owner, Admin, Delegate -ShowDetails -resultsize 50000)
|
||||||
|
write-host -fore green '$($SearchREsults.Count) Total entries Found'
|
||||||
|
if (-not $IncludeFolderBind) {
|
||||||
|
write-host -fore green 'Removing FolderBind operations.'
|
||||||
|
$SearchResults = @($SearchResults | ? { $_.Operation -notlike 'FolderBind' })
|
||||||
|
write-host -fore green 'Filtered to $($SearchREsults.Count) Entries'
|
||||||
|
}
|
||||||
|
$SearchResults = @($SearchResults | select ($LogParameters + @{Name = 'Subject'; e = { if (($_.SourceItems.Count -eq 0) -or ($_.SourceItems.Count -eq $null)) { $_.ItemSubject } else { ($_.SourceItems[0].SourceItemSubject).TrimStart(' ') } } },
|
||||||
|
@{Name = 'CrossMailboxOp'; e = { if (@('SendAs', 'Create', 'Update') -contains $_.Operation) { 'N/A' } else { $_.CrossMailboxOperation } } }))
|
||||||
|
$LogParameters = @('Subject') + $LogParameters + @('CrossMailboxOp')
|
||||||
|
If ($Subject -ne '' -and $Subject -ne $null) {
|
||||||
|
write-host -fore green 'Searching for Subject: $Subject'
|
||||||
|
$SearchResults = @($SearchResults | ? { $_.Subject -match $Subject -or $_.Subject -eq $Subject })
|
||||||
|
write-host -fore green 'Filtered to $($SearchREsults.Count) Entries'
|
||||||
|
}
|
||||||
|
$SearchResults = @($SearchResults | select $LogParameters)
|
||||||
|
}
|
28
Exchange Server/Export-Pst.ps1
Normal file
28
Exchange Server/Export-Pst.ps1
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#Tester sur Exchange Server 2010
|
||||||
|
|
||||||
|
#Atribuer le rôle pour les exports
|
||||||
|
New-ManagementRoleAssignment –Role “Mailbox Import Export” –User AD\Administrator
|
||||||
|
|
||||||
|
#Exporter toutes les boites
|
||||||
|
$Export = Get-Mailbox
|
||||||
|
|
||||||
|
#Exporter un liste de BAL
|
||||||
|
$Export = Get-Content .\Mailbox.txt
|
||||||
|
|
||||||
|
#Lancer les exports vers un dossier partagé
|
||||||
|
$Export | % { $_ | New-MailboxExportRequest -FilePath "\\<server FQDN>\<shared folder name>\$($_.alias).pst" }
|
||||||
|
|
||||||
|
#Vérifier l'état des exports en cours
|
||||||
|
Get-MailboxExportRequest | Get-MailboxExportRequestStatistics
|
||||||
|
|
||||||
|
#Supprimer les export terminés
|
||||||
|
Get-MailboxExportRequest | where { $_.status -eq "Completed" } | Remove-MailboxExportRequest
|
||||||
|
|
||||||
|
#Augmenter le nombre d'erreurs acceptées
|
||||||
|
Get-MailboxExportRequest -Status Failed | Set-MailboxExportRequest -BadItemLimit 500
|
||||||
|
|
||||||
|
#Redémarrer les exports en erreur
|
||||||
|
Get-MailboxExportRequest -Status Failed | Resume-MailboxExportRequest
|
||||||
|
|
||||||
|
#Créer un rapport d'erreurs détaillé
|
||||||
|
Get-MailboxExportRequest -Status Failed | Get-MailboxExportRequestStatistics -IncludeReport | FL > C:\FILEPATH\report.txt
|
1
Exchange Server/README.md
Normal file
1
Exchange Server/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Exchange Server
|
9
Exchange Server/Restart-ExchServices.ps1
Normal file
9
Exchange Server/Restart-ExchServices.ps1
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Obtenir la liste des services Exchange qui sont démarrer
|
||||||
|
|
||||||
|
$services = Get-Service | ? { $_.name -like "MSExchange*" -and $_.Status -eq "Running" }
|
||||||
|
|
||||||
|
# Redémarrer les services
|
||||||
|
|
||||||
|
foreach ($service in $services) {
|
||||||
|
Restart-Service $service.name -Force
|
||||||
|
}
|
1133
Exchange/ExchangeEnvironmentReport.ps1
Normal file
1133
Exchange/ExchangeEnvironmentReport.ps1
Normal file
File diff suppressed because it is too large
Load Diff
1143
Exchange/Get-ExchangeEnvironmentReport.ps1
Normal file
1143
Exchange/Get-ExchangeEnvironmentReport.ps1
Normal file
File diff suppressed because it is too large
Load Diff
2
Exchange/Modification-quota.ps1
Normal file
2
Exchange/Modification-quota.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
Set-mailbox $User.Identity -UseDatabaseQuotaDefaults $true -ProhibitSendReceiveQuota 'Unlimited' -ProhibitSendQuota 'unlimited' -CalendarLoggingQuota 1GB
|
50
Exchange/Rapports-MailBox.ps1
Normal file
50
Exchange/Rapports-MailBox.ps1
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
|
||||||
|
|
||||||
|
$Date = Get-Date -format 'yyyy-MM-dd HH-mm-ss'
|
||||||
|
$Fichier = "D:\Informatique\All-Mailbox-$Date.csv"
|
||||||
|
$emailAttachments = "D:\Informatique\All-Mailbox.csv"
|
||||||
|
|
||||||
|
#Get-Mailbox -ResultSize Unlimited | Select-Object Displayname,name,alias,PrimarySmtpAddress,Database,@{Name='TotalItemSize'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota | where-object {$_.enabled -eq $True} | export-csv -path $Fichier
|
||||||
|
Get-Mailbox -ResultSize Unlimited | Select-Object Displayname,name,alias,PrimarySmtpAddress,Database,@{Name='TotalItemSize'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota | export-csv -path $Fichier
|
||||||
|
|
||||||
|
$SPLA = (Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -like "*.mailnot.fr"} ).Count
|
||||||
|
|
||||||
|
(Get-Content $Fichier) -replace '","','";"' | Set-Content "D:\Informatique\All-Mailbox-temp.csv"
|
||||||
|
(Get-Content "D:\Informatique\All-Mailbox-temp.csv") -replace ',,,',';;;' | Set-Content $emailAttachments
|
||||||
|
|
||||||
|
Start-Sleep -s 10
|
||||||
|
|
||||||
|
$emailSmtpServer = "10.101.10.2"
|
||||||
|
$emailSmtpServerPort = "25"
|
||||||
|
|
||||||
|
$emailFrom = "Rapports@cloud-fichorga.fr"
|
||||||
|
$emailTo = "hcornet@fichorga.fr, ypereira@fichorga.fr, fdupont@fichorga.fr, cleroux@fichorga.fr, jmdefossez@fichorga.fr, alefevre@pmsjuris.fr, sdemarez@fichorga.fr, mdelplanche@fichorga.fr, eringuet@fichorga.fr"
|
||||||
|
|
||||||
|
|
||||||
|
$body = "<HTML><HEAD><META http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" /><TITLE></TITLE></HEAD>"
|
||||||
|
$body += "<BODY bgcolor=""#FFFFFF"" style=""font-size: Small; font-family: TAHOMA; color: #000000""><P>"
|
||||||
|
$body += "Bonjour <b><font color=blue>a tous</b></font><br><br>"
|
||||||
|
$body += "Voici l'extraction de l'ensemble des boites mail client a la date du <b>$Date</b>.<br>"
|
||||||
|
$body += "<br><br>"
|
||||||
|
$body += "Il y a : <b><font color=blue>$SPLA</b></font> comptes à déclarer pour le SPLA.<br>"
|
||||||
|
$body += "<br><br>"
|
||||||
|
$body += "Bonne lecture.<br><br>"
|
||||||
|
$body += "<b><font color=red>Merci de ne pas faire repondre a ce message.</b></font><br>"
|
||||||
|
$body += "Pour ne plus faire partie de la liste <a href='mailto:hcornet@fichorga.fr?Subject=Desinscription%20Rapport%20mail' target='_top'>Send Mail</a>.<br>"
|
||||||
|
|
||||||
|
$emailMessage = New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo )
|
||||||
|
$emailMessage.Subject = "Extraction : client CONNECT"
|
||||||
|
$emailMessage.IsBodyHtml = $True
|
||||||
|
$emailMessage.Body = $body
|
||||||
|
$emailMessage.Attachments.add($emailAttachments)
|
||||||
|
|
||||||
|
$SMTPClient = New-Object System.Net.Mail.SmtpClient( $emailSmtpServer, $emailSmtpServerPort )
|
||||||
|
$SMTPClient.EnableSsl = $False
|
||||||
|
$SMTPClient.Send( $emailMessage )
|
||||||
|
|
||||||
|
Start-Sleep -s 10
|
||||||
|
|
||||||
|
Remove-Item "D:\Informatique\All-Mailbox-$Date.csv" -recurse
|
||||||
|
Remove-Item "D:\Informatique\All-Mailbox-temp.csv" -recurse
|
||||||
|
Remove-Item "D:\Informatique\All-Mailbox.csv" -recurse
|
||||||
|
|
2157
Exchange/Test-ExchangeServerHealth.ps1
Normal file
2157
Exchange/Test-ExchangeServerHealth.ps1
Normal file
File diff suppressed because it is too large
Load Diff
2
Exchange/gestion calendrier/ajout-de-droit.ps1
Normal file
2
Exchange/gestion calendrier/ajout-de-droit.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
Add-MailboxFolderPermission -Identity BAL@DOMAINE:\calendrier -AccessRights Editor -user <USER>
|
2
Exchange/gestion calendrier/retirer-de-droit.ps1
Normal file
2
Exchange/gestion calendrier/retirer-de-droit.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
Remove-MailboxFolderPermission -Identity BAL@DOMAINE:\calendrier -user <USER>
|
2
Exchange/message-absence.ps1
Normal file
2
Exchange/message-absence.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
Set-MailboxAutoReplyConfiguration <USER> -AutoReplyState enabled -ExternalAudience all -InternalMessage "MESSAGE" –ExternalMessage "MESSAGE"
|
1
Exchange/purge.ps1
Normal file
1
Exchange/purge.ps1
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Get-ChildItem 'C:\Inetpub\Logs' -Directory | Get-ChildItem -Include '*.log' -Recurse | ? LastWriteTime -lt (Get-Date).AddDays(-20) | Remove-Item
|
5
Exchange/remote-authentification.ps1
Normal file
5
Exchange/remote-authentification.ps1
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
$sessionOption = New-PsSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
|
||||||
|
$credential = $host.ui.PromptForCredential("Connexion Exchange 2013", "Merci de renseigner votre compte.","DOMAINE\UTILISATEUR","NetBiosUserName")
|
||||||
|
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://DOMAINE/powershell" -Credential $Credential -Authentication kerberos
|
||||||
|
Import-PSSession $session
|
4
Exchange/scheduler.ps1
Normal file
4
Exchange/scheduler.ps1
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.\ExchangeEnvironmentReport.ps1 -HTMLReport .\report.html -SendMail $True -MailFrom "Rapports@cloud-fichorga.fr" -MailTo "hcornet@fichorga.fr" -MailServer 10.101.10.2
|
||||||
|
.\ExchangeEnvironmentReport.ps1 -HTMLReport .\report.html -SendMail $True -MailFrom "Rapports@cloud-fichorga.fr" -MailTo "jmdefossez@fichorga.fr" -MailServer 10.101.10.2
|
||||||
|
.\ExchangeEnvironmentReport.ps1 -HTMLReport .\report.html -SendMail $True -MailFrom "Rapports@cloud-fichorga.fr" -MailTo "alefevre@pmsjuris.fr" -MailServer 10.101.10.2
|
||||||
|
.\Test-ExchangeServerHealth.ps1 -ReportMode -SendEmail
|
110
Exchange/status-backup.ps1
Normal file
110
Exchange/status-backup.ps1
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
|
||||||
|
param($action) # paramètre à scpécifier lors de l'appel
|
||||||
|
|
||||||
|
$Run_Path=Split-Path -parent $MyInvocation.MyCommand.Definition
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$resultlog="$Run_Path\Checkbackup.log"
|
||||||
|
|
||||||
|
<# Log
|
||||||
|
------------------------------------------------
|
||||||
|
Usage : Utilisé pour logger
|
||||||
|
$data : Informations à logger
|
||||||
|
$new : A préciser pour démarrer un nouveau log.
|
||||||
|
#>
|
||||||
|
Function Log ($data,$new) {
|
||||||
|
If ($new) {
|
||||||
|
write-output "$data" | Out-File $resultlog
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
write-output "$data" | Out-File $resultlog -Append
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log "################# START ###############" $true
|
||||||
|
Try {
|
||||||
|
add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$global:ErrorCopy=@();$global:ErrorFull=@();$global:ErrorIncr=@()
|
||||||
|
|
||||||
|
$listdb=Get-MailboxDatabase -Status | select name, Server, LastFullBackup, LastIncrementalBackup, LastCopyBackup
|
||||||
|
Foreach ($db in $listdb) {
|
||||||
|
#Log $db
|
||||||
|
If(! $db.Name.Contains("Mailbox")) {
|
||||||
|
Switch ($action) {
|
||||||
|
"COPY" {
|
||||||
|
If (! $db.LastCopyBackup) {
|
||||||
|
$global:ErrorIncr+=$db.Name
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
If (($(Get-Date) - $db.LastCopyBackup).TotalMinutes -gt 35) {
|
||||||
|
$global:ErrorCopy+=$db.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"FULL" {
|
||||||
|
If (! $db.LastFullBackup) {
|
||||||
|
$global:ErrorIncr+=$db.Name
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
If (($(Get-Date) - $db.LastFullBackup).TotalDays -gt 7) {
|
||||||
|
$global:ErrorFull+=$db.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"INC" {
|
||||||
|
If (! $db.LastIncrementalBackup) {
|
||||||
|
If (! $db.LastFullBackup) {
|
||||||
|
$global:ErrorIncr+=$db.Name
|
||||||
|
}
|
||||||
|
Elseif(($(Get-Date) - $db.LastFullBackup).TotalDays -gt 1) {
|
||||||
|
$global:ErrorIncr+=$db.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Elseif(($(Get-Date) - $db.LastIncrementalBackup).TotalDays -gt 1) {
|
||||||
|
If (! $db.LastFullBackup)
|
||||||
|
{
|
||||||
|
$global:ErrorIncr+=$db.Name
|
||||||
|
}
|
||||||
|
Elseif(($(Get-Date) - $db.LastFullBackup).TotalDays -gt 1) {
|
||||||
|
$global:ErrorIncr+=$db.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($ErrorCopy.count -gt 0) {
|
||||||
|
$string="Error on "
|
||||||
|
$ErrorCopy=$ErrorCopy | sort
|
||||||
|
Foreach ($dbname in $ErrorCopy) {
|
||||||
|
$string+=$dbname+","
|
||||||
|
}
|
||||||
|
$string+=" during CopyBackup(Appsync)"
|
||||||
|
Log $string;$string;exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($ErrorFull.count -gt 0) {
|
||||||
|
$string="Error on "
|
||||||
|
$ErrorFull=$ErrorFull | sort
|
||||||
|
Foreach ($dbname in $ErrorFull) {
|
||||||
|
$string+=$dbname+","
|
||||||
|
}
|
||||||
|
$string+=" during FullBackup(TSM)"
|
||||||
|
Log $string;$string;exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($ErrorIncr.count -gt 0) {
|
||||||
|
$string="Error on "
|
||||||
|
$ErrorIncr=$ErrorIncr | sort
|
||||||
|
Foreach ($dbname in $ErrorIncr) {
|
||||||
|
$string+=$dbname+","
|
||||||
|
}
|
||||||
|
$string+=" during IncBackup(TSM)"
|
||||||
|
Log $string;$string;exit 2
|
||||||
|
}
|
||||||
|
Log "################## END ####################"
|
2
Exchange/status-sync.ps1
Normal file
2
Exchange/status-sync.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
Get-ExchangeServer | Where-Object {$_.IsHubTransportServer -eq $True} | Get-Queue | ft Identity, NextHopDomain, MessageCount
|
2
Exchange/visualiser-message-absence.ps1
Normal file
2
Exchange/visualiser-message-absence.ps1
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
Get-MailboxAutoReplyConfiguration <USER>
|
93
Exemples/Affichage-Calendrier.ps1
Normal file
93
Exemples/Affichage-Calendrier.ps1
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version: 1.0
|
||||||
|
Author: Hubert CORNET
|
||||||
|
Creation Date: <Date>
|
||||||
|
Purpose/Change: Initial script development
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
cls
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Bibliothèques de fonctions requises
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "<script_name>.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[]------------------------------------------------------------
|
||||||
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
|
Add-Type -AssemblyName System.Drawing
|
||||||
|
|
||||||
|
$form = New-Object Windows.Forms.Form -Property @{
|
||||||
|
StartPosition = [Windows.Forms.FormStartPosition]::CenterScreen
|
||||||
|
Size = New-Object Drawing.Size 280, 285
|
||||||
|
Text = 'Selection Date'
|
||||||
|
Topmost = $true
|
||||||
|
MaximizeBox = $false
|
||||||
|
MinimumSize = New-Object System.Drawing.Size(280,285)
|
||||||
|
MaximumSize = New-Object System.Drawing.Size(280,285)
|
||||||
|
ControlBox = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
$calendar = New-Object Windows.Forms.MonthCalendar -Property @{
|
||||||
|
ShowTodayCircle = $True
|
||||||
|
MaxSelectionCount = 1
|
||||||
|
}
|
||||||
|
$form.Controls.Add($calendar)
|
||||||
|
|
||||||
|
$okButton = New-Object Windows.Forms.Button -Property @{
|
||||||
|
Location = New-Object Drawing.Point 10, 210
|
||||||
|
Size = New-Object Drawing.Size 75, 23
|
||||||
|
Text = 'OK'
|
||||||
|
DialogResult = [Windows.Forms.DialogResult]::OK
|
||||||
|
}
|
||||||
|
$form.AcceptButton = $okButton
|
||||||
|
$form.Controls.Add($okButton)
|
||||||
|
|
||||||
|
$cancelButton = New-Object Windows.Forms.Button -Property @{
|
||||||
|
Location = New-Object Drawing.Point 180, 210
|
||||||
|
Size = New-Object Drawing.Size 75, 23
|
||||||
|
Text = 'Cancel'
|
||||||
|
DialogResult = [Windows.Forms.DialogResult]::Cancel
|
||||||
|
}
|
||||||
|
$form.CancelButton = $cancelButton
|
||||||
|
$form.Controls.Add($cancelButton)
|
||||||
|
|
||||||
|
$result = $form.ShowDialog()
|
||||||
|
|
||||||
|
If ($result -eq [Windows.Forms.DialogResult]::OK) {
|
||||||
|
$date = $calendar.SelectionStart
|
||||||
|
Write-Host "Date selected: $($date.ToShortDateString())"
|
||||||
|
}
|
55
Exemples/Creation-Multi-Fichier.ps1
Normal file
55
Exemples/Creation-Multi-Fichier.ps1
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : 22/11/2022
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Bibliothèques de fonctions requises
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "Creation-Multi-Fichier.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
Start-Transcript -Path $sLogFile -NoClobber
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------------------------------------------[Debut Du Script]---------------------------------------------------------
|
||||||
|
|
||||||
|
1..100 | %{ ($_ * (Get-Random -Max ([int]::maxvalue))) > "D:\script\file$_.txt"}
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Fin Du Script]----------------------------------------------------------
|
||||||
|
|
||||||
|
Stop-Transcript
|
195
Exemples/Dichotomie.ps1
Normal file
195
Exemples/Dichotomie.ps1
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : <Date>
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Position=0,Mandatory=$True)]
|
||||||
|
[string]$CheminSource,
|
||||||
|
[Parameter(Position=1,Mandatory=$True)]
|
||||||
|
[string]$Pattern,
|
||||||
|
[Parameter(Position=2,Mandatory=$True)]
|
||||||
|
[int]$Pourcentage
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "Dichotomie.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
Start-Transcript -Path $sLogFile -NoClobber
|
||||||
|
|
||||||
|
$Date = Get-Date -Format "yyyyMMdd HHmm"
|
||||||
|
$FolderBackup = $CheminSource+"\Backup - "+$Date
|
||||||
|
$FolderLotA = $CheminSource+"\Lot-A"
|
||||||
|
$FolderLotB = $CheminSource+"\Lot-B"
|
||||||
|
$FolderLock = $CheminSource+"\Fichier Bloquant - "+$Date
|
||||||
|
$Compteur = 0
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
Function Login-RestApi {
|
||||||
|
[cmdletbinding()]
|
||||||
|
param(
|
||||||
|
[string] $ApiUrl,
|
||||||
|
[string] $OpConUser,
|
||||||
|
[string] $OpConPassword
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Verbose ("Parameters =")
|
||||||
|
Write-Verbose ("ApiUrl: " + $ApiUrl)
|
||||||
|
Write-Verbose ("OpConUser: " + $OpConUser)
|
||||||
|
Write-Verbose ("OpConPassword: (hidden)")
|
||||||
|
|
||||||
|
$ApiUrl = $ApiUrl.ToLower().TrimEnd("/").TrimEnd("/api")
|
||||||
|
|
||||||
|
Write-Host ("Logging in to OpCon REST API: " + $ApiUrl)
|
||||||
|
|
||||||
|
$Global:OpconRESTApiUrl = $ApiUrl
|
||||||
|
$Global:OpconRESTApiUser = $OpConUser
|
||||||
|
$Global:OpConRESTApiPassword = $OpConPassword
|
||||||
|
$token = Get-OpConApiToken -Url $ApiUrl -User $OpConUser -Password $OpConPassword
|
||||||
|
$Global:OpconRESTApiToken = $token.id
|
||||||
|
|
||||||
|
$Global:OpconRESTApiAuthHeader = Get-OpConApiAuthHeader -Token $token.id
|
||||||
|
Write-Host ('Token successfully stored for future calls in session.')
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Ignore-SelfSignedCerts {
|
||||||
|
add-type -TypeDefinition @"
|
||||||
|
using System.Net;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
public class TrustAllCertsPolicy : ICertificatePolicy {
|
||||||
|
public bool CheckValidationResult(
|
||||||
|
ServicePoint srvPoint, X509Certificate certificate,
|
||||||
|
WebRequest request, int certificateProblem) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-OpConApiToken {
|
||||||
|
[cmdletbinding()]
|
||||||
|
param(
|
||||||
|
[string] $Url,
|
||||||
|
[string] $User,
|
||||||
|
[string] $Password
|
||||||
|
)
|
||||||
|
$tokensUri = -join($Url, "/api/tokens")
|
||||||
|
Write-Host ("Retrieving authorization token...")
|
||||||
|
Write-Host ("Uri: " + $tokensUri)
|
||||||
|
Write-Host ("User: " + $User)
|
||||||
|
$tokenObject = @{
|
||||||
|
user = @{
|
||||||
|
loginName = $User
|
||||||
|
password = $Password
|
||||||
|
}
|
||||||
|
tokenType = @{
|
||||||
|
type = "User"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Ignore-SelfSignedCerts
|
||||||
|
#$token = Invoke-RestMethod -Method Post -Uri $tokensUri -Body (ConvertTo-Json $tokenObject) -ContentType 'application/json; charset=utf-8' -ErrorVariable $RestException -SkipCertificateCheck
|
||||||
|
$token = Invoke-RestMethod -Method Post -Uri $tokensUri -Body (ConvertTo-Json $tokenObject) -ContentType 'application/json; charset=utf-8' -ErrorVariable $RestException
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
## $error = ConvertFrom-Json $RestException.ErrorDetails.Message
|
||||||
|
##Write-Host ("Unable to fetch token for user '" + $user + "'")
|
||||||
|
##Write-Host ("Error Code: " + $error.code)
|
||||||
|
##Write-Host ("Message: " + $error.message)
|
||||||
|
Write-Host ("StatusCode: " + $_.Exception.Response.StatusCode.value__)
|
||||||
|
Write-Host ("StatusDescription: " + $_.Exception.Response.StatusDescription)
|
||||||
|
Write-Host ("Message: " + $_[0].message)
|
||||||
|
##$Global:OpConRESTAPIException = $_
|
||||||
|
throw
|
||||||
|
##exit $_.Exception.Response.StatusCode.value__
|
||||||
|
}
|
||||||
|
Write-Host ("Token retrieved successfully, Id: " + $token.id + ", Valid Until: " + $token.validUntil)
|
||||||
|
return $token
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-OpConApiAuthHeader {
|
||||||
|
Param(
|
||||||
|
[string] $Token
|
||||||
|
)
|
||||||
|
|
||||||
|
$authHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
|
||||||
|
$authHeader.Add("Authorization", ("Token " + $Token))
|
||||||
|
|
||||||
|
return $authHeader
|
||||||
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------[Debut Du Script]---------------------------------------------------------
|
||||||
|
|
||||||
|
Login-RestApi -ApiUrl $ServerUrl -OpConUser $OpConUser -OpConPassword $clearPassword
|
||||||
|
|
||||||
|
#Nombre de fichier présent dans le répertoire
|
||||||
|
$ListFile = Get-ChildItem -Path $CheminSource"\*" -Include "*.$Pattern" | Select Name,FullName
|
||||||
|
$FileCount = $ListFile.count
|
||||||
|
|
||||||
|
$PourcentageFichier = (($Pourcentage/100)*$FileCount)
|
||||||
|
$PourcentageFichier = [math]::floor($PourcentageFichier)
|
||||||
|
|
||||||
|
If (!(Test-Path $FolderBackup)) {
|
||||||
|
New-Item -Path $FolderBackup -ItemType Directory
|
||||||
|
New-Item -Path $FolderLotA -ItemType Directory
|
||||||
|
New-Item -Path $FolderLotB -ItemType Directory
|
||||||
|
New-Item -Path $FolderLock -ItemType Directory
|
||||||
|
}
|
||||||
|
|
||||||
|
Foreach ($File in $ListFile) {
|
||||||
|
Copy-Item $File.FullName -Destination $FolderBackup
|
||||||
|
|
||||||
|
If ($Compteur -le $PourcentageFichier) {
|
||||||
|
Move-Item $File.FullName -Destination $FolderLotA
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Move-Item $File.FullName -Destination $FolderLotB
|
||||||
|
}
|
||||||
|
|
||||||
|
$Compteur = $Compteur + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Fin Du Script]----------------------------------------------------------
|
||||||
|
|
||||||
|
Stop-Transcript
|
14
Exemples/Envoie-Mail.ps1
Normal file
14
Exemples/Envoie-Mail.ps1
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
$Destinataires = "hubert.cornet-ext@saint-maclou.com","thedjinhn@gmail.com"
|
||||||
|
[string[]]$To = $Destinataires.Split(',')
|
||||||
|
$From = "POWERSHELL@saint-maclou.com"
|
||||||
|
$Subject = "Exemple 3"
|
||||||
|
$BODY = "Some important plain text!"
|
||||||
|
$SmtpServer = "RELAISSMTP.FR.DGS.GROUP"
|
||||||
|
$Port = "25"
|
||||||
|
$Attachments = ""
|
||||||
|
$Bcc = ""
|
||||||
|
$Cc = ""
|
||||||
|
$Encoding = ""
|
||||||
|
$Priority = "Normal"
|
||||||
|
|
||||||
|
Send-MailMessage -To $To -From $From -Subject $Subject -Body $BODY -SmtpServer $SmtpServer -Port $Port -BodyAsHtml -Priority $Priority #-Bcc $Bcc -Cc $Cc -Encoding $Encoding -Attachments $Attachments
|
431
Exemples/Fichier multiple/Liste-import.csv
Normal file
431
Exemples/Fichier multiple/Liste-import.csv
Normal file
@@ -0,0 +1,431 @@
|
|||||||
|
objet;marque;modele;serial;autre
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2268700985;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2268500899;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2258801771;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2258600994;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2259401255;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2259600645;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2268600239;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515F;K2259101182;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515MF;K2169008365;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;1515MF;K2168907266;P.1/2
|
||||||
|
IMPRIMANTE;RICOH;MP201SPF;W3029500722;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP201SPF;W3038800967;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP201SPF;W3029502690;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP201SPF;W3029502959;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP201SPF;W3029303536;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP171SPF;V4489601154;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP171SPF;V4498501045;P.3
|
||||||
|
IMPRIMANTE;RICOH;MP171SPF;V4498500895;P.3
|
||||||
|
IMPRIMANTE;RICOH;MPC407SPF;C499P700786;P.5
|
||||||
|
IMPRIMANTE;RICOH;MPC407SPF;C499P700804;P.5
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB36;A0ED94360;P.6
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB36;A0ED94360;P.6
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;;A32R022015985;P.3
|
||||||
|
UC;DELL;DCNE;9L4JJ3J;P.16
|
||||||
|
UC;DELL;DCNE;FL4JJ3J;P.16
|
||||||
|
UC;DELL;DCNE;20WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;57WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;BST434J;P.16
|
||||||
|
UC;DELL;DCNE;G25VL4J;P.16
|
||||||
|
UC;DELL;DCNE;D4WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;DZVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;C5WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;GYVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;25WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;CZVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;50WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;5YVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;G3WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;J0WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;67WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;24WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;DL4JJ3J;P.16
|
||||||
|
UC;DELL;DCNE;72WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;G2WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;82WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;7ZVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;94WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;31WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;70WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;41WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;G1WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;60WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;HZVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;G0WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;84WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;J4WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;F6WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;92WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;FYVJ94J;P.16
|
||||||
|
UC;DELL;DCNE;37WJ94J;P.16
|
||||||
|
UC;DELL;DCNE;60DGX3J;P.16
|
||||||
|
UC;DELL;DHS;H32GV1J;P.16
|
||||||
|
UC;DELL;DHS;3WNWR0J;P.16
|
||||||
|
UC;DELL;DHS;7GBBG1J;P.16
|
||||||
|
UC;DELL;DHS;7LXMS1J;P.16
|
||||||
|
UC;DELL;DHS;8LM5S0J;P.16
|
||||||
|
UC;DELL;DHS;?;P.16
|
||||||
|
UC;DELL;DHP;4HCSQ1J;P.16
|
||||||
|
UC;DELL;DHP;JPYKF1J;P.16
|
||||||
|
UC;DELL;DHP;J569K1J;P.16
|
||||||
|
UC;DELL;DCSM;GXVXG4J;P.16
|
||||||
|
UC;DELL;DCSM;JXVXG4J;P.16
|
||||||
|
UC;DELL;DCSM;3YVXG4J;P.16
|
||||||
|
UC;DELL;DCCY;6YKF32J;P.16
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013846;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013808;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021019527;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021019525;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013799;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013837;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013794;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013821;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021019536;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013743;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021019473;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021019535;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013839;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021019538;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021013830;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;451433LM12LD3;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;451433LM12LC2;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;451433LM11C1;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;A63P021022185;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 20P;A32P021024680;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 20P;A32P021024664;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 20P;A32P021024678;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 20P;A32P021024682;P.7/8
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 20P;A32P021024676;P.7/8
|
||||||
|
IMPRIMANTE;EPSON;AL-M200DN;RVCZ104482;P.7/8
|
||||||
|
IMPRIMANTE;EPSON;AL-M200DN;RVCZ104679;P.7/8
|
||||||
|
IMPRIMANTE;EPSON;AL-M200DN;RVCZ102517;P.7/8
|
||||||
|
IMPRIMANTE;EPSON;AL-M200DN;RVCZ104680;P.7/8
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0UJ532;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0MX028;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0MX028;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0MX028;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0MX028;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0MX028;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0MX028;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M6CFG;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M6CFG;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M6CFG;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M6CFG;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M6CFG;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M6CFG;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0R511D;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0R511D;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0R511D;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;DP4733;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;DP4733;P.9
|
||||||
|
IMPRIMANTE;DELL;LASER PRINTER 1720DN;0M9834;P.9
|
||||||
|
IMPRIMANTE;C352A;;LEVY159613;P.9
|
||||||
|
IMPRIMANTE;PRINTRONIX;P7210;6R07120114;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;PRINTRONIX;P7210;6RV608150016;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB36;A45X02100P006;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB36;A45X021008070;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;RICOH;MPC2050;V2294502701;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;RICOH;1027;K2259600645;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;RICOH;MP2550;M6584000997;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;RICOH;MPC3500;L8974200939;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;RICOH;3025;K8563804891;FOND ENTREP<45>T
|
||||||
|
IMPRIMANTE;RICOH;MPC5000;V1303000756;FOND ENTREP<45>T
|
||||||
|
SERVEUR;EMS01;;2PK2T3J;P.10/11
|
||||||
|
SERVEUR;EMS01;;1NG73TJ;P.10/11
|
||||||
|
SERVEUR;EMS01;;3PK2T3J;P.10/11
|
||||||
|
SERVEUR;3573;;xSB2008SD;P.10/11
|
||||||
|
SERVEUR;JPE-i;;CF2NV075200123;P.10/11
|
||||||
|
SERVEUR;B2G;;KD7N908;P.10/11
|
||||||
|
SERVEUR;EMC;;AC979094950279;P.10/11
|
||||||
|
SERVEUR;7945L4G;;K45GTT;P.10/11
|
||||||
|
SERVEUR;TL2000;;H79851F;P.10/11
|
||||||
|
SERVEUR;7945L4G;;KD45FYH;P.10/11
|
||||||
|
UC;SCL;;5LPDM0J;P.10/11
|
||||||
|
UC;SCL;;6LPDM0J;P.10/11
|
||||||
|
UC;SCL;;1Y6W21J;P.10/11
|
||||||
|
UC;ECM;;FFWJF2J;P.10/11
|
||||||
|
UC;ECM;;1222904;P.10/11
|
||||||
|
UC;ECM;;CZT5F1J;P.10/11
|
||||||
|
UC;ECM;;GYG9B1J;P.10/11
|
||||||
|
IMPRIM. ENTREPOT;B-472-QP;;1N310342;P.10/11
|
||||||
|
IMPRIM. ENTREPOT;B-672-QP;;28015220298;P.10/11
|
||||||
|
IMPRIM. ENTREPOT;B-672-QP;;2801522285;P.10/11
|
||||||
|
IMPRIMANTE;LEXMARK;MS421DN;S460083510CV0M;P.4
|
||||||
|
IMPRIMANTE;LEXMARK;MS421DN;S460083510CT73;P.4
|
||||||
|
IMPRIMANTE;LEXMARK;MS421DN;S460083510CV11;P.4
|
||||||
|
UC;DELL;OPTIPLEX 7010;7QDKJ32;P.17
|
||||||
|
UC;DELL;OPTIPLEX 360;1,44561E+11;?
|
||||||
|
IMPRIMANTE;LEXMARK;7017-476;S701793530FNMX;P.4
|
||||||
|
IMPRIMANTE;LEXMARK;MS421DN;S701793530FNBW;P.4
|
||||||
|
UC;DELL;OPTIPLEX 3020;JBH4952;P.18
|
||||||
|
UC;DELL;OPTIPLEX 3020;D9H4952;P.18
|
||||||
|
UC;DELL;OPTIPLEX 3020;CTWFZ72;P.18
|
||||||
|
UC;DELL;D11S;H1YCGM2;P.17
|
||||||
|
UC;DELL;D11S;7JGSV22;P.17
|
||||||
|
IMPRIMANTE;DELL;;G7QJR0J;
|
||||||
|
UC;DELL;OPTIPLEX 3060;TPV1824Z;
|
||||||
|
UC;DELL;OPTIPLEX 3060;TPV1824X;
|
||||||
|
UC;HP;;CZC310320M;
|
||||||
|
UC;HP;;CZC4124DPG;
|
||||||
|
UC;HP;;CZC4162WNV;
|
||||||
|
UC;HP;;CZC4124DPR;
|
||||||
|
ECRAN;FUJITSU - W2112;W2112;YV8T028676;P.18
|
||||||
|
ECRAN;FUJITSU - L22T-2;L22T-2;YV7Q006974;P.18
|
||||||
|
ECRAN;FUJITSU - W2112;W2112;YV8T028265;P.18
|
||||||
|
ECRAN;FUJITSU;;YV5F216107;P.18
|
||||||
|
ECRAN;FUJITSU;;YV5F216068;P.18
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G2QA002736;P.17
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63GAQA010890;P.17
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G2QA002667;P.17
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63GBQA014401;P.17
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G8QA001019;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005133;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005159;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005137;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005179;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005147;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005132;P.17
|
||||||
|
ECRAN;AOC - 215LM0041;215LM0041;GFRGBHA005146;P.17
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA002177;P.17
|
||||||
|
ECRAN;DELL;;CN-044FGY-72872-44J-C8YM;P.18
|
||||||
|
ECRAN;DELL;;CN-0PD06D-72872-4AH-C3CM;P.18
|
||||||
|
ECRAN;DELL;;CN-0PD06D-72872-4AH-C0WM;P.18
|
||||||
|
ECRAN;DELL;;CN-0C2XM8-74445-22L-526L;P.18
|
||||||
|
ECRAN;DELL;;CN-029C29-74261-58D-1NDS;P.18
|
||||||
|
ECRAN;LG - 22M37A;22M37A;S04NTQD10436;P.18
|
||||||
|
ECRAN;LG - 22M37A;22M37A;S04NTYT10458;P.18
|
||||||
|
ECRAN;LG - 22M37A;22M37A;S04NTLE10464;P.18
|
||||||
|
ECRAN;LG - 22M37A;22M37A;S04NTEP10420;P.18
|
||||||
|
ECRAN;HANNS.G - HC174D;HC174D;646DK3NA01059;P.18
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1810490320C4306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181049032264306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1810490329D4306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181049032864306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181049032184306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181049032A84306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181049032174306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1810490321B4306;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181107082704309;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181107082714309;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1811070827F4309;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1811070827D4309;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1811070826A4309;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181107081C34309;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLBP0C186051266ED40G0;P.19
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLBP0C186051269BD40G0;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB888500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420A3D18500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB758500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420A8098500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420A8188500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB8A8500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB168500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB768500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB7C8500;P.19
|
||||||
|
ECRAN;ACER - V193WD;V193WD;ETLHV0D0929420AB798500;P.19
|
||||||
|
ECRAN;ACER - V226HQL;V226HQL;MMLY7EE0164480746D8513;
|
||||||
|
ECRAN;ACER - V226HQL;V226HQL;MMLY7EE016448074DB8513;
|
||||||
|
ECRAN;ACER - V193HQV;V193HQV;ETLKX0W020224028F84300;P.19
|
||||||
|
ECRAN;ACER - V193HQV;V193HQV;ETLKX0W020224028DC4300;P.19
|
||||||
|
ECRAN;ACER - V193HQV;V193HQV;ETLKX0W020224029024300;P.19
|
||||||
|
ECRAN;ACER - V173;V173;ETLCA02018823045894111;P.19
|
||||||
|
ECRAN;ACER - V196WL;V196WL;MMLXWEE005311068338530;P.19
|
||||||
|
ECRAN;ACER - V196WL;V196WL;MMLXWEE005311069888530;P.19
|
||||||
|
ECRAN;ACER - V196WL;V196WL;MMLXWEE0053110694E8530;P.19
|
||||||
|
IMPRIMANTE;KYOCERA - FS-2100DN;FS-2100DN;V1N5789691;P.4
|
||||||
|
UC;DELL - D07D001;D07D001;;P.18
|
||||||
|
UC;DELL - D07D001;D07D001;;P.18
|
||||||
|
UC;DELL - D07D001;D07D001;;P.18
|
||||||
|
UC;DELL - D07D001;D07D001;;P.18
|
||||||
|
UC;DELL - D07D001;D07D001;;P.18
|
||||||
|
UC;DELL - D07D001;D07D001;;P.18
|
||||||
|
UC;HP;;CZC4124DPR;P.17
|
||||||
|
UC;HP;;CZC4124DV5;P.17
|
||||||
|
UC;HP;;CZC4124DQW;P.17
|
||||||
|
UC;HP;;CZC4124DQC;P.17
|
||||||
|
UC;HP;;CZC4162WP7;P.17
|
||||||
|
UC;HP;;CZC4162WP0;P.17
|
||||||
|
UC;HP;;CZC4162WMT;P.17
|
||||||
|
UC;HP;;CZC4140VRT;P.17
|
||||||
|
IMPRIMANTE;MS410DN;MS410DN;S451445LM1YDNK;P.4
|
||||||
|
IMPRIMANTE;MS410DN;MS410DN;S451445LM206BF;P.4
|
||||||
|
IMPRIMANTE;MS410DN;MS410DN;S451445LM20696;P.4
|
||||||
|
IMPRIMANTE;;;S451445L1YDVL;P.4
|
||||||
|
IMPRIMANTE;;;S451445L1YDMW;P.4
|
||||||
|
IMPRIMANTE;;;S451445LM1F094;P.4
|
||||||
|
IMPRIMANTE;;;S451445LM1YDGB;P.4
|
||||||
|
IMPRIMANTE;;;S451445LM1Z5HP;P.4
|
||||||
|
IMPRIMANTE;- MS415DN;MS415DN;S451445LM1YDZ;P.4
|
||||||
|
IMPRIMANTE;DELL - 0MX028;0MX028;;P.4
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86217E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86275E+11;P.15
|
||||||
|
UC;DELL;;1KGSV22;P.15
|
||||||
|
UC;DELL;;4KGSV22;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86275E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;DELL;;1,86177E+11;P.15
|
||||||
|
UC;HP;;CZC310320Q;P.15
|
||||||
|
UC;HP;;CZC3360BQD;P.15
|
||||||
|
UC;HP;;CZC242CW3Z;P.15
|
||||||
|
UC;HP;;CZC310320W;P.15
|
||||||
|
UC;HP;;CZC3360BQH;P.15
|
||||||
|
UC;HP;;CZC3360BQM;P.15
|
||||||
|
UC;HP;;CZC310320T;P.15
|
||||||
|
UC;HP;;CZC3360BQJ;P.15
|
||||||
|
UC;HP;;CZC310320P;P.15
|
||||||
|
UC;HP;;CZC4162WMW;P.15
|
||||||
|
UC;HP;;CZC4162WPB;P.15
|
||||||
|
UC;HP;;CZC4162WNL;P.15
|
||||||
|
UC;HP;;CZC3360BQB;P.15
|
||||||
|
UC;HP;;CZC310320N;P.15
|
||||||
|
UC;HP;;CZC3360BQK;P.15
|
||||||
|
UC;HP;;CZC310320V;P.15
|
||||||
|
IMPRIMANTE;LEXMARK MS410DN;MS410DN;S451445LM1Z5VY;P.4
|
||||||
|
IMPRIMANTE;LEXMARK MS410DN;MS410DN;S451445LM1YDV8;P.4
|
||||||
|
IMPRIMANTE;LEXMARK MS410DN;MS410DN;S451444LM1F0CB;P.4
|
||||||
|
IMPRIMANTE;LEXMARK MS410DN;MS410DN;S451444LM1F095;P.4
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;S451443LM185KL;P.4
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;S451445LM1Z638;P.4
|
||||||
|
IMPRIMANTE;KONICA MINOLTA;BIZHUB 3300P;S451445LM206CC;P.4
|
||||||
|
IMPRIMANTE;KONICA MINOLTA - BIZHUB 3300P;BIZHUB 3300P;S451444LM1F06F;P.4
|
||||||
|
IMPRIMANTE;MS421DW;MS421DW;S46009323104XX;P.4
|
||||||
|
IMPRIMANTE;MS421DW;MS421DW;S46009323105LV;P.4
|
||||||
|
SWITCH;TP LINK;TL-SF1008P;10B64901046;CAGE
|
||||||
|
SWITCH;TP LINK;TL-SF1008P;13175202775;CAGE
|
||||||
|
SWITCH;TP LINK;TL-SF1008P;13175202783;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;11B95800510;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;9983300925;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;11B95800501;CAGE
|
||||||
|
SWITCH;TP LINK;TL-SF1008P;11370200527;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;13168801655;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;13175202855;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;9975800770;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;13175202784;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;11B95800295;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;9983300890;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;9975800767;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;10B64901052;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;9983300941;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;13175202777;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;9975800719;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;11264301877;CAGE
|
||||||
|
SWITCH;TP LINK - TL-SF1008P;TL-SF1008P;11264301274;CAGE
|
||||||
|
SWITCH;SMC - EZ108DT;EZ108DT;T184601903;CAGE
|
||||||
|
SWITCH;SMC - EZ108DT;EZ108DT;T162516018;CAGE
|
||||||
|
SWITCH;SMC - EZ108DT;EZ108DT;T185002057;CAGE
|
||||||
|
SWITCH;SMC - EZ108DT;EZ108DT;T185002013;CAGE
|
||||||
|
SWITCH;SMC - EZ108DT;EZ108DT;T142201396;CAGE
|
||||||
|
SWITCH;SMC - EZ108DT;EZ108DT;T134706296;CAGE
|
||||||
|
SWITCH;ATI - FS708;FS708;L1E44153B;CAGE
|
||||||
|
SWITCH;ATI - FS708;FS708;L0EZ4018B;CAGE
|
||||||
|
SWITCH;ATI - FS708;FS708;L0KV4018B;CAGE
|
||||||
|
SWITCH;ATI - FS708;FS708;L0FD4018B;CAGE
|
||||||
|
SWITCH;MOTOROLA - PD3001/AC;PD3001/AC;SR10136050012326701;CAGE
|
||||||
|
SWITCH;MOTOROLA - PD3001/AC;PD3001/AC;SR08526050058512401;CAGE
|
||||||
|
SWITCH;MOTOROLA - PD3001/AC;PD3001/AC;SR11016050001140001;CAGE
|
||||||
|
SWITCH;DACOMEX;;?;CAGE
|
||||||
|
SWITCH;SMC - SMCGS8;SMCGS8;N11027006616;CAGE
|
||||||
|
SWITCH;DEXLAN - EW-408R;EW-408R;53124800628;CAGE
|
||||||
|
SWITCH;TP-LINK - TL-SF1016D;TL-SF1016D;2,14705E+12;CAGE
|
||||||
|
SWITCH;TP-LINK - TL-SF1016D;TL-SF1016D;2,14752E+12;CAGE
|
||||||
|
SWITCH;TP-LINK - TL-SF1016D;TL-SF1016D;2,14752E+12;CAGE
|
||||||
|
SWITCH;TP-LINK - TL-SF1016D;TL-SF1016D;2,14752E+12;CAGE
|
||||||
|
SWITCH;TP-LINK - TL-SF1016D;TL-SF1016D;2,14668E+12;CAGE
|
||||||
|
SWITCH;TP-LINK - TL-POE150S;TL-SF1016D;2,14455E+12;CAGE
|
||||||
|
UC;HP;;CZC6348XMS;P.20
|
||||||
|
UC;HP;;CZC5112XXQ;P.20
|
||||||
|
UC;HP;;CZC5112XY6;P.20
|
||||||
|
UC;HP;;CZC5112XY1;P.20
|
||||||
|
UC;HP;;CZC651782N;P.20
|
||||||
|
UC;HP;;CZC4293K1Z;P.20
|
||||||
|
UC;DELL - D08U;D08U;6FZ5C72;P.18
|
||||||
|
UC;DELL - D08U;D08U;CTV9Z72;P.18
|
||||||
|
WIFI;DELL - ANTENNE SF (WLAN);ANTENNE SF (WLAN);CN0WX4920084235O3249;CAGE
|
||||||
|
WIFI;DELL - ANTENNE SF (WLAN);ANTENNE SF (WLAN);CN0WX4920084235O3253;CAGE
|
||||||
|
WIFI;DELL - ANTENNE SF (WLAN);ANTENNE SF (WLAN);CN0WX4920084235O3223;CAGE
|
||||||
|
WIFI;DELL - ANTENNE SF (WLAN);ANTENNE SF (WLAN);CN0WX4920084235O3252;CAGE
|
||||||
|
WIFI;DELL - ANTENNE SF (WLAN);ANTENNE SF (WLAN);CN0RU2970084235O3264;CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;1,30305E+13;CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;1,41155E+13;CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;S14115523075061;CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;S14115523075467;CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;S14115523075264;CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;S14115523075250;HS/CAGE
|
||||||
|
WIFI;MOTOROLA - NCAP-500;NCAP-500;S14115523075501;HS/CAGE
|
||||||
|
SWITCH;MOTOROLA - PD3001/AC;PD3001/AC;SR10136050012326801;CAGE
|
||||||
|
WIFI;MOTOROLA - AP-5131;AP-5131;1,03445E+13;CAGE
|
||||||
|
WIFI;HOMERIDER / CR100_ANIG;CR100_ANIG;5,32202E+15;CAGE
|
||||||
|
ECRAN;LG - 22M37A-B;22M37A-B;504NTHM10433;CAGE
|
||||||
|
ECRAN;LG - 22M37A-B;22M37A-B;504NTFA10427;CAGE
|
||||||
|
UC;HP - TPC-I011-DM;TPC-I011-DM;4CH602164M;
|
||||||
|
ECRAN;AOC - 215LM00041;215LM00041;GFRGBHA005140;CAGE
|
||||||
|
ECRAN;AOC - 215LM00041;215LM00041;GFRGBHA005188;CAGE
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63GAQA011751;CAGE
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA002122;CAGE
|
||||||
|
ECRAN;FUJITSU - W2112;W2112;YV8T028276;CAGE
|
||||||
|
ECRAN;FUJITSU - L22T-2;L22T-2;YV7Q006922;CAGE
|
||||||
|
ECRAN;AOC - 215LM00041;215LM00041;GFRGBHA004388;CAGE
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W1811070827A4309;CAGE
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W18104900320F4306;CAGE
|
||||||
|
ECRAN;ACER - V193W D;V193W D;ETLHV0D0929420AB808500;CAGE
|
||||||
|
ECRAN;ACER - V193W D;V193W D;ETLHV0D0929420AB948500;CAGE
|
||||||
|
ECRAN;ACER - V193W D;V193W D;ETLHV0D0929420A8118500;CAGE
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLPB0C186051266E940G0;CAGE
|
||||||
|
ECRAN;ACER - V193W;V193W;ETLJE0W181049032104306;CAGE
|
||||||
|
ECRAN;ACER - V193W D;V193W D;ETLHV0D0929420A3D68500;CAGE
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63GAQA010841;HS / P.20
|
||||||
|
ECRAN;DELL - E2216Hf;E2216Hf;CN-0XV9JN-72872-631-DKJL-A01;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA002080;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G2QA002742;HS / P.20
|
||||||
|
ECRAN;FUJITSU - L22T-2;L22T-2;YV5F216051;HS / P.20
|
||||||
|
UC;DELL - OPTIPLEX 390;OPTIPLEX 390;1,86177E+11;CAGE
|
||||||
|
UC;DELL - OPTIPLEX 3010;OPTIPLEX 3010;1,86217E+11;CAGE
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G6QA013855;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;FZUECHA043503;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G6QA014012;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G6QA014098;CAGE
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G6QA001233;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63GAQA011924;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G6QA001232;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA002112;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA002079;HS / P.20
|
||||||
|
UC;DELL - OPTIPLEX 390;OPTIPLEX 390;1,86177E+11;CAGE
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63GAQA010860;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA002060;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00032;215LM00032;KARFC1A002746;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00063;215LM00063;B63G6QA014075;HS / P.20
|
||||||
|
ECRAN;AOC - 215LM00019;215LM00019;GAXF1HA013119;HS / P.20
|
||||||
|
WIFI;TP-LINK - TL-POE150S;TL-POE150S;2,16948E+12;CAGE
|
||||||
|
SWITCH;AVOCENT - SWITCH VIEW;SWITCH VIEW;FK0241919;CAGE
|
||||||
|
WIFI;D-LINK - DWL-G520;DWL-G520;BN2G33B004856;CAGE
|
||||||
|
SWITCH;3COM;3300XM;7MAV1D761C078;CAGE
|
||||||
|
SWITCH;3COM;3300XM;7MAV1D761D278;HS / CAGE
|
||||||
|
SWITCH;TRENDNET;TE100-S80g;CA1048S849840;CAGE
|
||||||
|
UC;WYSE;SX0;61T8DC03152;CAGE
|
||||||
|
SWITCH;TP-LINK;TL-POE150S;127A2804999;CAGE
|
||||||
|
SWITCH;TP-LINK;TL-POE150S;127A2804982;CAGE
|
|
59
Exemples/Fichier multiple/script-multi-fichier.ps1
Normal file
59
Exemples/Fichier multiple/script-multi-fichier.ps1
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
$Folder = "C:\Users\hubert.cornet\Downloads\Rules\"
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
$Mag = $Null
|
||||||
|
$FinalData = $Null
|
||||||
|
$RANK = 100
|
||||||
|
|
||||||
|
For ($Num = 1 ;$Num -le 243 ; $Num++) {
|
||||||
|
$RANK = 10
|
||||||
|
$RANK = $RANK + $Num
|
||||||
|
|
||||||
|
$measureNum = $Num | Measure-Object -Character
|
||||||
|
|
||||||
|
If ($measureNum.Characters -eq 1 ) {
|
||||||
|
$Mag = "00"+$Num
|
||||||
|
}
|
||||||
|
ElseIf ($measureNum.Characters -eq 2 ) {
|
||||||
|
$Mag = "0"+$Num
|
||||||
|
}
|
||||||
|
ElseIf ($measureNum.Characters -eq 3 ) {
|
||||||
|
$Mag = $Num
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$DataTexte = "<?xml version='1.0'?>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<entities_id>Saint-Maclou</entities_id>
|
||||||
|
<sub_type>RuleTicket</sub_type>
|
||||||
|
<ranking>$RANK</ranking>
|
||||||
|
<name>MAG$Mag</name>
|
||||||
|
<description></description>
|
||||||
|
<match>AND</match>
|
||||||
|
<is_active>1</is_active>
|
||||||
|
<comment></comment>
|
||||||
|
<is_recursive>0</is_recursive>
|
||||||
|
<uuid>500717c8-2bd6e957-53a12b5fd37f94.10365$Mag</uuid>
|
||||||
|
<condition>3</condition>
|
||||||
|
<date_creation></date_creation>
|
||||||
|
<rulecriteria>
|
||||||
|
<criteria>_locations_id_of_requester</criteria>
|
||||||
|
<condition>0</condition>
|
||||||
|
<pattern>Magasins &#62; MAG$Mag</pattern>
|
||||||
|
</rulecriteria>
|
||||||
|
<ruleaction>
|
||||||
|
<action_type>assign</action_type>
|
||||||
|
<field>locations_id</field>
|
||||||
|
<value>Magasins &#62; MAG$Mag</value>
|
||||||
|
</ruleaction>
|
||||||
|
</rule>
|
||||||
|
</rules>"
|
||||||
|
|
||||||
|
$File = $Folder+"\rules-$Mag.xml"
|
||||||
|
Add-Content $File $DataTexte
|
||||||
|
}
|
||||||
|
|
57
Exemples/Fichier multiple/script-un-fichier.ps1
Normal file
57
Exemples/Fichier multiple/script-un-fichier.ps1
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
$File = "C:\Users\hubert.cornet\Downloads\rules-010.xml"
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
$Mag = $Null
|
||||||
|
$FinalData = $Null
|
||||||
|
$RANK = 30
|
||||||
|
|
||||||
|
For ($Num = 1 ;$Num -le 243 ; $Num++) {
|
||||||
|
$RANK = 10
|
||||||
|
$RANK = $RANK + $Num
|
||||||
|
|
||||||
|
$measureNum = $Num | Measure-Object -Character
|
||||||
|
|
||||||
|
If ($measureNum.Characters -eq 1 ) {
|
||||||
|
$Mag = "00"+$Num
|
||||||
|
}
|
||||||
|
ElseIf ($measureNum.Characters -eq 2 ) {
|
||||||
|
$Mag = "0"+$Num
|
||||||
|
}
|
||||||
|
ElseIf ($measureNum.Characters -eq 3 ) {
|
||||||
|
$Mag = $Num
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$DataTexte = "
|
||||||
|
<rule>
|
||||||
|
<entities_id>Saint-Maclou</entities_id>
|
||||||
|
<sub_type>RuleLocation</sub_type>
|
||||||
|
<ranking>$RANK</ranking>
|
||||||
|
<name>MAG$Mag</name>
|
||||||
|
<description></description>
|
||||||
|
<match>AND</match>
|
||||||
|
<is_active>1</is_active>
|
||||||
|
<comment></comment>
|
||||||
|
<is_recursive>0</is_recursive>
|
||||||
|
<uuid>500717c8-2bd6e957-53a12b5fd45f84.20365$Mag</uuid>
|
||||||
|
<condition>0</condition>
|
||||||
|
<date_creation></date_creation>
|
||||||
|
<rulecriteria>
|
||||||
|
<criteria>tag</criteria>
|
||||||
|
<condition>0</condition>
|
||||||
|
<pattern>MAG$Mag</pattern>
|
||||||
|
</rulecriteria>
|
||||||
|
<ruleaction>
|
||||||
|
<action_type>assign</action_type>
|
||||||
|
<field>locations_id</field>
|
||||||
|
<value>Magasins &#62; MAG$Mag</value>
|
||||||
|
</ruleaction>
|
||||||
|
</rule>"
|
||||||
|
|
||||||
|
$FinalData += $DataTexte
|
||||||
|
}
|
||||||
|
|
||||||
|
Add-Content $File $FinalData
|
96
Exemples/Finalisation.ps1
Normal file
96
Exemples/Finalisation.ps1
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
[void][reflection.assembly]::loadwithpartialname("system.windows.forms")
|
||||||
|
|
||||||
|
Set-ExecutionPolicy Unrestricted
|
||||||
|
Clear-Host
|
||||||
|
|
||||||
|
write-host "Lancement du script"
|
||||||
|
write-host " "
|
||||||
|
|
||||||
|
# Fonction pour l'interface de saisie
|
||||||
|
Function ModeInstall() {
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
|
||||||
|
|
||||||
|
$objForm = New-Object System.Windows.Forms.Form
|
||||||
|
$objForm.Text = "Finalisation serveur"
|
||||||
|
$objForm.Size = New-Object System.Drawing.Size(500,300)
|
||||||
|
$objForm.StartPosition = "CenterScreen"
|
||||||
|
|
||||||
|
$objForm.KeyPreview = $True
|
||||||
|
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")
|
||||||
|
{$ClusterInstall=$objListBoxCluster.SelectedItem;$objForm.hide()}})
|
||||||
|
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")
|
||||||
|
{$objForm.hide()}})
|
||||||
|
$objForm.AcceptButton = $OKButton
|
||||||
|
$objForm.CancelButton = $CancelButton
|
||||||
|
|
||||||
|
$OKButton = New-Object System.Windows.Forms.Button
|
||||||
|
$OKButton.Location = New-Object System.Drawing.Size(10,230)
|
||||||
|
$OKButton.Size = New-Object System.Drawing.Size(75,23)
|
||||||
|
$OKButton.Text = "OK"
|
||||||
|
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
|
||||||
|
|
||||||
|
$CancelButton = New-Object System.Windows.Forms.Button
|
||||||
|
$CancelButton.Location = New-Object System.Drawing.Size(200,230)
|
||||||
|
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
|
||||||
|
$CancelButton.Text = "Cancel"
|
||||||
|
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
||||||
|
|
||||||
|
$objLabel1 = New-Object System.Windows.Forms.Label
|
||||||
|
$objLabel1.Location = New-Object System.Drawing.Size(10,20)
|
||||||
|
$objLabel1.Size = New-Object System.Drawing.Size(280,20)
|
||||||
|
$objLabel1.Text = "Merci de la clé Windows 2016 pour finaliser le serveur"
|
||||||
|
|
||||||
|
$objLabel3 = New-Object System.Windows.Forms.Label
|
||||||
|
$objLabel3.Location = New-Object System.Drawing.Size(10,80)
|
||||||
|
$objLabel3.Size = New-Object System.Drawing.Size(280,20)
|
||||||
|
$objLabel3.Text = "clé : "
|
||||||
|
|
||||||
|
$objTextBoxKey = New-Object System.Windows.Forms.TextBox
|
||||||
|
$objTextBoxKey.Location = New-Object System.Drawing.Size(10,100)
|
||||||
|
$objTextBoxKey.Size = New-Object System.Drawing.Size(250,20)
|
||||||
|
$objTextBoxKey.text = "AAAAA-BBBBB-CCCCC-DDDDD-EEEEE"
|
||||||
|
$objForm.Controls.Add($objTextBoxKey)
|
||||||
|
|
||||||
|
|
||||||
|
$objForm.Controls.AddRange(@($OKButton,$CancelButton,$objLabel1,$objLabel2,$objLabel3,$objLabel4,$objListBoxServeur))
|
||||||
|
$objForm.Topmost = $True
|
||||||
|
|
||||||
|
$dialogResult = $objForm.ShowDialog()
|
||||||
|
|
||||||
|
if ($dialogResult -eq [System.Windows.Forms.DialogResult]::OK)
|
||||||
|
{
|
||||||
|
|
||||||
|
$Key = $objTextBoxKey.Text
|
||||||
|
#$InstallCRPCEN
|
||||||
|
|
||||||
|
$return = "$Key"
|
||||||
|
$return
|
||||||
|
}
|
||||||
|
|
||||||
|
$objForm.dispose()
|
||||||
|
|
||||||
|
} # End Function DriveList
|
||||||
|
|
||||||
|
write-host " *****************************************"
|
||||||
|
Write-host " "
|
||||||
|
|
||||||
|
write-host " *****************************************"
|
||||||
|
write-host " * Génération de l'interface"
|
||||||
|
write-host " *****************************************"
|
||||||
|
|
||||||
|
$ModeInstall = ModeInstall
|
||||||
|
write-host "- Données saisie ............................................... "
|
||||||
|
$Blocage = $False
|
||||||
|
|
||||||
|
write-host "- Validation des informations saisie ............................. "
|
||||||
|
if ($ModeInstall -ne $null) {
|
||||||
|
$ModeInstall | foreach { $ModeInstall = $_ -split ';'
|
||||||
|
$key = $ModeInstall[0]
|
||||||
|
} }
|
||||||
|
|
||||||
|
write-host $key
|
||||||
|
|
||||||
|
Dism /online /Set-Edition:ServerStandard /AcceptEula /ProductKey:$key
|
||||||
|
|
||||||
|
Restart-Computer
|
125
Exemples/Get-FolderSize.ps1
Normal file
125
Exemples/Get-FolderSize.ps1
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
|
||||||
|
Cette fonction renvoi le nombre de fichier et la taille contenu dans le dossier ainsi que le détail pour les sous-dossiers sur N niveaux.
|
||||||
|
Le résultat est un tableau indiquant le nombre et la taille des fichiers directement dans le dossier ainsi que le cumul des sous dossiers.
|
||||||
|
Il est possible de définir l'unité pour les tailles (B,Kb,Mb,Gb), le nombre de niveau et de filtrer sur certains types de fichier (*.txt)
|
||||||
|
La fonction utilise Get-childitem et Measure-Object.
|
||||||
|
Attention à la version de PowerShell.
|
||||||
|
|
||||||
|
This function returns the number of files and the size contained in the folder as well as the detail for the subfolders on N levels.
|
||||||
|
The result is a table showing the number and size of files directly in the folder as well as the total of subfolders.
|
||||||
|
It is possible to set the unit for sizes (B, Kb, Mb, Gb), the number of level and filter on certain file types (* .txt)
|
||||||
|
The function uses Get-childitem and Measure-Object.
|
||||||
|
Watch out for the PowerShell version.
|
||||||
|
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Cette fonction renvoie un tableau avec :
|
||||||
|
- chemin du dossier (Path)
|
||||||
|
- nombre de fichiers dans le dossier (InFolderFiles)
|
||||||
|
- tailles des fichiers dans le dossier (InFolderSize)
|
||||||
|
- nombre de fichier dans le dossier et les sous dossiers (AllFiles)
|
||||||
|
- tailles des fichiers du dossier et des sous dossiers (AllSize)
|
||||||
|
|
||||||
|
This function returns an array with:
|
||||||
|
- Path of the folder (Path)
|
||||||
|
- number of files in the folder (InFolderFiles)
|
||||||
|
- file sizes in the folder (InFolderSize)
|
||||||
|
- number of files in the folder and subfolders (AllFiles)
|
||||||
|
- file sizes of the folder and subfolders (AllSize)
|
||||||
|
|
||||||
|
|
||||||
|
.PARAMETER FolderPath
|
||||||
|
|
||||||
|
Chemin du dossier à analyser
|
||||||
|
Folder path to analyze
|
||||||
|
|
||||||
|
.PARAMETER Level
|
||||||
|
|
||||||
|
Nombre de niveau de sous dossier.
|
||||||
|
Number of subfolder level.
|
||||||
|
|
||||||
|
.PARAMETER unit
|
||||||
|
|
||||||
|
Unité pour les tailles de fichiers (B,Kb,Mb,Gb).Par défaut :Gb.
|
||||||
|
Unit for file sizes
|
||||||
|
|
||||||
|
.PARAMETER Filter (B,Kb,Mb,Gb), default Gb.
|
||||||
|
|
||||||
|
Filtre les fichiers par type. Par exemple *.txt ne compte que les fichiers txt.
|
||||||
|
Filters files by type. For example * .txt only counts txt files.
|
||||||
|
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
|
||||||
|
.\Get-FolderSize.ps1 -FolderPath d:\tools -level 2
|
||||||
|
.EXAMPLE
|
||||||
|
|
||||||
|
.\Get-FolderSize.ps1 -FolderPath \\Server\Documents -level 2 -filter "*.doc*" -unit "kb"
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Author: Philippe BARTH
|
||||||
|
Version: 1.0
|
||||||
|
#>
|
||||||
|
|
||||||
|
# Déclaration des paramètres
|
||||||
|
param([string]$FolderPath,[int]$level,[string]$unit="Mb",[string]$Filter="*.*")
|
||||||
|
|
||||||
|
if ($level -lt 1) { $level = 1 }
|
||||||
|
|
||||||
|
# Determine unit for folder size, default Gb
|
||||||
|
Switch ($unit)
|
||||||
|
{
|
||||||
|
"Gb"
|
||||||
|
{
|
||||||
|
$div="1GB"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Mb"
|
||||||
|
{
|
||||||
|
$div="1MB"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Kb"
|
||||||
|
{
|
||||||
|
$div="1KB"
|
||||||
|
}
|
||||||
|
"b"
|
||||||
|
{
|
||||||
|
$div="1"
|
||||||
|
}
|
||||||
|
Default
|
||||||
|
{
|
||||||
|
$div="1GB"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#init result
|
||||||
|
$result=@()
|
||||||
|
# search subfolder
|
||||||
|
$SubFolders = (Get-ChildItem -path $FolderPath -recurse -Directory -Depth $($level-1)).FullName
|
||||||
|
#add parent folder in list
|
||||||
|
$SubFolders+=$FolderPath
|
||||||
|
# scan all folder
|
||||||
|
foreach ($subfolder in $SubFolders)
|
||||||
|
{
|
||||||
|
#Search file in folder and subfolder
|
||||||
|
$FolderSize = Get-ChildItem -path $SubFolder -filter $filter -File -recurse | Measure-Object -Sum Length
|
||||||
|
#Search file only in folder
|
||||||
|
$fileInFolder = Get-ChildItem -path $SubFolder -filter $filter -File | Measure-Object -Sum Length
|
||||||
|
|
||||||
|
#result
|
||||||
|
$result+= New-Object -TypeName PSObject -Property @{
|
||||||
|
Path = $subfolder
|
||||||
|
AllFiles = $foldersize.count
|
||||||
|
AllSize = $foldersize.sum/$div
|
||||||
|
InFolderFiles = $fileInFolder.count
|
||||||
|
InFolderSize = $fileInFolder.sum/$div
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result | Sort-Object -Property path
|
45
Exemples/Nagvis - generateur de carte/script.ps1
Normal file
45
Exemples/Nagvis - generateur de carte/script.ps1
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
cls
|
||||||
|
|
||||||
|
$Folder = "C:\Users\hubert.cornet\Downloads\Centreon\maps"
|
||||||
|
$FichierTemplate = "Mag000.cfg"
|
||||||
|
$FichierListMag = "_liste.csv"
|
||||||
|
|
||||||
|
$ListeMag = Import-CSV -Path $Folder"\"$FichierListMag -Delimiter ";"
|
||||||
|
|
||||||
|
Foreach ($Mag in $ListeMag) {
|
||||||
|
$Number = $Mag.Magasins.SubString(3,3)
|
||||||
|
$TPV = $Mag.tpv.SubString(3,5)
|
||||||
|
|
||||||
|
$FichierMap = $Folder+"\Mag"+$Number+".cfg"
|
||||||
|
|
||||||
|
If (!(Test-Path -Path $FichierMap+".new") -And !(Test-Path -Path $FichierMap)) {
|
||||||
|
Write-host "False"
|
||||||
|
|
||||||
|
Copy-Item $Folder"\Mag000.cfg" -Destination $FichierMap+".old"
|
||||||
|
(Get-Content $FichierMap+".old") -Replace "Mag000", "Mag$Number" | Set-Content $FichierMap+".tmp1"
|
||||||
|
(Get-Content $FichierMap+".tmp1") -Replace "swa-000", "swa-$Number" | Set-Content $FichierMap+".tmp2"
|
||||||
|
|
||||||
|
If (Test-Path -Path $FichierMap+".old") {
|
||||||
|
Remove-Item -Path $FichierMap+".old" -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
(Get-Content $FichierMap+".tmp2") -Replace "AAAAA", "$TPV" | Set-Content $FichierMap+".new"
|
||||||
|
|
||||||
|
If (Test-Path -Path $FichierMap+".tmp1") {
|
||||||
|
Remove-Item -Path $FichierMap+".tmp1" -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
If (Test-Path -Path $FichierMap+".tmp2") {
|
||||||
|
Remove-Item -Path $FichierMap+".tmp2" -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-host "True"
|
||||||
|
|
||||||
|
(Get-Content $FichierMap+".new") -Replace "BBBBB", "$TPV" | Set-Content $FichierMap
|
||||||
|
|
||||||
|
If (Test-Path -Path $FichierMap+".new") {
|
||||||
|
Remove-Item -Path $FichierMap+".new" -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
0
Exemples/README.md
Normal file
0
Exemples/README.md
Normal file
54
Exemples/couleur.ps1
Normal file
54
Exemples/couleur.ps1
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
function Write-Color([String[]]$Text, [ConsoleColor[]]$Color = "White", [int]$StartTab = 0, [int] $LinesBefore = 0,[int] $LinesAfter = 0, [string] $LogFile = "", $TimeFormat = "yyyy-MM-dd HH:mm:ss") {
|
||||||
|
# version 0.2
|
||||||
|
# - added logging to file
|
||||||
|
# version 0.1
|
||||||
|
# - first draft
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - TimeFormat https://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
|
||||||
|
|
||||||
|
$DefaultColor = $Color[0]
|
||||||
|
if ($LinesBefore -ne 0) { for ($i = 0; $i -lt $LinesBefore; $i++) { Write-Host "`n" -NoNewline } } # Add empty line before
|
||||||
|
if ($StartTab -ne 0) { for ($i = 0; $i -lt $StartTab; $i++) { Write-Host "`t" -NoNewLine } } # Add TABS before text
|
||||||
|
if ($Color.Count -ge $Text.Count) {
|
||||||
|
for ($i = 0; $i -lt $Text.Length; $i++) { Write-Host $Text[$i] -ForegroundColor $Color[$i] -NoNewLine }
|
||||||
|
} else {
|
||||||
|
for ($i = 0; $i -lt $Color.Length ; $i++) { Write-Host $Text[$i] -ForegroundColor $Color[$i] -NoNewLine }
|
||||||
|
for ($i = $Color.Length; $i -lt $Text.Length; $i++) { Write-Host $Text[$i] -ForegroundColor $DefaultColor -NoNewLine }
|
||||||
|
}
|
||||||
|
Write-Host
|
||||||
|
if ($LinesAfter -ne 0) { for ($i = 0; $i -lt $LinesAfter; $i++) { Write-Host "`n" } } # Add empty line after
|
||||||
|
if ($LogFile -ne "") {
|
||||||
|
$TextToFile = ""
|
||||||
|
for ($i = 0; $i -lt $Text.Length; $i++) {
|
||||||
|
$TextToFile += $Text[$i]
|
||||||
|
}
|
||||||
|
Write-Output "[$([datetime]::Now.ToString($TimeFormat))]$TextToFile" | Out-File $LogFile -Encoding unicode -Append
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Write-Color -Text "Red ", "Green ", "Yellow " -Color Red,Green,Yellow
|
||||||
|
|
||||||
|
Write-Color -Text "This is text in Green ",
|
||||||
|
"followed by red ",
|
||||||
|
"and then we have Magenta... ",
|
||||||
|
"isn't it fun? ",
|
||||||
|
"Here goes DarkCyan" -Color Green,Red,Magenta,White,DarkCyan
|
||||||
|
|
||||||
|
Write-Color -Text "This is text in Green ",
|
||||||
|
"followed by red ",
|
||||||
|
"and then we have Magenta... ",
|
||||||
|
"isn't it fun? ",
|
||||||
|
"Here goes DarkCyan" -Color Green,Red,Magenta,White,DarkCyan -StartTab 3 -LinesBefore 1 -LinesAfter 1
|
||||||
|
|
||||||
|
Write-Color "1. ", "Option 1" -Color Yellow, Green
|
||||||
|
Write-Color "2. ", "Option 2" -Color Yellow, Green
|
||||||
|
Write-Color "3. ", "Option 3" -Color Yellow, Green
|
||||||
|
Write-Color "4. ", "Option 4" -Color Yellow, Green
|
||||||
|
Write-Color "9. ", "Press 9 to exit" -Color Yellow, Gray -LinesBefore 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Write-Color -LinesBefore 2 -Text "This little ","message is ", "written to log ", "file as well." -Color Yellow, White, Green, Red, Red -LogFile "C:\testing.txt" -TimeFormat "yyyy-MM-dd HH:mm:ss"
|
||||||
|
Write-Color -Text "This can get ","handy if ", "want to display things, and log actions to file ", "at the same time." -Color Yellow, White, Green, Red, Red -LogFile "C:\testing.txt"
|
0
Exemples/creation graphique - ligne/README.md
Normal file
0
Exemples/creation graphique - ligne/README.md
Normal file
55
Exemples/creation graphique - ligne/script-002.ps1
Normal file
55
Exemples/creation graphique - ligne/script-002.ps1
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
|
||||||
|
$scriptpath = Split-Path -parent $MyInvocation.MyCommand.Definition
|
||||||
|
|
||||||
|
# chart object
|
||||||
|
$chart1 = New-object System.Windows.Forms.DataVisualization.Charting.Chart
|
||||||
|
$chart1.Width = 1000
|
||||||
|
$chart1.Height = 700
|
||||||
|
$chart1.BackColor = [System.Drawing.Color]::White
|
||||||
|
|
||||||
|
# title
|
||||||
|
[void]$chart1.Titles.Add("Titre")
|
||||||
|
$chart1.Titles[0].Font = "Arial,13pt"
|
||||||
|
$chart1.Titles[0].Alignment = "topLeft"
|
||||||
|
|
||||||
|
# chart area
|
||||||
|
$chartarea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
|
||||||
|
$chartarea.Name = "ChartArea1"
|
||||||
|
$chartarea.AxisY.Title = "Durée (en minutes)"
|
||||||
|
$chartarea.AxisX.Title = "Temps (en jours)"
|
||||||
|
$chartarea.AxisY.Interval = 100
|
||||||
|
$chartarea.AxisX.Interval = 1
|
||||||
|
$chart1.ChartAreas.Add($chartarea)
|
||||||
|
|
||||||
|
# legend
|
||||||
|
$legend = New-Object system.Windows.Forms.DataVisualization.Charting.Legend
|
||||||
|
$legend.name = "Legend1"
|
||||||
|
$chart1.Legends.Add($legend)
|
||||||
|
|
||||||
|
# data source
|
||||||
|
$datasource = Get-Process | sort PrivateMemorySize -Descending | Select-Object -First 15
|
||||||
|
|
||||||
|
# data series
|
||||||
|
[void]$chart1.Series.Add("VirtualMem")
|
||||||
|
$chart1.Series["VirtualMem"].ChartType = "StackedBar"
|
||||||
|
$chart1.Series["VirtualMem"].BorderWidth = 3
|
||||||
|
$chart1.Series["VirtualMem"].IsVisibleInLegend = $true
|
||||||
|
$chart1.Series["VirtualMem"].chartarea = "ChartArea1"
|
||||||
|
$chart1.Series["VirtualMem"].Legend = "Legend1"
|
||||||
|
$chart1.Series["VirtualMem"].color = "#62B5CC"
|
||||||
|
$datasource | ForEach-Object {$chart1.Series["VirtualMem"].Points.addxy( $_.Name , ($_.VirtualMemorySize / 1000000)) }
|
||||||
|
|
||||||
|
# data series
|
||||||
|
[void]$chart1.Series.Add("PrivateMem")
|
||||||
|
$chart1.Series["PrivateMem"].ChartType = "StackedBar"
|
||||||
|
$chart1.Series["PrivateMem"].IsVisibleInLegend = $true
|
||||||
|
$chart1.Series["PrivateMem"].BorderWidth = 3
|
||||||
|
$chart1.Series["PrivateMem"].chartarea = "ChartArea1"
|
||||||
|
$chart1.Series["PrivateMem"].Legend = "Legend1"
|
||||||
|
$chart1.Series["PrivateMem"].color = "#FF0000"
|
||||||
|
$datasource | ForEach-Object {$chart1.Series["PrivateMem"].Points.addxy( $_.Name , ($_.PrivateMemorySize / 1000000)) }
|
||||||
|
|
||||||
|
# save chart
|
||||||
|
$chart1.SaveImage("$env:TEMP\SplineArea.png","png")
|
||||||
|
|
||||||
|
."$env:TEMP\SplineArea.png"
|
197
Exemples/creation graphique - ligne/script.ps1
Normal file
197
Exemples/creation graphique - ligne/script.ps1
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
#Build graph
|
||||||
|
[Array]$Line1 = 1..12 | ForEach-Object{Get-Random (10..20)}
|
||||||
|
$p=Get-Random (14..25)
|
||||||
|
$p%5
|
||||||
|
[Array]$Line2 = 1..12 | ForEach-Object{
|
||||||
|
If($p%5 -eq 0){
|
||||||
|
$p-=(get-random (1..3))
|
||||||
|
}
|
||||||
|
Else{
|
||||||
|
$p+=(get-random (1..5))
|
||||||
|
}
|
||||||
|
$p
|
||||||
|
}
|
||||||
|
[Array]$Lines = $Line1,$Line2
|
||||||
|
$Legend = "Heure cible","Heure de fin"
|
||||||
|
$Colors = "Blue","Green"
|
||||||
|
|
||||||
|
$file = ([guid]::NewGuid()).Guid
|
||||||
|
$file = "$env:TEMP\$file.png"
|
||||||
|
Draw-Graph -Lines $Lines -Legend $Legend -Colors $Colors -Header "Ponctualité flux AX vers DataHUB" -SaveDestination $file
|
||||||
|
.$file
|
||||||
|
|
||||||
|
Add-Type -AssemblyName System.Windows.Forms,System.Drawing
|
||||||
|
|
||||||
|
Function Get-Color{
|
||||||
|
$rbg = @()
|
||||||
|
|
||||||
|
For($i = 0;$i -le 3;$i++){
|
||||||
|
Switch($i){
|
||||||
|
#Black
|
||||||
|
0{ $rbg += 255}#Get-Random -Minimum 128 -Maximum 255 }
|
||||||
|
#RGB
|
||||||
|
Default{$rbg += Get-Random -Minimum 0 -Maximum 255}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Return $rbg
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Draw-Graph{
|
||||||
|
Param(
|
||||||
|
$Width = 1024,
|
||||||
|
$Height = 512,
|
||||||
|
[Array]$Lines,
|
||||||
|
[Array]$Legend,
|
||||||
|
[Array]$Colors,
|
||||||
|
$Header = "Graph",
|
||||||
|
$SaveDestination,
|
||||||
|
[Switch]$Preview
|
||||||
|
)
|
||||||
|
Begin{}
|
||||||
|
Process{
|
||||||
|
If($Preview){
|
||||||
|
[Windows.Forms.Form]$Window = New-Object System.Windows.Forms.Form
|
||||||
|
|
||||||
|
$Window.Width = $Width
|
||||||
|
$Window.Height = $Height
|
||||||
|
|
||||||
|
$Window.Show()
|
||||||
|
$Window.Refresh()
|
||||||
|
|
||||||
|
[Drawing.Graphics]$Graph = $Window.CreateGraphics()
|
||||||
|
}
|
||||||
|
Else{
|
||||||
|
$bmp = New-Object Drawing.Bitmap $Width,$Height
|
||||||
|
$Graph = [Drawing.Graphics]::FromImage($bmp)
|
||||||
|
|
||||||
|
}
|
||||||
|
$Graph.InterpolationMode = [Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||||
|
$Graph.SmoothingMode = [Drawing.Drawing2D.SmoothingMode]::AntiAlias
|
||||||
|
$Graph.TextRenderingHint = [Drawing.Text.TextRenderingHint]::AntiAlias
|
||||||
|
$Graph.CompositingQuality = [Drawing.Drawing2D.CompositingQuality]::HighQuality
|
||||||
|
|
||||||
|
$Background = [System.Drawing.Color]::Snow
|
||||||
|
$Graph.Clear($Background)
|
||||||
|
|
||||||
|
$TextBrush = New-Object Drawing.SolidBrush([System.Drawing.Color]::FromArgb(255, 0, 212,252))
|
||||||
|
$Font = New-object System.Drawing.Font("arial",12)
|
||||||
|
$gridPen = [Drawing.Pens]::LightGray
|
||||||
|
|
||||||
|
#Draw Graph area
|
||||||
|
$DrawArea = New-Object 'object[,]' 2,2
|
||||||
|
|
||||||
|
# X (Width)
|
||||||
|
[int]$DrawArea[0,0] = $Width/10
|
||||||
|
[int]$DrawArea[0,1] = ($Width-$Width/6)
|
||||||
|
# Y (Height)
|
||||||
|
[int]$DrawArea[1,0] = $Height/10
|
||||||
|
[int]$DrawArea[1,1] = ($Height-$Height/3)
|
||||||
|
|
||||||
|
# Get X bounds
|
||||||
|
$xFac = ($Lines | ForEach-Object{$_.Length} | Sort -Descending)[0]-1
|
||||||
|
$xInc = ($DrawArea[0,1]-$DrawArea[0,0]+$DrawArea[0,0])/$xFac
|
||||||
|
|
||||||
|
#Get Y bounds
|
||||||
|
$yMax = ($lines | ForEach-Object{$_} | sort -Descending)[0]
|
||||||
|
$yFac = ($DrawArea[1,1]-$DrawArea[1,0])/$yMax
|
||||||
|
|
||||||
|
#Draw box
|
||||||
|
$Graph.DrawRectangle($gridPen, ($DrawArea[0,0]),($DrawArea[1,0]),($DrawArea[0,1]),($DrawArea[1,1]))
|
||||||
|
|
||||||
|
#Draw Header
|
||||||
|
$Textpoint = New-Object System.Drawing.PointF ((($DrawArea[0,1]-$DrawArea[0,0])/2+$DrawArea[0,0]),($DrawArea[1,0]/2))
|
||||||
|
$Graph.DrawString($Header,$Font,$TextBrush,$TextPoint)
|
||||||
|
|
||||||
|
#Draw horizontal lines
|
||||||
|
$scaleFac = 0.1
|
||||||
|
$i = 1
|
||||||
|
#Get scale
|
||||||
|
While($i -ge 1){
|
||||||
|
$scaleFac = $scaleFac*10
|
||||||
|
$i = $yMax/$scaleFac
|
||||||
|
}
|
||||||
|
$scaleFac = $scaleFac/10
|
||||||
|
|
||||||
|
0..($yMax/$scaleFac) | ForEach-Object{
|
||||||
|
$y = $DrawArea[1,1]-(($_*$scaleFac)*$yFac)+$DrawArea[1,0]
|
||||||
|
$x1 = $DrawArea[0,0]
|
||||||
|
$x2 = $DrawArea[0,1]+$DrawArea[0,0]
|
||||||
|
|
||||||
|
$Graph.DrawLine($gridPen,$x1,$y,$x2,$y)
|
||||||
|
$thisPoint = New-Object System.Drawing.PointF (($x1-10),($y-15))
|
||||||
|
$thisSF = New-object System.Drawing.StringFormat
|
||||||
|
$thisSF.Alignment = "Far"
|
||||||
|
$Graph.DrawString("$($_*$scaleFac)",$Font,$TextBrush,$thisPoint,$thisSF)
|
||||||
|
}
|
||||||
|
|
||||||
|
If($lines[0].Count -le 1){
|
||||||
|
$tmp = $Lines
|
||||||
|
Remove-Variable Lines
|
||||||
|
$Lines = @(0)
|
||||||
|
$Lines[0] = $tmp
|
||||||
|
Remove-Variable tmp
|
||||||
|
$Lines
|
||||||
|
}
|
||||||
|
|
||||||
|
#DRAW LINE
|
||||||
|
$l = 0
|
||||||
|
Foreach($Line in $Lines){
|
||||||
|
If($Colors.Count -gt $l){
|
||||||
|
$Pen = New-Object Drawing.Pen($Colors[$l])
|
||||||
|
}
|
||||||
|
Else{
|
||||||
|
$rgb = Get-Color
|
||||||
|
$Pen = New-object Drawing.Pen([System.Drawing.Color]::FromArgb($rgb[0],$rgb[1],$rgb[2],$rgb[3]))
|
||||||
|
}
|
||||||
|
$Pen.Width = 2
|
||||||
|
|
||||||
|
#Initiate/Reset Points
|
||||||
|
$Points = @()
|
||||||
|
$Step = 0
|
||||||
|
|
||||||
|
Foreach($point in $line){
|
||||||
|
|
||||||
|
$x = ($xInc*$step)+$DrawArea[0,0]
|
||||||
|
$y = $DrawArea[1,1]-($point*$yFac)+$DrawArea[1,0]
|
||||||
|
|
||||||
|
$Points += New-Object System.Drawing.PointF($x,$y)
|
||||||
|
$Step++
|
||||||
|
}
|
||||||
|
$Graph.DrawLines($pen,$Points)
|
||||||
|
|
||||||
|
If($Legend.Count -gt $l){
|
||||||
|
$thisLegend = $Legend[$l]
|
||||||
|
If($Colors.Count -gt $l){
|
||||||
|
$thisBrush = New-Object Drawing.SolidBrush($Colors[$l])
|
||||||
|
}
|
||||||
|
Else{
|
||||||
|
$rgb = Get-Color
|
||||||
|
$thisBrush = New-Object Drawing.SolidBrush([System.Drawing.Color]::FromArgb($rgb[0],$rgb[1],$rgb[2],$rgb[3]))
|
||||||
|
}
|
||||||
|
|
||||||
|
$y = $DrawArea[1,1]+$DrawArea[1,0]+20
|
||||||
|
$x = $DrawArea[0,0]+100*$l
|
||||||
|
|
||||||
|
$thisPoint = New-Object System.Drawing.PointF ($x,$y)
|
||||||
|
$thisFont = New-Object System.Drawing.Font("arial",12,[System.Drawing.FontStyle]::Bold)
|
||||||
|
$Graph.DrawString($thisLegend,$thisFont,$thisBrush,$thisPoint)
|
||||||
|
}
|
||||||
|
$l++
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
End{
|
||||||
|
|
||||||
|
If($Preview){
|
||||||
|
Start-Sleep 10
|
||||||
|
}
|
||||||
|
Else{
|
||||||
|
$bmp.save($SaveDestination)
|
||||||
|
}
|
||||||
|
|
||||||
|
Try{$Graph.Dispose()}Catch{}
|
||||||
|
Try{$bmp.Dispose()}Catch{}
|
||||||
|
Try{$Window.Close()}Catch{}
|
||||||
|
Try{$Window.Dispose()}Catch{}
|
||||||
|
}
|
||||||
|
}
|
192
Exemples/création-procédure.ps1
Normal file
192
Exemples/création-procédure.ps1
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
|
||||||
|
# Fonction pour créer une carte pôur NAGVIS
|
||||||
|
#
|
||||||
|
# Recoit en parametre :
|
||||||
|
# - l'emplacement du fichier source
|
||||||
|
# - l'emplacement du fichier de destination
|
||||||
|
# - le texte à rajouter
|
||||||
|
# - la position du texte dans l'image
|
||||||
|
Function AjoutTextePourImageMap {
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
PARAM (
|
||||||
|
[Parameter(Mandatory=$true)][String] $CheminSource,
|
||||||
|
[Parameter(Mandatory=$true)][String] $CheminDestination,
|
||||||
|
[Parameter(Mandatory=$true)][String] $Texte,
|
||||||
|
[Parameter(Mandatory=$true)][String] $Position,
|
||||||
|
[Parameter()][String] $Description = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Verbose "Load System.Drawing"
|
||||||
|
[Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
|
||||||
|
|
||||||
|
Write-Verbose "Get the image from $CheminSource"
|
||||||
|
$srcImg = [System.Drawing.Image]::FromFile($CheminSource)
|
||||||
|
|
||||||
|
Write-Verbose "Create a bitmap as $destPath"
|
||||||
|
$outputIImg = new-object System.Drawing.Bitmap([int]($srcImg.width)),([int]($srcImg.height))
|
||||||
|
|
||||||
|
Write-Verbose "Intialize Graphics"
|
||||||
|
$Image = [System.Drawing.Graphics]::FromImage($outputIImg)
|
||||||
|
$Image.SmoothingMode = "AntiAlias"
|
||||||
|
|
||||||
|
$Rectangle = New-Object Drawing.Rectangle 0, 0, $srcImg.Width, $srcImg.Height
|
||||||
|
$Image.DrawImage($srcImg, $Rectangle, 0, 0, $srcImg.Width, $srcImg.Height, ([Drawing.GraphicsUnit]::Pixel))
|
||||||
|
|
||||||
|
Write-Verbose "Draw title: $Title"
|
||||||
|
$Font = new-object System.Drawing.Font("Arial", 14, "Bold","Pixel")
|
||||||
|
|
||||||
|
#get font size
|
||||||
|
$font_size = [System.Windows.Forms.TextRenderer]::MeasureText($Texte, $Font)
|
||||||
|
$font_size_width = $font_size.Width
|
||||||
|
$font_size_height = $font_size.Height
|
||||||
|
|
||||||
|
$rect = [System.Drawing.RectangleF]::FromLTRB(0, 0, $srcImg.Width, $srcImg.Height)
|
||||||
|
|
||||||
|
If ($Position -eq "nom") {
|
||||||
|
#$text_in_middle_top_offset = $srcImg.Height / 2
|
||||||
|
$text_in_middle_top_offset = 180
|
||||||
|
$text_in_middle_left_offset = 155
|
||||||
|
|
||||||
|
#styling font
|
||||||
|
$Brush = New-Object Drawing.SolidBrush([System.Drawing.Color]::FromArgb(255, 0, 0, 0))
|
||||||
|
|
||||||
|
#lets draw font
|
||||||
|
$Image.DrawString($Texte, $Font, $Brush, $text_in_middle_top_offset, $text_in_middle_left_offset)
|
||||||
|
|
||||||
|
}
|
||||||
|
ElseIf ($Position -eq "adresse") {
|
||||||
|
$text_in_middle_top_offset = 180
|
||||||
|
$text_in_middle_left_offset = 205
|
||||||
|
|
||||||
|
#styling font
|
||||||
|
$Brush = New-Object Drawing.SolidBrush([System.Drawing.Color]::FromArgb(255, 0, 0, 0))
|
||||||
|
|
||||||
|
#lets draw font
|
||||||
|
$Image.DrawString($Texte, $Font, $Brush, $text_in_middle_top_offset, $text_in_middle_left_offset)
|
||||||
|
}
|
||||||
|
ElseIf ($Position -eq "password") {
|
||||||
|
$text_in_middle_top_offset = 180
|
||||||
|
$text_in_middle_left_offset1 = 257
|
||||||
|
$text_in_middle_left_offset2 = 280
|
||||||
|
|
||||||
|
#styling font
|
||||||
|
$Brush = New-Object Drawing.SolidBrush([System.Drawing.Color]::FromArgb(255, 0, 0, 0))
|
||||||
|
|
||||||
|
#lets draw font
|
||||||
|
$Image.DrawString($Texte, $Font, $Brush, $text_in_middle_top_offset, $text_in_middle_left_offset1)
|
||||||
|
$Image.DrawString($Texte, $Font, $Brush, $text_in_middle_top_offset, $text_in_middle_left_offset2)
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$format = [System.Drawing.StringFormat]::GenericDefault
|
||||||
|
$format.Alignment = [System.Drawing.StringAlignment]::Center
|
||||||
|
$format.LineAlignment = [System.Drawing.StringAlignment]::Center
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Save and close the files"
|
||||||
|
$outputIImg.save($CheminDestination, [System.Drawing.Imaging.ImageFormat]::jpeg)
|
||||||
|
$outputIImg.Dispose()
|
||||||
|
$srcImg.Dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$Nom = "DUPONT"
|
||||||
|
$Prenom = "Flavien"
|
||||||
|
$CRPCEN = "59159"
|
||||||
|
$SamAccountName = "$Prenom.$Nom@no$CRPCEN.mailnot.fr"
|
||||||
|
|
||||||
|
Add-Type -Path “$PSScriptRoot\itextsharp.dll”
|
||||||
|
Import-Module "$PSScriptRoot\PDF.psm1"
|
||||||
|
|
||||||
|
AjoutTextePourImageMap -CheminSource "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001.jpg" -CheminDestination "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp.jpg" -Texte "$Prenom.$Nom" -Position "nom"
|
||||||
|
AjoutTextePourImageMap -CheminSource "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp.jpg" -CheminDestination "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp-002.jpg" -Texte "$SamAccountName" -Position "adresse"
|
||||||
|
AjoutTextePourImageMap -CheminSource "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp-002.jpg" -CheminDestination "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp-003.jpg" -Texte "*******************" -Position "password"
|
||||||
|
|
||||||
|
$pdf = New-Object iTextSharp.text.Document
|
||||||
|
Create-PDF -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\exemple-0001.pdf" -TopMargin 20 -BottomMargin 20 -LeftMargin 20 -RightMargin 20 -Author "Patrick"
|
||||||
|
|
||||||
|
$pdf.Open()
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text "1"
|
||||||
|
Add-Text -Document $pdf -Text "2"
|
||||||
|
Add-Text -Document $pdf -Text "3"
|
||||||
|
Add-Text -Document $pdf -Text "4"
|
||||||
|
Add-Text -Document $pdf -Text "5"
|
||||||
|
Add-Text -Document $pdf -Text "6"
|
||||||
|
Add-Text -Document $pdf -Text "7"
|
||||||
|
Add-Text -Document $pdf -Text "8"
|
||||||
|
Add-Text -Document $pdf -Text "9"
|
||||||
|
Add-Text -Document $pdf -Text "10"
|
||||||
|
Add-Text -Document $pdf -Text "11"
|
||||||
|
Add-Text -Document $pdf -Text "12"
|
||||||
|
Add-Text -Document $pdf -Text "13"
|
||||||
|
Add-Text -Document $pdf -Text "14"
|
||||||
|
Add-Text -Document $pdf -Text "15"
|
||||||
|
Add-Text -Document $pdf -Text "16"
|
||||||
|
Add-Text -Document $pdf -Text "17"
|
||||||
|
Add-Text -Document $pdf -Text "18"
|
||||||
|
Add-Text -Document $pdf -Text "19"
|
||||||
|
Add-Text -Document $pdf -Text "20"
|
||||||
|
Add-Text -Document $pdf -Text "21"
|
||||||
|
Add-Text -Document $pdf -Text "22"
|
||||||
|
Add-Text -Document $pdf -Text "23"
|
||||||
|
Add-Text -Document $pdf -Text "24"
|
||||||
|
Add-Text -Document $pdf -Text "25"
|
||||||
|
Add-Text -Document $pdf -Text "26"
|
||||||
|
Add-Text -Document $pdf -Text "27"
|
||||||
|
Add-Text -Document $pdf -Text "28"
|
||||||
|
Add-Text -Document $pdf -Text "29"
|
||||||
|
Add-Text -Document $pdf -Text "30"
|
||||||
|
Add-Text -Document $pdf -Text "31"
|
||||||
|
Add-Text -Document $pdf -Text "32"
|
||||||
|
Add-Text -Document $pdf -Text "33"
|
||||||
|
Add-Text -Document $pdf -Text "34"
|
||||||
|
Add-Text -Document $pdf -Text "35"
|
||||||
|
Add-Text -Document $pdf -Text "36"
|
||||||
|
Add-Text -Document $pdf -Text "37"
|
||||||
|
Add-Text -Document $pdf -Text "38"
|
||||||
|
Add-Text -Document $pdf -Text "39"
|
||||||
|
Add-Text -Document $pdf -Text "40"
|
||||||
|
|
||||||
|
|
||||||
|
Add-Title -Document $pdf -Text "Configuration de la messagerie sur Outlook" -Color "magenta" -Centered
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text ""
|
||||||
|
Add-Text -Document $pdf -Text "Nous utilisons Outlook 2010"
|
||||||
|
Add-Text -Document $pdf -Text ""
|
||||||
|
Add-Text -Document $pdf -Text "Commencer par lancer l'application Outlook avec l'aide d'un des icones ci-dessous"
|
||||||
|
|
||||||
|
Add-Image -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0003.jpg"
|
||||||
|
|
||||||
|
Add-Image -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0004.jpg"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Add-Image -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0002.jpg"
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text ""
|
||||||
|
Add-Text -Document $pdf -Text "Dans l'application"
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text ""
|
||||||
|
Add-Text -Document $pdf -Text "Nous arrivons dans la fenêtre ci-dessous"
|
||||||
|
|
||||||
|
Add-Image -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001.jpg"
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text "Nous devons remplir les champs vide avec les informaions contenu dans le tableau"
|
||||||
|
Add-Table -Document $pdf -Dataset @("Nom", "$Prenom.$Nom", "Adresse", "$SamAccountName", "Mot de passe", "String", "Confirmer le mot de passe", "String") -Cols 2 -Centered
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text "Nous obtenons ceci"
|
||||||
|
Add-Image -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp-003.jpg"
|
||||||
|
|
||||||
|
Add-Text -Document $pdf -Text "Nous pouvons cliquer sur le bouton"
|
||||||
|
Add-Image -Document $pdf -File "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0005.jpg"
|
||||||
|
|
||||||
|
Add-Title -Document $pdf -Text "Configuration de la messagerie sur Iphone" -Color "magenta" -Centered
|
||||||
|
|
||||||
|
Add-Title -Document $pdf -Text "Configuration de la messagerie sur Androïd" -Color "magenta" -Centered
|
||||||
|
|
||||||
|
$pdf.Close()
|
||||||
|
|
||||||
|
Remove-Item -Path "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp.jpg" -Force
|
||||||
|
Remove-Item -Path "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp-002.jpg" -Force
|
||||||
|
Remove-Item -Path "C:\Users\hcornet\Downloads\PowerShell-PDF-master\PowerShell-PDF-master\Outlook-0001-temp-003.jpg" -Force
|
178
Exemples/etape1.ps1
Normal file
178
Exemples/etape1.ps1
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#Creation de la page HTML
|
||||||
|
|
||||||
|
$hostname = "Serveur 1";
|
||||||
|
$date = Date;
|
||||||
|
|
||||||
|
[System.Collections.ArrayList] $lignes = @()
|
||||||
|
|
||||||
|
|
||||||
|
$lignes += 'Installation ServerView RAID;OK/KO'
|
||||||
|
$lignes += 'Installation MegaRAID;OK/KO'
|
||||||
|
$lignes += 'Installation AD-Domain-Services;OK/KO'
|
||||||
|
$lignes += 'Installation DHCP;OK/KO'
|
||||||
|
$lignes += 'Installation Hyper-V;OK/KO'
|
||||||
|
$lignes += 'Installation SNMP;OK/KO'
|
||||||
|
|
||||||
|
$VersionWindows = "Windows Server 2016"
|
||||||
|
$NumeroDeSerie = "QSXRTFYJ5YIFL48"
|
||||||
|
$CPU = "Celeron 2 Duo"
|
||||||
|
$RAM = "256MB"
|
||||||
|
$NombreDeDisque = "1"
|
||||||
|
$EtatDisque = "OK"
|
||||||
|
$EtatRaid = "OK"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$HTML = @"
|
||||||
|
<HTML>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
body{
|
||||||
|
font-family: Arial;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
text-align: center;
|
||||||
|
margin: 2% 2% 2% 2%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1{
|
||||||
|
background-color: #3074d3;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr{
|
||||||
|
background-color: #EFEFEF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hostname{
|
||||||
|
width: 100%;
|
||||||
|
font-size: 350%;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
|
||||||
|
<div id='hostname'>$hostname</div>
|
||||||
|
<h3>$date</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<table width='49%' style='display: inline-block; float: left;'>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Version de Windows</td>
|
||||||
|
<td height="42px" width='100%'>$VersionWindows</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Date</td>
|
||||||
|
<td height="42px" width='100%'>$date</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Numéro de série</td>
|
||||||
|
<td height="42px" width='100%'>$NumeroDeSerie</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Processeur</td>
|
||||||
|
<td height="42px" width='100%'>$CPU</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>RAM</td>
|
||||||
|
<td height="42px" width='100%'>$RAM</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Nombre de disque</td>
|
||||||
|
<td height="42px" width='100%'>$NombreDeDisque</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Etat disque</td>
|
||||||
|
<td height="42px" width='100%'>$EtatDisque</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td height="42px" width='100%'>Etat Raid</td>
|
||||||
|
<td height="42px" width='100%'>$EtatRaid</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<table width='49%' style='display: inline-block; margin-left: 1%; '>
|
||||||
|
<tr height='86px'>
|
||||||
|
<td width='100%'>Disque C</td>
|
||||||
|
<td width='100%'></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr height='86px'>
|
||||||
|
<td width='100%'>Disque D</td>
|
||||||
|
<td width='100%'></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr height='86px'>
|
||||||
|
<td width='100%'>Disque E</td>
|
||||||
|
<td width='100%'></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr height='86px'>
|
||||||
|
<td width='100%'>Disque F</td>
|
||||||
|
<td width='100%'></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br><br><br><br>
|
||||||
|
"@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$table = @"
|
||||||
|
<h1 width='100%'> ETAPE 1 </h1>
|
||||||
|
|
||||||
|
<table id='etape1' width='100%' >
|
||||||
|
<th></th>
|
||||||
|
<th>Status </th>
|
||||||
|
|
||||||
|
"@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ForEach($elem in $lignes){
|
||||||
|
|
||||||
|
$ligne = $elem.Split(';')
|
||||||
|
|
||||||
|
$ligne0=$ligne[0]
|
||||||
|
$ligne1=$ligne[1]
|
||||||
|
|
||||||
|
$table += @"
|
||||||
|
<tr>
|
||||||
|
<td width='85%'>$ligne0</td>
|
||||||
|
<td width='15%'>$ligne1</td>
|
||||||
|
</tr>
|
||||||
|
"@
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$table += '</table>'
|
||||||
|
|
||||||
|
$HTML += $table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$HTML | Out-file "C:\Users\arobert\Desktop\Powershell etapes en HTML\index1.html"
|
78
Exemples/get_remoteapps_from_appserver.ps1
Normal file
78
Exemples/get_remoteapps_from_appserver.ps1
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#Detect os version script is executed on
|
||||||
|
$osversionString = (Get-WmiObject -class Win32_OperatingSystem).Caption
|
||||||
|
If ($osversionString.Contains('2008')){ $osVersion = '2008'}
|
||||||
|
Elseif ($osversionString.Contains('2012')){ $osversion = '2012'}
|
||||||
|
Elseif ($osversionString.Contains('2016')){ $osversion = '2016'}
|
||||||
|
else { $Host.SetShouldExit(1) }
|
||||||
|
|
||||||
|
#function to safely define directory of the script
|
||||||
|
function Get-ScriptDirectory
|
||||||
|
{
|
||||||
|
$Invocation = (Get-Variable MyInvocation -Scope 1).Value;
|
||||||
|
if($Invocation.PSScriptRoot)
|
||||||
|
{
|
||||||
|
$Invocation.PSScriptRoot;
|
||||||
|
}
|
||||||
|
Elseif($Invocation.MyCommand.Path)
|
||||||
|
{
|
||||||
|
Split-Path $Invocation.MyCommand.Path
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$Invocation.InvocationName.Substring(0,$Invocation.InvocationName.LastIndexOf("\"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create Folder to store the csv
|
||||||
|
$scriptDir = Get-ScriptDirectory
|
||||||
|
$path = "$($scriptdir)\Awingu_Apps"
|
||||||
|
if (Test-Path $path){
|
||||||
|
Remove-item $path -recurse
|
||||||
|
}
|
||||||
|
New-Item $path -type directory
|
||||||
|
#Fetch all info to populate the csv
|
||||||
|
$tabName = "remoteApps"
|
||||||
|
|
||||||
|
#Create Table object
|
||||||
|
$table = New-Object system.Data.DataTable "$tabName"
|
||||||
|
|
||||||
|
#Define Columns
|
||||||
|
$col1 = New-Object system.Data.DataColumn command,([string])
|
||||||
|
$col2 = New-Object system.Data.DataColumn name,([string])
|
||||||
|
$col3 = New-Object system.Data.DataColumn icon,([string])
|
||||||
|
|
||||||
|
#Add the Columns
|
||||||
|
$table.columns.add($col1)
|
||||||
|
$table.columns.add($col2)
|
||||||
|
$table.columns.add($col3)
|
||||||
|
|
||||||
|
if ($osversion -eq '2008')
|
||||||
|
{
|
||||||
|
Import-Module RemoteDesktopServices -verbose
|
||||||
|
cd RDS:
|
||||||
|
$remoteapps = Get-ChildItem RemoteApp\RemoteAppPrograms
|
||||||
|
ForEach ($remoteapp in $remoteapps) {
|
||||||
|
#Create a row
|
||||||
|
$row = $table.NewRow()
|
||||||
|
$row.command = $remoteapp.Name
|
||||||
|
$row.name = (Get-Item RemoteApp\RemoteAppPrograms\$remoteapp\DisplayName).CurrentValue
|
||||||
|
$row.icon = (Get-Item RemoteApp\RemoteAppPrograms\$remoteapp\Iconcontents).CurrentValue
|
||||||
|
$table.Rows.Add($row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Elseif ($osversion -eq '2012' -OR $osversion -eq '2016')
|
||||||
|
{
|
||||||
|
$remoteapps = get-rdsessioncollection | get-rdremoteapp
|
||||||
|
ForEach ($remoteapp in $remoteapps) {
|
||||||
|
#Create a row
|
||||||
|
$row = $table.NewRow()
|
||||||
|
$row.command = $remoteapp.ALIAS
|
||||||
|
$row.name = $remoteapp.DisplayName
|
||||||
|
$row.icon = $remoteapp.IconContents -join ','
|
||||||
|
$table.Rows.Add($row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#Dump the table into the csv
|
||||||
|
$tabCsv = $table | export-csv "$path\remoteapps.csv" -noType
|
1
Exemples/test.ps1
Normal file
1
Exemples/test.ps1
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Get-ADReplAccount -All -Server $env:ComputerName -NamingContext $(Get-ADDomain | select -ExpandProperty DistinguishedName) | Test-PasswordQuality -IncludeDisabledAccounts
|
22
Exemples/tirage euromillion/script-001.ps1
Normal file
22
Exemples/tirage euromillion/script-001.ps1
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
cls
|
||||||
|
|
||||||
|
$Array = @(("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50"),("00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00","00"))
|
||||||
|
|
||||||
|
For ($j=0;$j -lt 2500;$j++) {
|
||||||
|
$Number = Get-Random @('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50') -Count 1
|
||||||
|
$Star = Get-Random @('1','2','3','4','5','6','7','8','9','10','11','12') -Count 1
|
||||||
|
|
||||||
|
For ($i=1;$i -lt 50;$i++) {
|
||||||
|
If ($i -eq $Number) {
|
||||||
|
$Array[1][$i] = [int]$Array[1][$i] + 1
|
||||||
|
|
||||||
|
If ($Array[1][$i] -lt 10) {
|
||||||
|
$Array[1][$i] = "0" + $Array[1][$i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host $Array[0]
|
||||||
|
Write-Host
|
||||||
|
Write-Host $Array[1]
|
||||||
|
Write-Host
|
61
GLPI/Extraction.ps1
Normal file
61
GLPI/Extraction.ps1
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
Import-Module GlpiTools
|
||||||
|
|
||||||
|
Set-GlpiToolsConfig -PathToGlpi "https://glpi.fr.dgs.group/apirest.php" -AppToken "A37784iAbavHXtNKOome2zhBv1bKW7ycDSkJTtk8" -UserToken "xoRND6NwIcQ8qlEz1MOJCGOhHsOlf7DDmMRQETWu"
|
||||||
|
|
||||||
|
$ListeTicket = Get-GlpiToolsTickets -TicketName "[OPCON]"
|
||||||
|
|
||||||
|
$Extraction = @()
|
||||||
|
$percentComplete = $null
|
||||||
|
$Counter = $null
|
||||||
|
$listeTechniciens = $null
|
||||||
|
|
||||||
|
ForEach($Ticket in $ListeTicket) {
|
||||||
|
|
||||||
|
$percentComplete = $(($Counter / $ListeTicket.Count) * 100 )
|
||||||
|
|
||||||
|
$Progress = @{
|
||||||
|
Activity = "Getting folder information for '$($Ticket.Titre)'."
|
||||||
|
Status = "Processing $Counter of $($ListeTicket.Count)"
|
||||||
|
PercentComplete = $([math]::Round($percentComplete, 2))
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Progress @Progress -Id 1
|
||||||
|
|
||||||
|
If ($Ticket.Statut -ne "6") {
|
||||||
|
If ($Ticket.Technicien) {
|
||||||
|
$Technicien = Get-GlpiToolsUsers -UserId $Ticket.Technicien
|
||||||
|
|
||||||
|
If ($Technicien.Count -le "1") {
|
||||||
|
$Extraction += [pscustomobject]@{
|
||||||
|
ID = $Ticket.ID
|
||||||
|
Titre = $Ticket.Titre
|
||||||
|
Entité = $Ticket.Entité
|
||||||
|
Demandeur = $Ticket.Demandeur
|
||||||
|
Status = $Ticket.Statut
|
||||||
|
Date_ouverture = $Ticket."Date d'ouverture"
|
||||||
|
Groupe_techniciens = $Ticket."Groupe de techniciens"
|
||||||
|
Technicien = $Technicien.realname+" "+$Technicien.firstname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Foreach ($tmp in $Technicien) {
|
||||||
|
$listeTechniciens += $tmp.realname + " " + $tmp.firstname + "`n"
|
||||||
|
}
|
||||||
|
$Extraction += [pscustomobject]@{
|
||||||
|
ID = $Ticket.ID
|
||||||
|
Titre = $Ticket.Titre
|
||||||
|
Entité = $Ticket.Entité
|
||||||
|
Demandeur = $Ticket.Demandeur
|
||||||
|
Status = $Ticket.Statut
|
||||||
|
Date_ouverture = $Ticket."Date d'ouverture"
|
||||||
|
Groupe_techniciens = $Ticket."Groupe de techniciens"
|
||||||
|
Technicien = $listeTechniciens
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$Counter++
|
||||||
|
$listeTechniciens = $null
|
||||||
|
}
|
||||||
|
|
||||||
|
$Extraction | Export-CSV -Path "C:\Ntico\OPCON_BIRT\ReportEngine\rapports\FichierIn\ExtractionGlpi-V2.0.csv" -Force -Encoding UTF8 -NoTypeInformation
|
115
GUI/template.ps1
Normal file
115
GUI/template.ps1
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
|
||||||
|
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName('System.Collections')
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName('System.ComponentModel')
|
||||||
|
[void] [System.Reflection.Assembly]::LoadWithPartialName('System.Data')
|
||||||
|
|
||||||
|
$Ajouter = New-Object System.Windows.Forms.Button
|
||||||
|
$AdresseIP = new-object System.Windows.Forms.Label
|
||||||
|
$Liste_IP = new-object System.Windows.Forms.TextBox
|
||||||
|
$TXTNomConnecteurServeur = new-object System.Windows.Forms.CheckBox
|
||||||
|
$TXTNomConnecteurCopieur = new-object System.Windows.Forms.CheckBox
|
||||||
|
$TXTNomConnecteurRelais = new-object System.Windows.Forms.CheckBox
|
||||||
|
$TXTNomConnecteurAS400 = new-object System.Windows.Forms.CheckBox
|
||||||
|
$GroupBox1 = New-Object System.Windows.Forms.GroupBox
|
||||||
|
|
||||||
|
# Bouton
|
||||||
|
$Ajouter.Text = "Ajouter"
|
||||||
|
$Ajouter.Location = New-Object System.Drawing.Size(100, 245)
|
||||||
|
$Ajouter.Size = New-Object System.Drawing.Size(90,30)
|
||||||
|
$Ajouter.Add_Click({AjoutAdresseIP})
|
||||||
|
|
||||||
|
# TEXTE
|
||||||
|
$AdresseIP.AutoSize = $true
|
||||||
|
$AdresseIP.Location = new-object System.Drawing.Point(10, 130)
|
||||||
|
$AdresseIP.Name = "AdresseIP"
|
||||||
|
$AdresseIP.Size = new-object System.Drawing.Size(21, 13)
|
||||||
|
$AdresseIP.TabIndex = 2
|
||||||
|
$AdresseIP.Text = "Adresse IP :"
|
||||||
|
|
||||||
|
# Groupe Box
|
||||||
|
$GroupBox1 = New-Object System.Windows.Forms.GroupBox
|
||||||
|
$GroupBox1.Location = New-Object System.Drawing.Size(10,10)
|
||||||
|
$GroupBox1.size = New-Object System.Drawing.Size(100,100)
|
||||||
|
$GroupBox1.text = "Nom du connecteur :"
|
||||||
|
$GroupBox1.AutoSize = $True
|
||||||
|
|
||||||
|
# Bouton radio Groupe Box
|
||||||
|
$RadioButton1 = New-Object System.Windows.Forms.RadioButton
|
||||||
|
$RadioButton1.Location = new-object System.Drawing.Point(15,15)
|
||||||
|
$RadioButton1.size = New-Object System.Drawing.Size(200,20)
|
||||||
|
$RadioButton1.Checked = $true
|
||||||
|
$RadioButton1.Text = "SERVEURS"
|
||||||
|
$GroupBox1.Controls.Add($RadioButton1)
|
||||||
|
|
||||||
|
# Bouton radio Groupe Box
|
||||||
|
$RadioButton2 = New-Object System.Windows.Forms.RadioButton
|
||||||
|
$RadioButton2.Location = new-object System.Drawing.Point(15,35)
|
||||||
|
$RadioButton2.size = New-Object System.Drawing.Size(200,20)
|
||||||
|
$RadioButton2.Text = "COPIEURS"
|
||||||
|
$GroupBox1.Controls.Add($RadioButton2)
|
||||||
|
|
||||||
|
# Bouton radio Groupe Box
|
||||||
|
$RadioButton3 = New-Object System.Windows.Forms.RadioButton
|
||||||
|
$RadioButton3.Location = new-object System.Drawing.Point(15,55)
|
||||||
|
$RadioButton3.size = New-Object System.Drawing.Size(200,20)
|
||||||
|
$RadioButton3.Text = "RELAIS EXTERNE"
|
||||||
|
$GroupBox1.Controls.Add($RadioButton3)
|
||||||
|
|
||||||
|
# Bouton radio Groupe Box
|
||||||
|
$RadioButton4 = New-Object System.Windows.Forms.RadioButton
|
||||||
|
$RadioButton4.Location = new-object System.Drawing.Point(15,75)
|
||||||
|
$RadioButton4.size = New-Object System.Drawing.Size(200,20)
|
||||||
|
$RadioButton4.Text = "AS400"
|
||||||
|
$GroupBox1.Controls.Add($RadioButton4)
|
||||||
|
|
||||||
|
# Zone de saisie
|
||||||
|
$Liste_IP.AutoSize = $false
|
||||||
|
$Liste_IP.Location = new-object System.Drawing.Point(120, 130)
|
||||||
|
$Liste_IP.Name = "TXTAdresseIP"
|
||||||
|
$Liste_IP.Size = new-object System.Drawing.Size(150, 100)
|
||||||
|
$Liste_IP.TabIndex = 4
|
||||||
|
$Liste_IP.Text = "127.0.0.1"
|
||||||
|
$Liste_IP.Multiline = $true
|
||||||
|
|
||||||
|
# Mise en forme
|
||||||
|
$Form1 = new-object System.Windows.Forms.form
|
||||||
|
$Form1.ClientSize = new-object System.Drawing.Size(300, 290)
|
||||||
|
$Form1.Controls.Add($AdresseIP)
|
||||||
|
$Form1.Controls.Add($GroupBox1)
|
||||||
|
$Form1.Controls.Add($Liste_IP)
|
||||||
|
$Form1.Controls.Add($Ajouter)
|
||||||
|
$Form1.Name = "Form1"
|
||||||
|
$Form1.Text = "Ajouter adresse IP dans connecteur"
|
||||||
|
$Form1.ShowDialog()
|
||||||
|
|
||||||
|
Function AjoutAdresseIP {
|
||||||
|
|
||||||
|
If ($RadioButton1.Checked -eq $true) {$ConnectorName="SERVEURS"}
|
||||||
|
If ($RadioButton2.Checked -eq $true) {$ConnectorName="COPIEURS"}
|
||||||
|
If ($RadioButton3.Checked -eq $true) {$ConnectorName="RELAIS_EXTERNE"}
|
||||||
|
If ($RadioButton4.Checked -eq $true) {$ConnectorName="AS400"}
|
||||||
|
|
||||||
|
$date = Get-Date -Format "yyyy-MM-dd_H\hmm" # Recuperation de la date et heure du jours
|
||||||
|
|
||||||
|
$Texte1 = "Vous avez rajouté sur le connecteur : " + $ConnectorName + "`n"
|
||||||
|
$Texte2 = "Avec les adresse IP : `n"
|
||||||
|
$Texte3 = $Liste_IP -replace "System.Windows.Forms.TextBox, Text: ", ""
|
||||||
|
|
||||||
|
$oReturn=[System.Windows.Forms.MessageBox]::Show($Texte1 + $Texte2 + $Texte3,"Controle de saisie",[System.Windows.Forms.MessageBoxButtons]::OKCancel)
|
||||||
|
|
||||||
|
switch ($oReturn) {
|
||||||
|
"OK" {
|
||||||
|
write-host "Saisie valide"
|
||||||
|
|
||||||
|
Foreach ($IP in $Texte3) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Cancel" {
|
||||||
|
write-host "Saisie non valide"
|
||||||
|
# Enter some code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
197
General/Cheat-Sheet-1.ps1
Normal file
197
General/Cheat-Sheet-1.ps1
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
Get-Command # Retrieves a list of all the commands available to PowerShell
|
||||||
|
# (native binaries in $env:PATH + cmdlets / functions from PowerShell modules)
|
||||||
|
Get-Command -Module Microsoft* # Retrieves a list of all the PowerShell commands exported from modules named Microsoft*
|
||||||
|
Get-Command -Name *item # Retrieves a list of all commands (native binaries + PowerShell commands) ending in "item"
|
||||||
|
|
||||||
|
Get-Help # Get all help topics
|
||||||
|
Get-Help -Name about_Variables # Get help for a specific about_* topic (aka. man page)
|
||||||
|
Get-Help -Name Get-Command # Get help for a specific PowerShell function
|
||||||
|
Get-Help -Name Get-Command -Parameter Module # Get help for a specific parameter on a specific command
|
||||||
|
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Operators
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
$a = 2 # Basic variable assignment operator
|
||||||
|
$a += 1 # Incremental assignment operator
|
||||||
|
$a -= 1 # Decrement assignment operator
|
||||||
|
|
||||||
|
$a -eq 0 # Equality comparison operator
|
||||||
|
$a -ne 5 # Not-equal comparison operator
|
||||||
|
$a -gt 2 # Greater than comparison operator
|
||||||
|
$a -lt 3 # Less than comparison operator
|
||||||
|
|
||||||
|
$FirstName = 'Trevor'
|
||||||
|
$FirstName -like 'T*' # Perform string comparison using the -like operator, which supports the wildcard (*) character. Returns $true
|
||||||
|
|
||||||
|
$BaconIsYummy = $true
|
||||||
|
$FoodToEat = $BaconIsYummy ? 'bacon' : 'beets' # Sets the $FoodToEat variable to 'bacon' using the ternary operator
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Regular Expressions
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
'Trevor' -match '^T\w*' # Perform a regular expression match against a string value. # Returns $true and populates $matches variable
|
||||||
|
$matches[0] # Returns 'Trevor', based on the above match
|
||||||
|
|
||||||
|
@('Trevor', 'Billy', 'Bobby') -match '^B' # Perform a regular expression match against an array of string values. Returns Billy, Bobby
|
||||||
|
|
||||||
|
$regex = [regex]'(\w{3,8})'
|
||||||
|
$regex.Matches('Trevor Bobby Dillon Joe Jacob').Value # Find multiple matches against a singleton string value.
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Flow Control
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
if (1 -eq 1) { } # Do something if 1 is equal to 1
|
||||||
|
|
||||||
|
do { 'hi' } while ($false) # Loop while a condition is true (always executes at least once)
|
||||||
|
|
||||||
|
while ($false) { 'hi' } # While loops are not guaranteed to run at least once
|
||||||
|
while ($true) { } # Do something indefinitely
|
||||||
|
while ($true) { if (1 -eq 1) { break } } # Break out of an infinite while loop conditionally
|
||||||
|
|
||||||
|
for ($i = 0; $i -le 10; $i++) { Write-Host $i } # Iterate using a for..loop
|
||||||
|
foreach ($item in (Get-Process)) { } # Iterate over items in an array
|
||||||
|
|
||||||
|
switch ('test') { 'test' { 'matched'; break } } # Use the switch statement to perform actions based on conditions. Returns string 'matched'
|
||||||
|
switch -regex (@('Trevor', 'Daniel', 'Bobby')) { # Use the switch statement with regular expressions to match inputs
|
||||||
|
'o' { $PSItem; break } # NOTE: $PSItem or $_ refers to the "current" item being matched in the array
|
||||||
|
}
|
||||||
|
switch -regex (@('Trevor', 'Daniel', 'Bobby')) { # Switch statement omitting the break statement. Inputs can be matched multiple times, in this scenario.
|
||||||
|
'e' { $PSItem }
|
||||||
|
'r' { $PSItem }
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Variables
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
|
||||||
|
$a = 0 # Initialize a variable
|
||||||
|
[int] $a = 'Trevor' # Initialize a variable, with the specified type (throws an exception)
|
||||||
|
[string] $a = 'Trevor' # Initialize a variable, with the specified type (doesn't throw an exception)
|
||||||
|
|
||||||
|
Get-Command -Name *varia* # Get a list of commands related to variable management
|
||||||
|
|
||||||
|
Get-Variable # Get an array of objects, representing the variables in the current and parent scopes
|
||||||
|
Get-Variable | ? { $PSItem.Options -contains 'constant' } # Get variables with the "Constant" option set
|
||||||
|
Get-Variable | ? { $PSItem.Options -contains 'readonly' } # Get variables with the "ReadOnly" option set
|
||||||
|
|
||||||
|
New-Variable -Name FirstName -Value Trevor
|
||||||
|
New-Variable FirstName -Value Trevor -Option Constant # Create a constant variable, that can only be removed by restarting PowerShell
|
||||||
|
New-Variable FirstName -Value Trevor -Option ReadOnly # Create a variable that can only be removed by specifying the -Force parameter on Remove-Variable
|
||||||
|
|
||||||
|
Remove-Variable -Name firstname # Remove a variable, with the specified name
|
||||||
|
Remove-Variable -Name firstname -Force # Remove a variable, with the specified name, that has the "ReadOnly" option set
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Functions
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
function add ($a, $b) { $a + $b } # A basic PowerShell function
|
||||||
|
|
||||||
|
function Do-Something { # A PowerShell Advanced Function, with all three blocks declared: BEGIN, PROCESS, END
|
||||||
|
[CmdletBinding]()]
|
||||||
|
param ()
|
||||||
|
begin { }
|
||||||
|
process { }
|
||||||
|
end { }
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Working with Modules
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
Get-Command -Name *module* -Module mic*core # Which commands can I use to work with modules?
|
||||||
|
|
||||||
|
Get-Module -ListAvailable # Show me all of the modules installed on my system (controlled by $env:PSModulePath)
|
||||||
|
Get-Module # Show me all of the modules imported into the current session
|
||||||
|
|
||||||
|
$PSModuleAutoLoadingPreference = 0 # Disable auto-loading of installed PowerShell modules, when a command is invoked
|
||||||
|
|
||||||
|
Import-Module -Name NameIT # Explicitly import a module, from the specified filesystem path or name (must be present in $env:PSModulePath)
|
||||||
|
Remove-Module -Name NameIT # Remove a module from the scope of the current PowerShell session
|
||||||
|
|
||||||
|
New-ModuleManifest # Helper function to create a new module manifest. You can create it by hand instead.
|
||||||
|
|
||||||
|
New-Module -Name trevor -ScriptBlock { # Create an in-memory PowerShell module (advanced users)
|
||||||
|
function Add($a,$b) { $a + $b } }
|
||||||
|
|
||||||
|
New-Module -Name trevor -ScriptBlock { # Create an in-memory PowerShell module, and make it visible to Get-Module (advanced users)
|
||||||
|
function Add($a,$b) { $a + $b } } | Import-Module
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Module Management
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
Get-Command -Module PowerShellGet # Explore commands to manage PowerShell modules
|
||||||
|
|
||||||
|
Find-Module -Tag cloud # Find modules in the PowerShell Gallery with a "cloud" tag
|
||||||
|
Find-Module -Name ps* # Find modules in the PowerShell Gallery whose name starts with "PS"
|
||||||
|
|
||||||
|
Install-Module -Name NameIT -Scope CurrentUser -Force # Install a module to your personal directory (non-admin)
|
||||||
|
Install-Module -Name NameIT -Force # Install a module to your personal directory (admin / root)
|
||||||
|
Install-Module -Name NameIT -RequiredVersion 1.9.0 # Install a specific version of a module
|
||||||
|
|
||||||
|
Uninstall-Module -Name NameIT # Uninstall module called "NameIT", only if it was installed via Install-Module
|
||||||
|
|
||||||
|
Register-PSRepository -Name <repo> -SourceLocation <uri> # Configure a private PowerShell module registry
|
||||||
|
Unregister-PSRepository -Name <repo> # Deregister a PowerShell Repository
|
||||||
|
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Filesystem
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
New-Item -Path c:\test -ItemType Directory # Create a directory
|
||||||
|
mkdir c:\test2 # Create a directory (short-hand)
|
||||||
|
|
||||||
|
New-Item -Path c:\test\myrecipes.txt # Create an empty file
|
||||||
|
Set-Content -Path c:\test.txt -Value '' # Create an empty file
|
||||||
|
[System.IO.File]::WriteAllText('testing.txt', '') # Create an empty file using .NET Base Class Library
|
||||||
|
|
||||||
|
Remove-Item -Path testing.txt # Delete a file
|
||||||
|
[System.IO.File]::Delete('testing.txt') # Delete a file using .NET Base Class Library
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Hashtables (Dictionary)
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
$Person = @{
|
||||||
|
FirstName = 'Trevor'
|
||||||
|
LastName = 'Sullivan'
|
||||||
|
Likes = @(
|
||||||
|
'Bacon',
|
||||||
|
'Beer',
|
||||||
|
'Software'
|
||||||
|
)
|
||||||
|
} # Create a PowerShell HashTable
|
||||||
|
|
||||||
|
$Person.FirstName # Retrieve an item from a HashTable
|
||||||
|
$Person.Likes[-1] # Returns the last item in the "Likes" array, in the $Person HashTable (software)
|
||||||
|
$Person.Age = 50 # Add a new property to a HashTable
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Windows Management Instrumentation (WMI) (Windows only)
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
Get-CimInstance -ClassName Win32_BIOS # Retrieve BIOS information
|
||||||
|
Get-CimInstance -ClassName Win32_DiskDrive # Retrieve information about locally connected physical disk devices
|
||||||
|
Get-CimInstance -ClassName Win32_PhysicalMemory # Retrieve information about install physical memory (RAM)
|
||||||
|
Get-CimInstance -ClassName Win32_NetworkAdapter # Retrieve information about installed network adapters (physical + virtual)
|
||||||
|
Get-CimInstance -ClassName Win32_VideoController # Retrieve information about installed graphics / video card (GPU)
|
||||||
|
|
||||||
|
Get-CimClass -Namespace root\cimv2 # Explore the various WMI classes available in the root\cimv2 namespace
|
||||||
|
Get-CimInstance -Namespace root -ClassName __NAMESPACE # Explore the child WMI namespaces underneath the root\cimv2 namespace
|
||||||
|
|
||||||
|
|
||||||
|
###################################################
|
||||||
|
# Asynchronous Event Registration
|
||||||
|
###################################################
|
||||||
|
|
||||||
|
$Watcher = [System.IO.FileSystemWatcher]::new('c:\tmp')
|
||||||
|
Register-ObjectEvent -InputObject $Watcher -EventName Created -Action {
|
||||||
|
Write-Host -Object 'New file created!!!'
|
||||||
|
} # Register for filesystem events
|
20
General/Get-RandomPassword.ps1
Normal file
20
General/Get-RandomPassword.ps1
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
function Get-RandomPassword {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[int] $LettersLowerCase = 4,
|
||||||
|
[int] $LettersHigherCase = 2,
|
||||||
|
[int] $Numbers = 1,
|
||||||
|
[int] $SpecialChars = 0,
|
||||||
|
[int] $SpecialCharsLimited = 1
|
||||||
|
)
|
||||||
|
$Password = @(
|
||||||
|
Get-RandomCharacters -length $LettersLowerCase -characters 'abcdefghiklmnoprstuvwxyz'
|
||||||
|
Get-RandomCharacters -length $LettersHigherCase -characters 'ABCDEFGHKLMNOPRSTUVWXYZ'
|
||||||
|
Get-RandomCharacters -length $Numbers -characters '1234567890'
|
||||||
|
Get-RandomCharacters -length $SpecialChars -characters '!$%()=?{@#'
|
||||||
|
Get-RandomCharacters -length $SpecialCharsLimited -characters '!$#'
|
||||||
|
)
|
||||||
|
$StringPassword = $Password -join ''
|
||||||
|
$StringPassword = ($StringPassword.ToCharArray() | Get-Random -Count $StringPassword.Length) -join ''
|
||||||
|
return $StringPassword
|
||||||
|
}
|
1
General/README.md
Normal file
1
General/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# General
|
31
General/Send-Mail.ps1
Normal file
31
General/Send-Mail.ps1
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Get the credential
|
||||||
|
$creduser = Read-Host "Sender Email"
|
||||||
|
$credpassword = Read-Host "Sender Password"
|
||||||
|
|
||||||
|
[securestring]$secStringPassword = ConvertTo-SecureString $credpassword -AsPlainText -Force
|
||||||
|
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($creduser, $secStringPassword)
|
||||||
|
|
||||||
|
$Users = Import-Csv -Path "Send-Mail.csv" -Delimiter ";" -Encoding UTF8
|
||||||
|
|
||||||
|
foreach ($User in $Users) {
|
||||||
|
|
||||||
|
## Define the Send-MailMessage parameters
|
||||||
|
$mailParams = @{
|
||||||
|
SmtpServer = 'smtp.office365.com'
|
||||||
|
Port = '587'
|
||||||
|
UseSSL = $true
|
||||||
|
Credential = $credObject
|
||||||
|
From = $creduser
|
||||||
|
To = $($User.UserMail)
|
||||||
|
Subject = "Mail from PowerShell"
|
||||||
|
Body = "Hello,<br><br>
|
||||||
|
Your email is $($User.UserMail)<br>"
|
||||||
|
DeliveryNotificationOption = 'OnFailure'
|
||||||
|
BodyAsHtml = $true
|
||||||
|
Encoding = [System.Text.Encoding]::UTF8
|
||||||
|
}
|
||||||
|
|
||||||
|
## Send the message
|
||||||
|
Send-MailMessage @mailParams
|
||||||
|
|
||||||
|
}
|
4
General/Templates/Send-Mail.csv
Normal file
4
General/Templates/Send-Mail.csv
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
UserMail
|
||||||
|
user1@domain.com
|
||||||
|
user2@domain.com
|
||||||
|
user3@domain.com
|
|
26
Hyper-V/Compact-VHD.ps1
Normal file
26
Hyper-V/Compact-VHD.ps1
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Importer le moudule Hyper-V
|
||||||
|
Import-Module -Name Hyper-V
|
||||||
|
|
||||||
|
# Chemin du VHD et mode de compactage
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true, ValueFromPipeline = $true)][String]$Path,
|
||||||
|
[Parameter()][Microsoft.Vhd.PowerShell.VhdCompactMode]$Mode = [Microsoft.Vhd.PowerShell.VhdCompactMode]::Full
|
||||||
|
)
|
||||||
|
|
||||||
|
# Vérifier le fichier
|
||||||
|
try {
|
||||||
|
$Path = (Resolve-Path -Path $Path -ErrorAction Stop).Path
|
||||||
|
if ($Path -notmatch '\.a?vhdx?$') { throw }
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw('{0} is not a valid VHDX file.' -f $Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Monter le VHD
|
||||||
|
Mount-VHD -Path $Path -ReadOnly -ErrorAction Stop
|
||||||
|
|
||||||
|
# Compacter le VHD
|
||||||
|
Optimize-VHD -Path $Path -Mode $Mode -ErrorAction Continue
|
||||||
|
|
||||||
|
# Démonter le VHD
|
||||||
|
Dismount-VHD -Path $Path
|
108
Hyper-V/Create-VM.ps1
Normal file
108
Hyper-V/Create-VM.ps1
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
Import-Module Hyper-V
|
||||||
|
|
||||||
|
$HypervConfig = Get-VMHost | Select-Object VirtualHardDiskPath, VirtualMachinePath
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Emlacement des VM: " $HypervConfig.VirtualMachinePath
|
||||||
|
Write-Host "Emplacement des VHD: " $HypervConfig.VirtualHardDiskPath
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
$NewConfig = Read-Host "Voulez-vous changer les emplacements ? (o pour oui, non par défaut) "
|
||||||
|
|
||||||
|
if ($NewConfig -eq "o") {
|
||||||
|
|
||||||
|
$HvVmPath = Read-Host "Entre un chemin pour les VM (a pour annuler)"
|
||||||
|
|
||||||
|
if (Test-Path $HvVmPath -ErrorAction SilentlyContinue) {
|
||||||
|
Set-VMHost -VirtualMachinePath $HvVmPath
|
||||||
|
}
|
||||||
|
|
||||||
|
$HvVhdPath = Read-Host "Entre un chemin pour les VHD (a pour annuler)"
|
||||||
|
|
||||||
|
if (Test-Path $HvVhdPath -ErrorAction SilentlyContinue) {
|
||||||
|
Set-VMHost -VirtualHardDiskPath $HvVhdPath
|
||||||
|
}
|
||||||
|
|
||||||
|
$HypervConfig = Get-VMHost | Select-Object VirtualHardDiskPath, VirtualMachinePath
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Emlacement des VM: " $HypervConfig.VirtualMachinePath
|
||||||
|
Write-Host "Emplacement des VHD: " $HypervConfig.VirtualHardDiskPath
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$Template = Read-Host "Avez-vous un template VHD pour votre VM ? (o pour oui, non par défaut) "
|
||||||
|
|
||||||
|
if ($Template -eq "o") {
|
||||||
|
do {
|
||||||
|
|
||||||
|
$TemplatePath = Read-Host "Entre un chemin pour le VHD (a pour annuler)"
|
||||||
|
|
||||||
|
if ($TemplatePath -eq "a") {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
} until (Test-Path $TemplatePath -ErrorAction SilentlyContinue)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$VMName = Read-Host "Entrez un Nom pour votre VM"
|
||||||
|
$VMSwitch = Read-Host "Entrez un le nom du swith pour votre VM"
|
||||||
|
New-Item -Path (Join-Path $HypervConfig.VirtualMachinePath ($VMName + "\Virtual Hard Disks")) -ItemType Directory -Force
|
||||||
|
$VhdPath = (Join-Path $HypervConfig.VirtualMachinePath ($VMName + "\Virtual Hard Disks"))
|
||||||
|
|
||||||
|
if (!(Test-Path $TemplatePath -ErrorAction SilentlyContinue)) {
|
||||||
|
$VhdSize = Read-Host "Entrez la capacité pour le VHDx (avec Gb à la fin)"
|
||||||
|
$VhdFile = $VMName + ".vhdx"
|
||||||
|
New-VM -Name $VMName -Generation 2 -SwitchName $VMSwitch -Path $HypervConfig.VirtualMachinePath -NewVHDPath (Join-Path $VhdPath $VhdFile) -NewVHDSizeBytes ($VhdSize)
|
||||||
|
}
|
||||||
|
elseif (Test-Path $TemplatePath -ErrorAction SilentlyContinue) {
|
||||||
|
Start-BitsTransfer -Source $TemplatePath -Destination $VhdPath
|
||||||
|
$VhdFile = Split-Path $TemplatePath -leaf
|
||||||
|
New-VM -Name $VMName -Generation 2 -SwitchName $VMSwitch -Path $HypervConfig.VirtualMachinePath -VHDPath (Join-Path $VhdPath $VhdFile)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
New-VM -Name $VMName -Generation 2 -SwitchName $VMSwitch -Path $HypervConfig.VirtualMachinePath -NoVHD
|
||||||
|
}
|
||||||
|
|
||||||
|
$VMProc = Read-Host "Entrez le nombre de processeurs pour votre VM"
|
||||||
|
$VMRam = Read-Host "Entrez la RAM pour votre VM (avec Gb à la fin) "
|
||||||
|
|
||||||
|
Set-VM -Name $VMName -CheckpointType Production -AutomaticCheckpointsEnabled $false -AutomaticStartAction Start -AutomaticStopAction Shutdown -ProcessorCount $VMProc -MemoryStartupBytes ($VMRam)
|
||||||
|
Set-VMFirmware $VMName -EnableSecureBoot On -BootOrder ((Get-VMFirmware $VMName).BootOrder[1]), ((Get-VMFirmware $VMName).BootOrder[0])
|
||||||
|
|
||||||
|
Enable-VMIntegrationService -VMName $VMName -Name "Guest Service Interface"
|
||||||
|
|
||||||
|
$VMDC = Read-Host "Est-ce que votre VM est un controlleur de domaine ? (o pour oui, non par défaut) "
|
||||||
|
if ($VMDC -eq "o") {
|
||||||
|
Disable-VMIntegrationService -VMName $VMName -Name "Time Synchronization"
|
||||||
|
}
|
||||||
|
|
||||||
|
$VMHdd = Read-Host "Est-ce que vous souhaitez ajouter un autre VHD à la VM ? (o pour oui, non par défaut) "
|
||||||
|
if ($VMHdd -eq "o") {
|
||||||
|
|
||||||
|
$VhdName = Read-Host "Entrez un nom pour le VHDx (avec .vhdx)"
|
||||||
|
$VhdSize = Read-Host "Entrez la capacité pour le VHDx (en Gb)"
|
||||||
|
|
||||||
|
New-VHD -Path (Join-Path $VhdPath $VhdName) -SizeBytes $VhdSize -Dynamic
|
||||||
|
|
||||||
|
Add-VMHardDiskDrive -VMName $VMName -Path (Join-Path $VhdPath $VhdName)
|
||||||
|
}
|
||||||
|
|
||||||
|
$VMOs = Read-Host "Quel est l'OS de votre VM (l pour linux, Windows par défaut) "
|
||||||
|
|
||||||
|
switch ($VMOs) {
|
||||||
|
"l" {
|
||||||
|
|
||||||
|
}
|
||||||
|
Default {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$StartVM = Read-Host "Voulez-Vous démarrer la VM ? (o pour oui, non par défaut) "
|
||||||
|
|
||||||
|
if ($StartVM -eq "o") {
|
||||||
|
Start-VM $VMName
|
||||||
|
}
|
1
Hyper-V/README.md
Normal file
1
Hyper-V/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Hyper-V
|
22
Kemp/KEMP.ps1
Normal file
22
Kemp/KEMP.ps1
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential bal -Verbose
|
||||||
|
|
||||||
|
# Set variables
|
||||||
|
$ContentMatchingRuleName = "$CRPCEN_Authentic"
|
||||||
|
$ContentMatchingRulePattern = "/^\/$CRPCEN-Authentic.*/"
|
||||||
|
$VirtualServiceName = "10.80.20.2"
|
||||||
|
$VirtualServicePort = 443
|
||||||
|
$RealServerName = "xx-P-IIS-011.xx.net"
|
||||||
|
$RealServerPort = 80
|
||||||
|
$CheckUrl = "xx.xx.com"
|
||||||
|
|
||||||
|
# Create Content Rule
|
||||||
|
New-AdcContentRule -RuleName $ContentMatchingRuleName -Header Host -MatchType regex -Pattern $ContentMatchingRulePattern -NoCase true
|
||||||
|
|
||||||
|
# Create Sub Virtual Service
|
||||||
|
$NASVS = New-AdcSubVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||||
|
$NASVSIndex = ($NASVS.Data.VS.SubVS[-1]).VSIndex
|
||||||
|
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckHost $RealServerName -CheckPort $RealServerPort -CheckType http -CheckUrl $CheckUrl -CheckUse1_1 1 -Nickname $CheckUrl -VSType http -Weight 1000
|
||||||
|
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckHost $RealServerName -CheckPort $RealServerPort -CheckType http -CheckUrl $CheckUrl -CheckUse1_1 1 -Nickname $CheckUrl -VSType http -Weight 900
|
||||||
|
|
||||||
|
# Add Real Server to Sub Virtual Service (disabled)
|
||||||
|
New-AdcRealServer -RealServer $RealServerName -RealServerPort $RealServerPort -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 1000
|
153
Kemp/KEMP2.ps1
Normal file
153
Kemp/KEMP2.ps1
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
Function KempAuthenticDuo {
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
PARAM (
|
||||||
|
[Parameter(Mandatory=$true)][String] $CRPCEN,
|
||||||
|
[Parameter(Mandatory=$true)][String] $PortPROXY,
|
||||||
|
[Parameter(Mandatory=$true)][String] $Principal,
|
||||||
|
[Parameter(Mandatory=$true)][String] $Secondaire,
|
||||||
|
[Parameter()][String] $Description = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
#Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||||
|
|
||||||
|
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||||
|
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||||
|
|
||||||
|
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||||
|
|
||||||
|
#Variable
|
||||||
|
$ContentMatchingRuleName = $CRPCEN+"_ui_Authentic"
|
||||||
|
$ContentMatchingRulePattern = "/^\/$CRPCEN-ui-Authentic./"
|
||||||
|
$VirtualServiceName = "10.80.20.2"
|
||||||
|
$VirtualServicePort = 443
|
||||||
|
$CheckedPort = $Port
|
||||||
|
$SubVSName = "$CRPCEN-ui-Authentic"
|
||||||
|
$Url = "/$CRPCEN-ui-Authentic/kemp.jsp"
|
||||||
|
$AllowedVirtualHosts = "www.cloud-fichorga.fr"
|
||||||
|
$AllowedVirtualDirectories = "/$CRPCEN-ui-Authentic*"
|
||||||
|
$SchedulingMethod = "fixed"
|
||||||
|
#$HTTPHeaderModifications = ""
|
||||||
|
|
||||||
|
# Creation Rules & Checking > Content Rules
|
||||||
|
New-AdcContentRule -RuleName $ContentMatchingRuleName -MatchType regex -Pattern $ContentMatchingRulePattern -NoCase 1
|
||||||
|
|
||||||
|
# Create Sub Virtual Service
|
||||||
|
$NASVS = New-AdcSubVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||||
|
$NASVSIndex = ($NASVS.Data.VS.SubVS[-1]).VSIndex
|
||||||
|
|
||||||
|
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckPort $PortPROXY -CheckType http -CheckUrl $Url -CheckUse1_1 0 -Nickname $SubVSName -VSType http -Weight 1000 -ESPEnabled $True -AllowedHosts $AllowedVirtualHosts -AllowedDirectories $AllowedVirtualDirectories -Schedule $SchedulingMethod -CheckUseGet 1 -AddVia 2 -StandByAddr 10.101.20.21 -StandByPort 8015
|
||||||
|
|
||||||
|
New-AdcRealServer -RealServer $Principal -RealServerPort $PortPROXY -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 800
|
||||||
|
New-AdcRealServer -RealServer $Secondaire -RealServerPort $PortPROXY -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 700
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Function KempAuthenticQuatro {
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
PARAM (
|
||||||
|
[Parameter(Mandatory=$true)][String] $CRPCEN,
|
||||||
|
[Parameter(Mandatory=$true)][String] $PortPROXY1,
|
||||||
|
[Parameter(Mandatory=$true)][String] $PortPROXY2,
|
||||||
|
[Parameter(Mandatory=$true)][String] $Principal,
|
||||||
|
[Parameter(Mandatory=$true)][String] $Secondaire,
|
||||||
|
[Parameter()][String] $Description = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
#Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||||
|
|
||||||
|
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||||
|
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||||
|
|
||||||
|
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||||
|
|
||||||
|
#Variable
|
||||||
|
$ContentMatchingRuleName = $CRPCEN+"_ui_Authentic"
|
||||||
|
$ContentMatchingRulePattern = "/^\/$CRPCEN-ui-Authentic./"
|
||||||
|
$VirtualServiceName = "10.80.20.2"
|
||||||
|
$VirtualServicePort = 443
|
||||||
|
$CheckedPort = $Port
|
||||||
|
$SubVSName = "$CRPCEN-ui-Authentic"
|
||||||
|
$Url = "/$CRPCEN-ui-Authentic/kemp.jsp"
|
||||||
|
$AllowedVirtualHosts = "www.cloud-fichorga.fr"
|
||||||
|
$AllowedVirtualDirectories = "/$CRPCEN-ui-Authentic*"
|
||||||
|
$SchedulingMethod = "fixed"
|
||||||
|
#$HTTPHeaderModifications = ""
|
||||||
|
|
||||||
|
# Creation Rules & Checking > Content Rules
|
||||||
|
New-AdcContentRule -RuleName $ContentMatchingRuleName -MatchType regex -Pattern $ContentMatchingRulePattern -NoCase 1
|
||||||
|
|
||||||
|
# Create Sub Virtual Service
|
||||||
|
$NASVS = New-AdcSubVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||||
|
$NASVSIndex = ($NASVS.Data.VS.SubVS[-1]).VSIndex
|
||||||
|
|
||||||
|
Set-AdcSubVirtualService -SubVSIndex $NASVSIndex -CheckPort $PortPROXY1 -CheckType http -CheckUrl $Url -CheckUse1_1 0 -Nickname $SubVSName -VSType http -Weight 1000 -ESPEnabled $True -AllowedHosts $AllowedVirtualHosts -AllowedDirectories $AllowedVirtualDirectories -Schedule $SchedulingMethod -CheckUseGet 1 -AddVia 2 -StandByAddr 10.101.20.21 -StandByPort 8015
|
||||||
|
|
||||||
|
New-AdcRealServer -RealServer $Principal -RealServerPort $PortPROXY1 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 1000
|
||||||
|
New-AdcRealServer -RealServer $Principal -RealServerPort $PortPROXY2 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 800
|
||||||
|
|
||||||
|
Start-Sleep -s 5
|
||||||
|
|
||||||
|
New-AdcRealServer -RealServer $Secondaire -RealServerPort $PortPROXY1 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 900
|
||||||
|
New-AdcRealServer -RealServer $Secondaire -RealServerPort $PortPROXY2 -Enable $true -Forward nat -VSIndex $NASVSIndex -Weight 700
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||||
|
|
||||||
|
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||||
|
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||||
|
|
||||||
|
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||||
|
|
||||||
|
Foreach($Line in Get-Content C:\tmp\CRPCEN.txt) {
|
||||||
|
|
||||||
|
If ($Line -ne $null) {
|
||||||
|
$Line | foreach { $Line = $_ -split ';'
|
||||||
|
$CRPCEN = $Line[0]
|
||||||
|
$Serveur1 = $Line[1]
|
||||||
|
$PortServeur1 = $Line[2]
|
||||||
|
$PoidServeur1 = $Line[3]
|
||||||
|
$Serveur2 = $Line[4]
|
||||||
|
$PortServeur2 = $Line[5]
|
||||||
|
$PoidServeur2 = $Line[6]
|
||||||
|
$Serveur3 = $Line[7]
|
||||||
|
$PortServeur3 = $Line[8]
|
||||||
|
$PoidServeur3 = $Line[9]
|
||||||
|
$Serveur4 = $Line[10]
|
||||||
|
$PortServeur4 = $Line[11]
|
||||||
|
$PoidServeur4 = $Line[12]
|
||||||
|
} }
|
||||||
|
|
||||||
|
write-host "$CRPCEN"
|
||||||
|
|
||||||
|
If ($Serveur3 -ne '') {
|
||||||
|
write-host "ici" $Serveur3
|
||||||
|
|
||||||
|
If ( $PoidServeur1 -lt $PoidServeur2 ) {
|
||||||
|
write-host $CRPCEN $PortServeur1 $PortServeur2 $Serveur3 $Serveur1
|
||||||
|
KempAuthenticQuatro $CRPCEN $PortServeur1 $PortServeur2 $Serveur3 $Serveur1
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
write-host $CRPCEN $PortServeur1 $PortServeur2 $Serveur1 $Serveur3
|
||||||
|
KempAuthenticQuatro $CRPCEN $PortServeur1 $PortServeur2 $Serveur1 $Serveur3
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
write-host "la" $Serveur3
|
||||||
|
|
||||||
|
If ( $PoidServeur1 -lt $PoidServeur2 ) {
|
||||||
|
write-host $CRPCEN $PortServeur1 $Serveur2 $Serveur1
|
||||||
|
KempAuthenticDuo $CRPCEN $PortServeur1 $Serveur2 $Serveur1
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
write-host $CRPCEN $PortServeur1 $Serveur1 $Serveur2
|
||||||
|
KempAuthenticDuo $CRPCEN $PortServeur1 $Serveur1 $Serveur2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Sleep -s 10
|
||||||
|
|
||||||
|
}
|
91
Kemp/Modification-KEMP.ps1
Normal file
91
Kemp/Modification-KEMP.ps1
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
Import-Module Kemp.LoadBalancer.Powershell.psd1 -errorAction SilentlyContinue -Verbose
|
||||||
|
|
||||||
|
$lm49 = ConvertTo-SecureString "F1ch0rg@PM$" -AsPlainText -Force
|
||||||
|
$creds = New-Object System.Management.Automation.PSCredential("bal", $lm49)
|
||||||
|
|
||||||
|
Initialize-LmConnectionParameters -Address 10.101.50.1 -LBPort 443 -Credential $creds -Verbose
|
||||||
|
|
||||||
|
#Variable
|
||||||
|
$VirtualServiceName = "10.80.20.2"
|
||||||
|
$VirtualServicePort = 443
|
||||||
|
|
||||||
|
$Liste = Get-AdcVirtualService -VirtualService $VirtualServiceName -VSPort $VirtualServicePort -VSProtocol tcp
|
||||||
|
|
||||||
|
$VSIndex = $Liste.Data.VS.subVS.VSIndex
|
||||||
|
|
||||||
|
Foreach ($VSClient in $VSIndex) {
|
||||||
|
$NASVS = Get-AdcSubVirtualService -SubVSIndex $VSClient
|
||||||
|
|
||||||
|
$Temp = $NASVS.DATA.VS.NickName
|
||||||
|
$IndexKemp = $NASVS.DATA.VS.index
|
||||||
|
|
||||||
|
$Temp | Foreach { $Temp = $_ -split '-'
|
||||||
|
$ValueCRPCEN = $Temp[0]
|
||||||
|
$ValueApp = $Temp[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
#foreach ($Ligne Get-Content clients.csv) {
|
||||||
|
Foreach($Ligne in [System.IO.File]::ReadLines("D:\Data\Administration\app-2.csv")) {
|
||||||
|
$Ligne | Foreach { $Ligne = $_ -split ';'
|
||||||
|
$KempCRPCEN = $Ligne[0]
|
||||||
|
$KempApp = $Ligne[1]
|
||||||
|
$KempPrincipal = $Ligne[2]
|
||||||
|
$KempSecondaire = $Ligne[3]
|
||||||
|
$KempPort = $Ligne[4]
|
||||||
|
}
|
||||||
|
|
||||||
|
If($KempCRPCEN -eq $ValueCRPCEN) {
|
||||||
|
|
||||||
|
If($KempApp -eq $ValueApp) {
|
||||||
|
|
||||||
|
#write-host $KempCRPCEN"/"$KempApp"/"$KempPrincipal"/"$KempSecondaire"/"$KempPort"/"$NASVS.DATA.VS.index
|
||||||
|
|
||||||
|
If (Test-Connection $KempPrincipal -count 1 -Quiet) {
|
||||||
|
$ipV4Principal = Test-Connection "$KempPrincipal" -count 1 | select Ipv4Address
|
||||||
|
|
||||||
|
If ($ipV4Principal -ne $null) {
|
||||||
|
$ipV4Principal | foreach { $ipV4Principal = $_ -split '='
|
||||||
|
$ipV4PrincipalCLOUD = $ipV4Principal[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ipV4PrincipalCLOUD = $ipV4PrincipalCLOUD -replace " ", ""
|
||||||
|
$ipV4PrincipalCLOUD = $ipV4PrincipalCLOUD -replace "}", ""
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$ipV4Principal = "0.0.0.0"
|
||||||
|
$ipV4PrincipalCLOUD = "0.0.0.0"
|
||||||
|
}
|
||||||
|
#write-host "$ipV4PrincipalCLOUD"
|
||||||
|
}
|
||||||
|
|
||||||
|
If (Test-Connection $KempSecondaire -count 1 -Quiet) {
|
||||||
|
$ipV4Secondaire = Test-Connection "$KempSecondaire" -count 1 | select Ipv4Address
|
||||||
|
|
||||||
|
If ($ipV4Secondaire -ne $null) {
|
||||||
|
$ipV4Secondaire | foreach { $ipV4Secondaire = $_ -split '='
|
||||||
|
$ipV4SecondaireCLOUD = $ipV4Secondaire[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
$ipV4SecondaireCLOUD = $ipV4SecondaireCLOUD -replace " ", ""
|
||||||
|
$ipV4SecondaireCLOUD = $ipV4SecondaireCLOUD -replace "}", ""
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$ipV4Secondaire = "0.0.0.0"
|
||||||
|
$ipV4SecondaireCLOUD = "0.0.0.0"
|
||||||
|
}
|
||||||
|
#write-host "$ipV4SecondaireCLOUD"
|
||||||
|
}
|
||||||
|
write-host $KempCRPCEN"-"$KempApp":"$ipV4PrincipalCLOUD"/"$ipV4SecondaireCLOUD"-"$KempPort"-"$IndexKemp
|
||||||
|
New-AdcRealServer -RealServer $ipV4PrincipalCLOUD -RealServerPort $KempPort -Enable $true -Forward nat -VSIndex $IndexKemp -Weight 800
|
||||||
|
New-AdcRealServer -RealServer $ipV4SecondaireCLOUD -RealServerPort $KempPort -Enable $true -Forward nat -VSIndex $IndexKemp -Weight 700
|
||||||
|
Start-Sleep -s 5
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
0
Kemp/README.md
Normal file
0
Kemp/README.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,120 @@
|
|||||||
|
#
|
||||||
|
# Module manifest for module 'Kemp.LoadBalancer.Powershell'
|
||||||
|
#
|
||||||
|
# Generated by: KEMP
|
||||||
|
#
|
||||||
|
# Generated on: Nov 30 2017
|
||||||
|
#
|
||||||
|
|
||||||
|
@{
|
||||||
|
|
||||||
|
# Script module or binary module file associated with this manifest.
|
||||||
|
RootModule = 'Kemp.LoadBalancer.Powershell.psm1'
|
||||||
|
|
||||||
|
# Version number of this module.
|
||||||
|
ModuleVersion = '7.2.40.0'
|
||||||
|
|
||||||
|
# ID used to uniquely identify this module
|
||||||
|
GUID = 'fb76aa2c-d5f7-11e7-b122-000af7388c80'
|
||||||
|
|
||||||
|
# Author of this module
|
||||||
|
Author = 'Fabrizio Carpin'
|
||||||
|
|
||||||
|
# Company or vendor of this module
|
||||||
|
CompanyName = 'KEMP Technologies'
|
||||||
|
|
||||||
|
# Copyright statement for this module
|
||||||
|
Copyright = '(c) 2017. All rights reserved.'
|
||||||
|
|
||||||
|
# Description of the functionality provided by this module
|
||||||
|
Description = 'KEMP Load Balancer Powershell Module'
|
||||||
|
|
||||||
|
# Minimum version of the Windows PowerShell engine required by this module
|
||||||
|
PowerShellVersion = '2.0'
|
||||||
|
|
||||||
|
# Name of the Windows PowerShell host required by this module
|
||||||
|
# PowerShellHostName = ''
|
||||||
|
|
||||||
|
# Minimum version of the Windows PowerShell host required by this module
|
||||||
|
PowerShellHostVersion = '2.0'
|
||||||
|
|
||||||
|
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
||||||
|
DotNetFrameworkVersion = '2.0'
|
||||||
|
|
||||||
|
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
|
||||||
|
CLRVersion = '2.0.50727.0'
|
||||||
|
|
||||||
|
# Processor architecture (None, X86, Amd64) required by this module
|
||||||
|
ProcessorArchitecture = 'None'
|
||||||
|
|
||||||
|
# Modules that must be imported into the global environment prior to importing this module
|
||||||
|
# RequiredModules = @()
|
||||||
|
|
||||||
|
# Assemblies that must be loaded prior to importing this module
|
||||||
|
RequiredAssemblies = @()
|
||||||
|
|
||||||
|
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
|
||||||
|
ScriptsToProcess = @()
|
||||||
|
|
||||||
|
# Type files (.ps1xml) to be loaded when importing this module
|
||||||
|
TypesToProcess = @()
|
||||||
|
|
||||||
|
# Format files (.ps1xml) to be loaded when importing this module
|
||||||
|
FormatsToProcess = @()
|
||||||
|
|
||||||
|
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
|
||||||
|
NestedModules = @()
|
||||||
|
|
||||||
|
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
|
||||||
|
FunctionsToExport = '*'
|
||||||
|
|
||||||
|
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||||
|
CmdletsToExport = '*'
|
||||||
|
|
||||||
|
# Variables to export from this module
|
||||||
|
VariablesToExport = '*'
|
||||||
|
|
||||||
|
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
|
||||||
|
AliasesToExport = '*'
|
||||||
|
|
||||||
|
# DSC resources to export from this module
|
||||||
|
# DscResourcesToExport = @()
|
||||||
|
|
||||||
|
# List of all modules packaged with this module
|
||||||
|
ModuleList = @()
|
||||||
|
|
||||||
|
# List of all files packaged with this module
|
||||||
|
FileList = @()
|
||||||
|
|
||||||
|
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
|
||||||
|
PrivateData = @{
|
||||||
|
|
||||||
|
PSData = @{
|
||||||
|
|
||||||
|
# Tags applied to this module. These help with module discovery in online galleries.
|
||||||
|
# Tags = @()
|
||||||
|
|
||||||
|
# A URL to the license for this module.
|
||||||
|
# LicenseUri = ''
|
||||||
|
|
||||||
|
# A URL to the main website for this project.
|
||||||
|
# ProjectUri = ''
|
||||||
|
|
||||||
|
# A URL to an icon representing this module.
|
||||||
|
# IconUri = ''
|
||||||
|
|
||||||
|
# ReleaseNotes of this module
|
||||||
|
ReleaseNotes = 'BUILD: 1159'
|
||||||
|
|
||||||
|
} # End of PSData hashtable
|
||||||
|
|
||||||
|
} # End of PrivateData hashtable
|
||||||
|
|
||||||
|
# HelpInfo URI of this module
|
||||||
|
# HelpInfoURI = ''
|
||||||
|
|
||||||
|
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
|
||||||
|
# DefaultCommandPrefix = ''
|
||||||
|
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
7771
Kemp/modules/Kemp.LoadBalancer.Powershell/deprecated.psm1
Normal file
7771
Kemp/modules/Kemp.LoadBalancer.Powershell/deprecated.psm1
Normal file
File diff suppressed because it is too large
Load Diff
92
Microsoft Azure/Azure-Migrate-Test.ps1
Normal file
92
Microsoft Azure/Azure-Migrate-Test.ps1
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
|
||||||
|
param (
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
|
||||||
|
[string]
|
||||||
|
|
||||||
|
$SubsID,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
|
||||||
|
[string]
|
||||||
|
|
||||||
|
$FilePath = "$Env:USERPROFILE\Desktop\AzureMoveResourcesReport.docx"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
Import-Module Az
|
||||||
|
Import-Module PSWriteWord
|
||||||
|
|
||||||
|
|
||||||
|
if ($SubsID) {
|
||||||
|
|
||||||
|
Connect-AzAccount -Subscription $SubsID | Out-Null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
Connect-AzAccount | Out-Null
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$WordDocument = New-WordDocument $FilePath
|
||||||
|
|
||||||
|
#$res = Invoke-WebRequest -Uri https://raw.githubusercontent.com/tfitzmac/resource-capabilities/master/move-support-resources.csv -Method Get
|
||||||
|
#$list = Convertfrom-csv -InputObject $res.Content
|
||||||
|
|
||||||
|
$list = Import-Csv -Path "move-support-resources.csv"
|
||||||
|
|
||||||
|
$resGroups = Get-AzResourceGroup
|
||||||
|
|
||||||
|
foreach ($group in $resGroups) {
|
||||||
|
|
||||||
|
$resObjs = Get-AzResource -ResourceGroupName $group.ResourceGroupName
|
||||||
|
|
||||||
|
Add-WordText -WordDocument $WordDocument -Text "`nResources Group: $($group.ResourceGroupName)" -FontSize 20 -Color Blue -Supress $True
|
||||||
|
Add-WordLine -WordDocument $WordDocument -LineColor Blue -LineType double -Supress $True
|
||||||
|
|
||||||
|
foreach ($obj in $resObjs) {
|
||||||
|
|
||||||
|
$resName = $obj.Name
|
||||||
|
|
||||||
|
$resType = $obj.ResourceType
|
||||||
|
|
||||||
|
$resID = $obj.ResourceId
|
||||||
|
|
||||||
|
$resList = $list -match $obj.ResourceType
|
||||||
|
|
||||||
|
if ($resList) {
|
||||||
|
|
||||||
|
$i = [int]$resList[0].'Move Subscription'
|
||||||
|
|
||||||
|
if ($i -ne 1) {
|
||||||
|
|
||||||
|
Write-Host "`nOBJECT CAN _NOT_ BE MIGRATED: $resName has type $resType ($resID)" -ForegroundColor Yellow -BackgroundColor DarkRed
|
||||||
|
Add-WordText -WordDocument $WordDocument -Text "`nOBJECT CAN _NOT_ BE MIGRATED: $resName has type $resType ($resID)" -FontSize 12 -Color Red -Supress $True
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
Write-Host "`nOBJECT SUPPORTED FOR MIGRATION: $resName has type $resType ($resID)" -ForegroundColor Green
|
||||||
|
Add-WordText -WordDocument $WordDocument -Text "`nOBJECT SUPPORTED FOR MIGRATION: $resName has type $resType ($resID)" -FontSize 12 -Color Green -Supress $True
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
Write-Host "UNKNOWN OBJECT's TYPE: $resName has type $resType ($resID)" -ForegroundColor DarkRed -BackgroundColor Yellow
|
||||||
|
Add-WordText -WordDocument $WordDocument -Text "UNKNOWN OBJECT's TYPE: $resName has type $resType ($resID)" -FontSize 12 -Color Yellow -Supress $True
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Save-WordDocument $WordDocument -Language 'en-US' -Supress $True -OpenDocument:$true
|
30
Microsoft Azure/Get-Storagelength.ps1
Normal file
30
Microsoft Azure/Get-Storagelength.ps1
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#Reprise d'un exemple officiel pour calculer la taile d'un conteneur Blob sur Azure
|
||||||
|
#Attention les opérations de lecture sont facturables !
|
||||||
|
|
||||||
|
# these are for the storage account to be used
|
||||||
|
$resourceGroup = ""
|
||||||
|
$storageAccountName = ""
|
||||||
|
$containerName = ""
|
||||||
|
|
||||||
|
# get a reference to the storage account and the context
|
||||||
|
$storageAccount = Get-AzStorageAccount `
|
||||||
|
-ResourceGroupName $resourceGroup `
|
||||||
|
-Name $storageAccountName
|
||||||
|
$ctx = $storageAccount.Context
|
||||||
|
|
||||||
|
# get a list of all of the blobs in the container
|
||||||
|
$listOfBLobs = Get-AzStorageBlob -Container $ContainerName -Context $ctx
|
||||||
|
|
||||||
|
# zero out our total
|
||||||
|
$length = 0
|
||||||
|
|
||||||
|
# this loops through the list of blobs and retrieves the length for each blob
|
||||||
|
# and adds it to the total
|
||||||
|
$listOfBlobs | ForEach-Object { $length = $length + $_.Length }
|
||||||
|
|
||||||
|
# output the blobs and their sizes and the total
|
||||||
|
Write-Host "List of Blobs and their size (length)"
|
||||||
|
Write-Host " "
|
||||||
|
$listOfBlobs | select Name, Length
|
||||||
|
Write-Host " "
|
||||||
|
Write-Host "Total Length = " $length
|
1
Microsoft Azure/README.md
Normal file
1
Microsoft Azure/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Microsoft Azure
|
61
MsSQL/script.ps1
Normal file
61
MsSQL/script.ps1
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
Function QuerySQLServer([string]$DBServer, [string]$DBName, [string]$Query) {
|
||||||
|
Try {
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
$resultsDataTable = New-Object System.Data.DataTable
|
||||||
|
|
||||||
|
$cn = new-object System.Data.SqlClient.SqlConnection("Data Source=$DBServer;Integrated Security=SSPI;Initial Catalog=$DBName")
|
||||||
|
$cn.open()
|
||||||
|
|
||||||
|
$cmd = new-object "System.Data.SqlClient.SqlCommand" ($Query , $cn)
|
||||||
|
$reader = $cmd.ExecuteReader()
|
||||||
|
|
||||||
|
$resultsDataTable.Load($reader)
|
||||||
|
|
||||||
|
$cn.Close()
|
||||||
|
|
||||||
|
return $resultsDataTable
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
write-host $_.Exception.Message
|
||||||
|
$_.Exception.Message >> "d:\error.log"
|
||||||
|
}
|
||||||
|
Finally {
|
||||||
|
$ErrorActionPreference = "Continue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cls
|
||||||
|
|
||||||
|
$bReturnOK = $TRUE
|
||||||
|
$bReturnCritical = $FALSE
|
||||||
|
$bReturnWarning = $FALSE
|
||||||
|
$returnStateOK = 0
|
||||||
|
$returnStateWarning = 1
|
||||||
|
$returnStateCritical = 2
|
||||||
|
$returnStateUnknown = 3
|
||||||
|
|
||||||
|
$strCritical = ""
|
||||||
|
$strWarning = ""
|
||||||
|
$DataTexte = ""
|
||||||
|
|
||||||
|
$ComputerName = $env:COMPUTERNAME
|
||||||
|
|
||||||
|
$Liste = QuerySQLServer "$ComputerName" "dhb_prd" "SELECT A.session_id, Db_Name(database_id) AS [database], DateDiff(MINUTE, A.connect_time, GetDate()) AS [Connected (mins)], num_reads, num_writes, login_name, Text AS SQL FROM sys.dm_exec_connections AS A INNER JOIN sys.dm_exec_sessions AS B ON A.session_id = B.session_id INNER JOIN sys.sysprocesses AS s ON s.spid = A.session_id OUTER APPLY::fn_get_sql(sql_handle)"
|
||||||
|
$Liste | Format-Table | Out-String|% {Write-Host $_}
|
||||||
|
|
||||||
|
$DataTexte = $Liste.login_name
|
||||||
|
|
||||||
|
If ($bReturnCritical) {
|
||||||
|
write-output $strCritical
|
||||||
|
write-output $strWarning "|" $DataTexte
|
||||||
|
exit $returnStateCritical
|
||||||
|
}
|
||||||
|
Elseif ($bReturnWarning) {
|
||||||
|
write-output $strWarning "|" $DataTexte
|
||||||
|
exit $returnStateWarning
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
write-output "OK - Nombre de requete en cours : $DataTexte | 'NbrequetesEnCours'=$DataTexte "
|
||||||
|
exit $returnStateOK
|
||||||
|
}
|
71
MySQL/scripts.ps1
Normal file
71
MySQL/scripts.ps1
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : <Date>
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
[void][system.reflection.Assembly]::LoadFrom("C:\Program Files (x86)\MySQL\MySQL Connector NET 8.0.32\Assemblies\v4.5.2\MySql.Data.dll")
|
||||||
|
|
||||||
|
# Bibliothèques de fonctions requises
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "<script_name>.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
Start-Transcript -Path $sLogFile -NoClobber
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------------------------------------------[Debut Du Script]---------------------------------------------------------
|
||||||
|
|
||||||
|
$Mysqlhost= "10.78.56.51"
|
||||||
|
$Mysqluser= "toor"
|
||||||
|
$Mysqlpass= "jN7VKeR3jjexMLzG"
|
||||||
|
$Mysqldatabase= "bugtracker"
|
||||||
|
|
||||||
|
$Connection = [MySql.Data.MySqlClient.MySqlConnection]@{ConnectionString="server=$Mysqlhost;uid=$Mysqluser;pwd=$Mysqlpass;database=$Mysqldatabase"}
|
||||||
|
$Connection.Open()
|
||||||
|
$sql = New-Object MySql.Data.MySqlClient.MySqlCommand
|
||||||
|
$sql.Connection = $Connection
|
||||||
|
|
||||||
|
$sql.CommandText = "SELECT id,summary FROM mantis_bug_table where summary like '%Opcon%'"
|
||||||
|
$myreader = $sql.ExecuteReader()
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Fin Du Script]----------------------------------------------------------
|
||||||
|
|
||||||
|
Stop-Transcript
|
||||||
|
|
||||||
|
|
||||||
|
|
119
NRPE/Check-AD-Accounts-Lock.ps1
Normal file
119
NRPE/Check-AD-Accounts-Lock.ps1
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : 17/11/2022
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[string]$action = "LockedOut",
|
||||||
|
[string]$searchBase = "",
|
||||||
|
[string]$searchScope = "Subtree",
|
||||||
|
[int]$maxWarn = 5,
|
||||||
|
[int]$maxCrit = 10
|
||||||
|
)
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "Check-AD-Account-Lock.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
Start-Transcript -Path $sLogFile -NoClobber
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------------------------------------------[Debut Du Script]---------------------------------------------------------
|
||||||
|
|
||||||
|
# check that powershell ActiveDirectory module is present
|
||||||
|
If(Get-Module -Name "ActiveDirectory" -ListAvailable) {
|
||||||
|
Try {
|
||||||
|
Import-Module -Name ActiveDirectory
|
||||||
|
}
|
||||||
|
Catch {
|
||||||
|
Write-Host "CRITICAL: Missing PowerShell ActiveDirectory module"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
Write-Host "CRITICAL: Missing PowerShell ActiveDirectory module"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
# check params if provided
|
||||||
|
If($action -notmatch "^(AccountDisabled|AccountExpired|AccountExpiring|AccountInactive|LockedOut|PasswordExpired|PasswordNeverExpires)$") {
|
||||||
|
Write-Host "CRITICAL: action parameter can only be AccountDisabled,AccountExpired,AccountExpiring,AccountInactive,LockedOut,PasswordExpired,PasswordNeverExpires. Provided $action"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
If($searchScope -notmatch "^(Base|OneLevel|Subtree)$") {
|
||||||
|
Write-Host "CRITICAL: searchScope parameter can only be Base,OneLevel,Subtree. Provided $searchScope"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
|
||||||
|
If(($searchBase -ne "") -and $searchBase -ne ((Get-ADDomain).DistinguishedName)) {
|
||||||
|
$search=Get-ADObject -Filter 'ObjectClass -eq "OrganizationalUnit" -and DistinguishedName -eq $searchBase'
|
||||||
|
|
||||||
|
If ($search.Count -ne 1) {
|
||||||
|
Write-Host "CRITICAL: SearchBase not found or duplicate. Provided $searchBase"
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$searchBase=(Get-ADDomain).DistinguishedName
|
||||||
|
}
|
||||||
|
|
||||||
|
$command="Search-ADAccount -"+$action+" -SearchBase '"+$searchBase+"' -SearchScope "+$searchScope
|
||||||
|
$result=invoke-expression $command
|
||||||
|
|
||||||
|
If($result.Count -gt $maxCrit) {
|
||||||
|
$state="CRITICAL"
|
||||||
|
$exitcode=2
|
||||||
|
}
|
||||||
|
Elseif($result.Count -gt $maxWarn) {
|
||||||
|
$state="WARNING"
|
||||||
|
$exitcode=1
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$state="OK"
|
||||||
|
$exitcode=0
|
||||||
|
}
|
||||||
|
|
||||||
|
$output=$state+": "+$result.Count+" "+$action+"|"+$action+"="+$result.Count+";"+$maxWarn+";"+$maxCrit
|
||||||
|
Write-Host $output
|
||||||
|
exit $exitcode
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Fin Du Script]----------------------------------------------------------
|
||||||
|
|
||||||
|
Stop-Transcript
|
76
NRPE/Check-NetLbfoTeamMember.ps1
Normal file
76
NRPE/Check-NetLbfoTeamMember.ps1
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : <Date>
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
# Bibliothèques de fonctions requises
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "<script_name>.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
Start-Transcript -Path $sLogFile -NoClobber
|
||||||
|
|
||||||
|
# Initial state
|
||||||
|
$ExitCode = 0
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------------------------------------------[Debut Du Script]---------------------------------------------------------
|
||||||
|
|
||||||
|
# Get the status
|
||||||
|
$LbfoTeamMemberOutput = Get-NetLbfoTeamMember | Select-Object Name,FailureReason,Team
|
||||||
|
$LbfoTeamMemberCount = (Get-NetLbfoTeamMember).Count
|
||||||
|
|
||||||
|
# Normal state : AdministrativeDecision / NoFailure
|
||||||
|
Foreach($Member in $LbfoTeamMemberOutput) {
|
||||||
|
If(!(($Member.FailureReason -eq "NoFailure") -or ($Member.FailureReason -eq "AdministrativeDecision"))) {
|
||||||
|
$ExitCode = 2
|
||||||
|
Write-Output "CRITICAL: Member $($Member.Name) of the team $($Member.Team) state is $($Member.FailureReason)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Evaluate final exit code result for all passed checks.
|
||||||
|
If ($ExitCode -eq 0) {
|
||||||
|
Write-Output "OK: Members ($LbfoTeamMemberCount) of all LBFO teams are OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
exit $ExitCode
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Fin Du Script]----------------------------------------------------------
|
||||||
|
|
||||||
|
Stop-Transcript
|
99
NRPE/Check-Port-TCP.ps1
Normal file
99
NRPE/Check-Port-TCP.ps1
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
<Overview of script>
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Version : 1.0
|
||||||
|
Author : Hubert CORNET
|
||||||
|
Creation Date : <Date>
|
||||||
|
Purpose/Change : <Initial script development>
|
||||||
|
|
||||||
|
.LINK
|
||||||
|
https://www.tips-of-mine.fr
|
||||||
|
|
||||||
|
.EXEMPLE
|
||||||
|
<Example goes here. Repeat this attribute for more than one example>
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
<Brief description of script>
|
||||||
|
|
||||||
|
.PARAMETER <Parameter_Name>
|
||||||
|
<Brief description of parameter input required. Repeat this attribute if required>
|
||||||
|
|
||||||
|
.INPUTS
|
||||||
|
<Inputs if any, otherwise state None>
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
<Outputs if any, otherwise state None - example: Log file stored in C:\Windows\Temp\<name>.log>
|
||||||
|
#>
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Initialisations]--------------------------------------------------------
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
Param(
|
||||||
|
[Parameter(Mandatory=$True,Position=1)]
|
||||||
|
[int]$PortSearch
|
||||||
|
)
|
||||||
|
|
||||||
|
# Définir l'action d'erreur pour continuer silencieusement
|
||||||
|
$ErrorActionPreference = "SilentlyContinue"
|
||||||
|
|
||||||
|
#----------------------------------------------------------[Declarations]----------------------------------------------------------
|
||||||
|
# Version Script
|
||||||
|
$sScriptVersion = "1.0"
|
||||||
|
|
||||||
|
#Log File Info
|
||||||
|
$sLogPath = "C:\Tmp"
|
||||||
|
$sLogName = "<script_name>.log"
|
||||||
|
$sLogFile = Join-Path -Path $sLogPath -ChildPath $sLogName
|
||||||
|
|
||||||
|
Start-Transcript -Path $sLogFile -NoClobber
|
||||||
|
|
||||||
|
$bReturnOK = $TRUE
|
||||||
|
$bReturnCritical = $FALSE
|
||||||
|
$bReturnWarning = $FALSE
|
||||||
|
$returnStateOK = 0
|
||||||
|
$returnStateWarning = 1
|
||||||
|
$returnStateCritical = 2
|
||||||
|
$returnStateUnknown = 3
|
||||||
|
|
||||||
|
$strCritical = ""
|
||||||
|
$strWarning = ""
|
||||||
|
$DataTexte = ""
|
||||||
|
|
||||||
|
#-----------------------------------------------------------[Functions]------------------------------------------------------------
|
||||||
|
|
||||||
|
#--------------------------------------------------------[Debut Du Script]---------------------------------------------------------
|
||||||
|
|
||||||
|
$ListPort = Get-NetTCPConnection
|
||||||
|
|
||||||
|
Foreach ($Port in $ListPort) {
|
||||||
|
If ($Port.LocalPort -eq $PortSearch) {
|
||||||
|
$DataTexte = "Service avec $PortSearch fonctionnel"
|
||||||
|
$bReturnCritical = $False
|
||||||
|
break
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
$bReturnCritical = $TRUE
|
||||||
|
$strCritical = "Critique"
|
||||||
|
$DataTexte = "Service avec $PortSearch non fonctionnel"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
If ($bReturnCritical) {
|
||||||
|
write-output $strCritical
|
||||||
|
write-output $strWarning "|" $DataTexte
|
||||||
|
exit $returnStateCritical
|
||||||
|
}
|
||||||
|
Elseif ($bReturnWarning) {
|
||||||
|
write-output $strWarning "|" $DataTexte
|
||||||
|
exit $returnStateWarning
|
||||||
|
}
|
||||||
|
Else {
|
||||||
|
write-output "OK" "|" $DataTexte
|
||||||
|
exit $returnStateOK
|
||||||
|
}
|
||||||
|
|
||||||
|
#---------------------------------------------------------[Fin Du Script]----------------------------------------------------------
|
||||||
|
|
||||||
|
Stop-Transcript
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user