update
This commit is contained in:
parent
2cef42a718
commit
09c2faad93
1732
Active Directory/ADHTMLReports.ps1
Normal file
1732
Active Directory/ADHTMLReports.ps1
Normal file
File diff suppressed because it is too large
Load Diff
1372
Active Directory/Audit-v3.ps1
Normal file
1372
Active Directory/Audit-v3.ps1
Normal file
File diff suppressed because it is too large
Load Diff
1658
Active Directory/Audit.ps1
Normal file
1658
Active Directory/Audit.ps1
Normal file
File diff suppressed because it is too large
Load Diff
50
Active Directory/Get-AdComputerInventory.ps1
Normal file
50
Active Directory/Get-AdComputerInventory.ps1
Normal file
@ -0,0 +1,50 @@
|
||||
$Computers = Get-ADComputer -filter * | Select-Object -ExpandProperty Name
|
||||
# Get-ADComputer -Filter { OperatingSystem -NotLike '*Server*' } -Properties OperatingSystem
|
||||
|
||||
Foreach ($computer in $computers) {
|
||||
|
||||
if (!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) {
|
||||
write-host "cannot reach $computer offline" -f red
|
||||
}
|
||||
else {
|
||||
$outtbl = @()
|
||||
Try {
|
||||
$sr = Get-WmiObject win32_bios -ComputerName $Computer -ErrorAction Stop
|
||||
$Xr = Get-WmiObject –class Win32_processor -ComputerName $computer -ErrorAction Stop
|
||||
$ld = get-adcomputer $computer -properties Name, Lastlogondate, operatingsystem, ipv4Address, enabled, description, DistinguishedName -ErrorAction Stop
|
||||
$r = "{0} GB" -f ((Get-WmiObject Win32_PhysicalMemory -ComputerName $computer | Measure-Object Capacity -Sum).Sum / 1GB)
|
||||
$x = gwmi win32_computersystem -ComputerName $computer | Select-Object @{Name = "Type"; Expression = { if (($_.pcsystemtype -eq '2') ) {
|
||||
'Laptop'
|
||||
}
|
||||
Else {
|
||||
'Desktop Or Other something else'
|
||||
}
|
||||
}
|
||||
}, Manufacturer, @{Name = "Model"; Expression = { if (($_.model -eq "$null") ) { 'Virtual' } Else { $_.model } } }, username -ErrorAction Stop
|
||||
$t = New-Object PSObject -Property @{
|
||||
serialnumber = $sr.serialnumber
|
||||
computername = $ld.name
|
||||
Ipaddress = $ld.ipv4Address
|
||||
Enabled = $ld.Enabled
|
||||
Description = $ld.description
|
||||
Ou = $ld.DistinguishedName.split(',')[1].split('=')[1]
|
||||
Type = $x.type
|
||||
Manufacturer = $x.Manufacturer
|
||||
Model = $x.Model
|
||||
Ram = $R
|
||||
ProcessorName = ($xr.name | Out-String).Trim()
|
||||
NumberOfCores = ($xr.NumberOfCores | Out-String).Trim()
|
||||
NumberOfLogicalProcessors = ($xr.NumberOfLogicalProcessors | Out-String).Trim()
|
||||
Addresswidth = ($xr.Addresswidth | Out-String).Trim()
|
||||
Operatingsystem = $ld.operatingsystem
|
||||
Lastlogondate = $ld.lastlogondate
|
||||
LoggedinUser = $x.username
|
||||
}
|
||||
$outtbl += $t
|
||||
}
|
||||
catch [Exception] {
|
||||
"Error communicating with $computer, skipping to next"
|
||||
}
|
||||
$outtbl | Select-Object Computername, enabled, description, ipAddress, Ou, Type, Serialnumber, Manufacturer, Model, Ram, ProcessorName, NumberOfCores, NumberOfLogicalProcessors, Addresswidth, Operatingsystem, loggedinuser, Lastlogondate
|
||||
}
|
||||
}
|
64
Active Directory/Get-UserRights.ps1
Normal file
64
Active Directory/Get-UserRights.ps1
Normal file
@ -0,0 +1,64 @@
|
||||
#Paremetres Utilisateur et racine du partage
|
||||
|
||||
$User = "Username"
|
||||
$Path = "PATH"
|
||||
|
||||
#Nom de Domaine NetBios
|
||||
$Domain = "DOMSNS"
|
||||
|
||||
Function Get-ADUserNestedGroups {
|
||||
Param
|
||||
(
|
||||
[string]$DistinguishedName,
|
||||
[array]$Groups = @()
|
||||
)
|
||||
|
||||
#Get the AD object, and get group membership.
|
||||
$ADObject = Get-ADObject -Filter "DistinguishedName -eq '$DistinguishedName'" -Properties memberOf, DistinguishedName;
|
||||
|
||||
#If object exists.
|
||||
If ($ADObject) {
|
||||
#Enummurate through each of the groups.
|
||||
Foreach ($GroupDistinguishedName in $ADObject.memberOf) {
|
||||
#Get member of groups from the enummerated group.
|
||||
$CurrentGroup = Get-ADObject -Filter "DistinguishedName -eq '$GroupDistinguishedName'" -Properties memberOf, DistinguishedName;
|
||||
|
||||
#Check if the group is already in the array.
|
||||
If (($Groups | Where-Object { $_.DistinguishedName -eq $GroupDistinguishedName }).Count -eq 0) {
|
||||
#Add group to array.
|
||||
$Groups += $CurrentGroup;
|
||||
|
||||
#Get recursive groups.
|
||||
$Groups = Get-ADUserNestedGroups -DistinguishedName $GroupDistinguishedName -Groups $Groups;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Return $Groups;
|
||||
}
|
||||
|
||||
$Groups = Get-ADUserNestedGroups -DistinguishedName (Get-ADUser -Identity $User).DistinguishedName;
|
||||
|
||||
$list = Get-ChildItem $Path -Recurse -Directory
|
||||
|
||||
Foreach ($item in $list) {
|
||||
|
||||
$ACL = (Get-Acl $item.FullName).Access
|
||||
|
||||
if (($ACL.IdentityReference -contains ("$($Domain)\" + $User)) -and ($ACL.IsInherited -eq $false)) {
|
||||
|
||||
Write-Host "$($User) a les droits $($ACL.FileSystemRights) sur $($item.FullName)"
|
||||
|
||||
}
|
||||
|
||||
Foreach ($Group in $Groups.Name) {
|
||||
|
||||
if (($ACL.IdentityReference -contains ("$($Domain)\" + $Group)) -and ($ACL.IsInherited -eq $false)) {
|
||||
|
||||
Write-Host "$($User) est dans le groupe $($Group) qui a les droits $($ACL.FileSystemRights) sur $($item.FullName)"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
48
Active Directory/Import-AdGroups.ps1
Normal file
48
Active Directory/Import-AdGroups.ps1
Normal file
@ -0,0 +1,48 @@
|
||||
#Importer le module Active Directory
|
||||
Import-Module activedirectory
|
||||
|
||||
[string]$Mode
|
||||
$Rights = Import-csv "Templates\Import-AdGroups.csv" -Delimiter ";" -Encoding UTF8
|
||||
|
||||
# $Groups_Names = ($Rights[0].psobject.Properties).name | Where-Object { $_ -ne "Utilisateur" }
|
||||
# $Groups_Names -contains $Property.name
|
||||
|
||||
ForEach ($User in $Rights) {
|
||||
ForEach ($Property in $User.PsObject.Properties) {
|
||||
if ($Property.Value -eq "0") {
|
||||
$Mode = "Access"
|
||||
}
|
||||
elseif ($Property.Value -eq "1") {
|
||||
$Mode = "Read"
|
||||
}
|
||||
elseif ($Property.Value -eq "2") {
|
||||
$Mode = "Write"
|
||||
}
|
||||
|
||||
$Group = (($Property.name -replace " ", "-" -replace "\\", "_" -replace ",", "-") + "_" + $Mode)
|
||||
|
||||
Try {
|
||||
|
||||
$TheGroup = Get-ADGroup $Group
|
||||
|
||||
$GroupMembers = Get-ADGroupMember -Identity ($($TheGroup.name))
|
||||
|
||||
if ($GroupMembers.SamAccountName -contains $User.Utilisateur) {
|
||||
Write-Host "User $($User.Utilisateur) is already in the group" ($($TheGroup.name)) -BackgroundColor Blue
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Add-AdGroupMember -Identity ($($TheGroup.name)) -members $User.Utilisateur
|
||||
Write-Host "User $($User.Utilisateur) added to the group" ($($TheGroup.name)) -BackgroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Host "User $($User.Utilisateur) not added to the group" ($($TheGroup.name)) -BackgroundColor Yellow
|
||||
}
|
||||
}
|
||||
}
|
||||
Catch {
|
||||
Write-Host "Group $($Group) not exist, skipped !" -BackgroundColor Red
|
||||
}
|
||||
Remove-Variable Mode -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
52
Active Directory/Import-AdUsers.ps1
Normal file
52
Active Directory/Import-AdUsers.ps1
Normal file
@ -0,0 +1,52 @@
|
||||
# Import active directory module for running AD cmdlets
|
||||
Import-Module activedirectory
|
||||
|
||||
#Store the data from ADUsers.csv in the $ADUsers variable
|
||||
$ADUsers = Import-csv "Templates\Import-AdUsers.csv" -Delimiter ";" -Encoding UTF8
|
||||
$Domain = "dom.hitea.fr"
|
||||
|
||||
#Loop through each row containing user details in the CSV file
|
||||
foreach ($User in $ADUsers) {
|
||||
|
||||
$FullName = "$($User.firstname) $($User.lastname)"
|
||||
$Upn = "$($User.username)@$Domain"
|
||||
|
||||
if ((Get-AdUser -Filter "SamAccountName -eq '$($User.username)'")) {
|
||||
Write-Warning "A user account with username $($User.username) already exist in Active Directory."
|
||||
}
|
||||
elseif (([string]::IsNullOrEmpty($User.password))) {
|
||||
Write-Warning "The password for $($User.username) is nul or empty."
|
||||
}
|
||||
elseif (($User.username).Length -gt 19) {
|
||||
Write-Warning "The username $($User.username) is too long (Greater than 20)."
|
||||
}
|
||||
else {
|
||||
try {
|
||||
New-ADUser `
|
||||
-SamAccountName $User.username `
|
||||
-UserPrincipalName $Upn `
|
||||
-GivenName $User.firstname `
|
||||
-Surname $User.lastname `
|
||||
-Name $FullName `
|
||||
-DisplayName $FullName `
|
||||
-Path $User.ou `
|
||||
-Company $User.company `
|
||||
-State $User.state `
|
||||
-City $User.city `
|
||||
-StreetAddress $User.streetaddress `
|
||||
-OfficePhone $User.telephone `
|
||||
-EmailAddress $User.email `
|
||||
-Title $User.jobtitle `
|
||||
-Department $User.department `
|
||||
-AccountPassword (convertto-securestring $User.password -AsPlainText -Force) `
|
||||
-Enabled $True `
|
||||
-ChangePasswordAtLogon $False `
|
||||
-PasswordNeverExpires $True `
|
||||
-CannotChangePassword $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."
|
||||
}
|
||||
}
|
||||
}
|
12
Active Directory/Join-Domain.ps1
Normal file
12
Active Directory/Join-Domain.ps1
Normal file
@ -0,0 +1,12 @@
|
||||
# Parametres Domaine
|
||||
$domain = "DOMAIN"
|
||||
|
||||
# Le nom d'utilisateur
|
||||
$username = "$domain\USERNAME HERE"
|
||||
|
||||
# Le mot de passe de l'utilisateur
|
||||
$password = "PASSWORD HERE" | ConvertTo-SecureString -asPlainText -Force
|
||||
|
||||
$credential = New-Object System.Management.Automation.PSCredential($username, $password)
|
||||
|
||||
Add-Computer -DomainName $domain -Credential $credential
|
25
Active Directory/New-Domain.ps1
Normal file
25
Active Directory/New-Domain.ps1
Normal file
@ -0,0 +1,25 @@
|
||||
#Installer la fonctionnalité AD DS
|
||||
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
|
||||
|
||||
#Importer le module de déploiement
|
||||
Import-Module ADDSDeployment
|
||||
|
||||
#Créer une nouvelle forêt
|
||||
Install-ADDSForest `
|
||||
-CreateDnsDelegation:$false `
|
||||
-DatabasePath "C:\Windows\NTDS" `
|
||||
-DomainMode "WinThreshold" `
|
||||
-DomainName "DOMAINE.LOCAL" `
|
||||
-DomainNetbiosName "DOMAINE" `
|
||||
-ForestMode "WinThreshold" `
|
||||
-InstallDns:$true `
|
||||
-LogPath "C:\Windows\NTDS" `
|
||||
-NoRebootOnCompletion:$false `
|
||||
-SysvolPath "C:\Windows\SYSVOL" `
|
||||
-Force:$true
|
||||
|
||||
#Voir les rédirecteurs du serveur DNS
|
||||
Get-DnsServerForwarder
|
||||
|
||||
#Ajouter un redirecteur au serveur DNS, Exemple avec le DNS de CloudFare
|
||||
Add-DnsServerForwarder -IPAddress 1.1.1.1
|
50
Active Directory/New-UsersHome.ps1
Normal file
50
Active Directory/New-UsersHome.ps1
Normal file
@ -0,0 +1,50 @@
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Créer des dossiers utilisateurs avec les autorisations contrôle total
|
||||
|
||||
.PARAMETER Domain
|
||||
Indique le domaine
|
||||
|
||||
.PARAMETER BaseDir
|
||||
Indique le dossier racine
|
||||
|
||||
.EXAMPLE
|
||||
New-UsersHome -Domain "@Domaine.local" -BaseDir "C:\UsersHome"
|
||||
|
||||
#>
|
||||
|
||||
param (
|
||||
[parameter(Mandatory = $True)]
|
||||
[ValidateNotNullOrEmpty()]$Domain,
|
||||
[parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]$BaseDir
|
||||
)
|
||||
|
||||
# Lister tous les utilisateurs du domaine
|
||||
$Users = Get-ADUser -Filter { UserPrincipalName -like "*$($Domain)" } | Select SAMAccountName, SID
|
||||
|
||||
# Déactiver l'héritage sur le dossier racine et supprimer les autorisation Utilisateurs
|
||||
Foreach ($User in $Users) {
|
||||
|
||||
$UserDir = Join-Path $BaseDir $User.SAMAccountName
|
||||
|
||||
If (!(test-path $UserDir)) {
|
||||
New-Item -ItemType Directory -Path $UserDir
|
||||
}
|
||||
|
||||
$acl = Get-Acl $UserDir
|
||||
$acl.SetAccessRuleProtection($true, $true)
|
||||
|
||||
$FileSystemRights = [System.Security.AccessControl.FileSystemRights]"FullControl"
|
||||
$AccessControlType = [System.Security.AccessControl.AccessControlType]::Allow
|
||||
$InheritanceFlags = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit"
|
||||
$PropagationFlags = [System.Security.AccessControl.PropagationFlags]::None
|
||||
|
||||
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($User.SID, $FileSystemRights, $InheritanceFlags, $PropagationFlags, $AccessControlType)
|
||||
$acl.AddAccessRule($AccessRule)
|
||||
|
||||
Set-Acl -Path $UserDir -AclObject $acl -ea Stop
|
||||
|
||||
}
|
||||
|
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>
|
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
|
|
112
Active Directory/Validate-GroupMembership.ps1
Normal file
112
Active Directory/Validate-GroupMembership.ps1
Normal file
@ -0,0 +1,112 @@
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Validates AD group membership for a user or computer object
|
||||
|
||||
.PARAMETER SearchString
|
||||
Provide Username or Computer Name
|
||||
|
||||
.PARAMETER SearchType
|
||||
Specify type (User or Computer)
|
||||
|
||||
.PARAMETER Group
|
||||
Provide AD Group name
|
||||
|
||||
.EXAMPLE
|
||||
Validate-GroupMembership -SearchString $env:USERNAME -SearchType User -Group "Test Group"
|
||||
|
||||
.EXAMPLE
|
||||
Validate-GroupMembership -SearchString $env:COMPUTERNAME -SearchType Computer -Group "ORL Computers"
|
||||
|
||||
#>
|
||||
|
||||
param (
|
||||
[parameter(Mandatory = $True)]
|
||||
[ValidateNotNullOrEmpty()]$SearchString,
|
||||
[parameter(Mandatory = $True)]
|
||||
[ValidateSet("User", "Computer")]
|
||||
[ValidateNotNullOrEmpty()]$SearchType,
|
||||
[parameter(Mandatory = $true)]
|
||||
[ValidateNotNullOrEmpty()]$Group
|
||||
)
|
||||
|
||||
Try {
|
||||
|
||||
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
|
||||
$objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry
|
||||
|
||||
If ($SearchType -eq "User") {
|
||||
|
||||
$objSearcher.Filter = "(&(objectCategory=User)(SAMAccountName=$SearchString))"
|
||||
|
||||
}
|
||||
Else {
|
||||
|
||||
$objSearcher.Filter = "(&(objectCategory=Computer)(cn=$SearchString))"
|
||||
|
||||
}
|
||||
|
||||
$objSearcher.SearchScope = "Subtree"
|
||||
$obj = $objSearcher.FindOne()
|
||||
$User = $obj.Properties["distinguishedname"]
|
||||
|
||||
$objSearcher.PageSize = 1000
|
||||
$objSearcher.Filter = "(&(objectClass=group)(cn=$Group))"
|
||||
$obj = $objSearcher.FindOne()
|
||||
|
||||
[String[]]$Members = $obj.Properties["member"]
|
||||
|
||||
If ($Members.count -eq 0) {
|
||||
|
||||
$retrievedAllMembers = $false
|
||||
$rangeBottom = 0
|
||||
$rangeTop = 0
|
||||
|
||||
While (! $retrievedAllMembers) {
|
||||
|
||||
$rangeTop = $rangeBottom + 1499
|
||||
|
||||
$memberRange = "member;range=$rangeBottom-$rangeTop"
|
||||
|
||||
$objSearcher.PropertiesToLoad.Clear()
|
||||
[void]$objSearcher.PropertiesToLoad.Add("$memberRange")
|
||||
|
||||
$rangeBottom += 1500
|
||||
|
||||
Try {
|
||||
|
||||
$obj = $objSearcher.FindOne()
|
||||
$rangedProperty = $obj.Properties.PropertyNames -like "member;range=*"
|
||||
$Members += $obj.Properties.item($rangedProperty)
|
||||
|
||||
if ($Members.count -eq 0) { $retrievedAllMembers = $true }
|
||||
}
|
||||
|
||||
Catch {
|
||||
|
||||
$retrievedAllMembers = $true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Catch {
|
||||
|
||||
Write-Host "Either group or user does not exist"
|
||||
Return $False
|
||||
|
||||
}
|
||||
|
||||
If ($Members -contains $User) {
|
||||
|
||||
Return $True
|
||||
|
||||
}
|
||||
Else {
|
||||
|
||||
Return $False
|
||||
|
||||
}
|
409
Active Directory/creation-automatique.ps1
Normal file
409
Active Directory/creation-automatique.ps1
Normal file
@ -0,0 +1,409 @@
|
||||
# Fonction pour les requetes SQL
|
||||
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:\tmp\error.log"
|
||||
}
|
||||
Finally {
|
||||
$ErrorActionPreference = "Continue"
|
||||
}
|
||||
}
|
||||
|
||||
# Fonction pour les requetes dans GLPI
|
||||
Function QueryGLPI([string]$Titre, [string]$Message, [string]$Categorie) {
|
||||
Write-host $Titre
|
||||
Write-host $Message
|
||||
Write-host $Categorie
|
||||
|
||||
$UtilisateurGLPI = Get-GlpiToolsUsers -UserName helpdesk
|
||||
|
||||
$Ticket = New-GlpiToolsTicket -Name $Titre -Content $Message -Type Request -itilcategories_id $Categorie -Priority Medium -requester_id $UtilisateurGLPI.ID
|
||||
|
||||
Update-GlpiToolsTicket -ticket_id $Ticket.id -requester_id $UtilisateurGLPI.ID -technician_id '12'
|
||||
}
|
||||
|
||||
cls
|
||||
|
||||
$ListeException = $null
|
||||
$ListeVide = $null
|
||||
$FichierException = "D:\tmp\Exception.txt"
|
||||
$FichierVide = "D:\tmp\vide.txt"
|
||||
$percentCompleteA = $null
|
||||
$percentCompleteB = $null
|
||||
$CounterA = $null
|
||||
$CounterB = $null
|
||||
$EtatUtilisateur = $null
|
||||
|
||||
$DateDesactivation = Get-Date -Format "dd/MM/yyyy"
|
||||
$DateExpiration = (Get-Date $DateDesactivation).AddDays(-1)
|
||||
$DateDelete = (Get-Date $DateDesactivation).AddDays(-30)
|
||||
|
||||
$DateTmp = (Get-Date).AddDays(-1)
|
||||
$DateCreation = Get-Date $DateTmp -Format "yyyy-dd-MM"
|
||||
|
||||
Start-Transcript -path "D:\tmp\MyTranscript-$DateCreation.txt"
|
||||
|
||||
$OuPath = "OU=Utilisateurs,DC=fr,DC=dgs,DC=group"
|
||||
$ListeUserAD = Get-ADUser -Filter * -SearchBase $OuPath -Properties cn,description,sAMAccountName
|
||||
|
||||
## Desactivation ou Update de compte
|
||||
|
||||
Foreach ($UserAD in $ListeUserAD) {
|
||||
# Barre de progression
|
||||
$percentCompleteA = $(($CounterA / $ListeUserAD.Count) * 100 )
|
||||
|
||||
$ProgressA = @{
|
||||
Activity = "Getting folder information for '$($UserAD.Name)'."
|
||||
Status = "Processing $CounterA of $($ListeUserAD.Count)"
|
||||
PercentComplete = $([math]::Round($percentCompleteA, 2))
|
||||
}
|
||||
|
||||
Write-Progress @ProgressA -Id 1
|
||||
|
||||
# recherche inforamtiopn 1 utilisateur
|
||||
$InfoUser = Get-ADUser -identity $UserAD.sAMAccountName -properties 'msDS-cloudExtensionAttribute1','msDS-cloudExtensionAttribute2',mail,employeeID,EmployeeNumber,EmployeeType,Title,Initials
|
||||
|
||||
$C = $UserAD.C
|
||||
$City = $UserAD.City
|
||||
$Cn = $UserAD.Cn
|
||||
$Company = $UserAD.Company
|
||||
$department = $UserAD.Department
|
||||
$displayName = $UserAD.DisplayName
|
||||
$EmailAddress = $UserAD.EmailAddress
|
||||
$Enable = $UserAD.Enabled
|
||||
$GivenName = $UserAD.GivenName
|
||||
$Name = $UserAD.Name
|
||||
$Office = $UserAD.Office
|
||||
$Organization = $UserAD.Organization
|
||||
$PostalCode = $UserAD.PostalCode
|
||||
$sn = $UserAD.Sn
|
||||
$Surname = $UserAD.Surname
|
||||
|
||||
$ExtensionAttribute1 = $InfoUser.'msDS-cloudExtensionAttribute1'
|
||||
$ExtensionAttribute2 = $InfoUser.'msDS-cloudExtensionAttribute2'
|
||||
$Mail = $InfoUser.Mail
|
||||
$EmployeeID = $InfoUser.employeeID
|
||||
$EmployeeNumber = $InfoUser.EmployeeNumber
|
||||
$EmployeeType = $InfoUser.EmployeeType
|
||||
$Title = $InfoUser.Title
|
||||
$Initials = $InfoUser.Initials
|
||||
|
||||
# Est-ce qu'il est actif
|
||||
If ($Enable -eq "True") {
|
||||
# Est-ce qu'il est interne
|
||||
If($EmployeeType -eq "Interne") {
|
||||
# Est-ce qu'il a un ID
|
||||
If ($EmployeeID) {
|
||||
# Si l'employeeID est bien présent
|
||||
$EtatUtilisateurD = QuerySQLServer "SWDHBBDDP01.fr.dgs.group" "dhb_prd" "SELECT NOM,PRN,NOM_PAT,LIB_EMP,ADR_EML,MTR,NUM_ALC,COD_SEX,FLG_AGT,DAT_SRT FROM [dhb_prd].[dhbref].[TAB_RH_SAL] WHERE MTR = '$EmployeeID' And DAT_SRT IS NOT NULL"
|
||||
$EtatUtilisateurU = QuerySQLServer "SWDHBBDDP01.fr.dgs.group" "dhb_prd" "SELECT NOM,PRN,NOM_PAT,LIB_EMP,ADR_EML,MTR,NUM_ALC,COD_SEX,FLG_AGT,DAT_SRT FROM [dhb_prd].[dhbref].[TAB_RH_SAL] WHERE MTR = '$EmployeeID'"
|
||||
|
||||
# Desactivation du compte ?
|
||||
If ($EtatUtilisateurD) {
|
||||
If ($DateExpiration -gt $EtatUtilisateurD.DAT_SRT) {
|
||||
|
||||
Get-ADUser -Identity $UserAD.sAMAccountName | Move-ADObject -TargetPath "OU=_A_SUPPRIMER,OU=Utilisateurs,DC=fr,DC=dgs,DC=group"
|
||||
Set-ADAccountExpiration -Identity $UserAD.sAMAccountName -DateTime $dateExpiration
|
||||
Set-ADUser -Identity $Utilisateur -Clear msDS-cloudExtensionAttribute2
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -Add @{'msDS-cloudExtensionAttribute2' = "$DateExpiration"}
|
||||
Disable-ADAccount -Identity $UserAD.sAMAccountName
|
||||
|
||||
$TitreA = "Désactivation du compte Active Directory : $UserAD.sAMAccountName "
|
||||
|
||||
$MessageA = "Bonjour, `r`n `r`n" `
|
||||
+"Nous venons de désactiver le compte de : $DisplayName `r`n `r`n" `
|
||||
+"Prénom : $GivenName `r`n" `
|
||||
+"Nom : $Surname `r`n" `
|
||||
+"Mail : $Mail `r`n" `
|
||||
+"Matricule : $EmployeeID `r`n" `
|
||||
+"Fonction : $Title `r`n" `
|
||||
+"`r`n" `
|
||||
+"Conformément à la politique entreprise le compte restera en état désactivé pendant 30 jours avant d'être supprimé `r`n" `
|
||||
+"La suppression du compte GMAIL se fait également en automatique."
|
||||
|
||||
QueryGLPI $TitreA $MessageA "213"
|
||||
}
|
||||
}
|
||||
|
||||
# Mise en place de la civilité
|
||||
If ($EtatUtilisateurU) {
|
||||
If (($Initials -ne "Mr") -And ($EtatUtilisateurU.COD_SEX -eq "H")) {
|
||||
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -Clear Initials
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -Initials "Mr"
|
||||
|
||||
Write-Host " - Update civilité - Mr"
|
||||
}
|
||||
ElseIf (($Initials -ne "Mme") -And ($EtatUtilisateurU.COD_SEX -eq "F")) {
|
||||
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -Clear Initials
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -Initials "Mme"
|
||||
|
||||
Write-Host " - Update civilité - Mme"
|
||||
}
|
||||
Else {
|
||||
# Write-Host " - Pas de modification"
|
||||
}
|
||||
}
|
||||
|
||||
# Mise en place du Employee Number
|
||||
If ($EmployeeNumber -ne $EtatUtilisateurU.NUM_ALC) {
|
||||
If ($EmployeeID.substring(0, 1) -eq 0 ) {
|
||||
$tmp = ($EtatUtilisateurU.NUM_ALC).Remove(0,1)
|
||||
If (!($EmployeeNumber -eq $tmp)) {
|
||||
Write-host " - 2erreur : "$EtatUtilisateurU.MTR" > $EmployeeID | "$EtatUtilisateurU.NUM_ALC" > $EmployeeNumber"
|
||||
}
|
||||
}
|
||||
Else {
|
||||
Write-host " - erreur : "$EtatUtilisateurU.MTR" > $EmployeeID | "$EtatUtilisateurU.NUM_ALC" > $EmployeeNumber"
|
||||
}
|
||||
}
|
||||
|
||||
# Controle du status
|
||||
If (($ExtensionAttribute1 -eq $null) -Or ($ExtensionAttribute1 -ne $EmployeeType)) {
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -Add @{'msDS-cloudExtensionAttribute1' = $EmployeeType}
|
||||
}
|
||||
}
|
||||
Else {
|
||||
# Si l'employé ID n'est pas présent
|
||||
$EtatUtilisateurID = QuerySQLServer "SWDHBBDDP01.fr.dgs.group" "dhb_prd" "SELECT NOM,PRN,NOM_PAT,LIB_EMP,ADR_EML,MTR,NUM_ALC,COD_SEX,FLG_AGT,DAT_SRT FROM [dhb_prd].[dhbref].[TAB_RH_SAL] WHERE NOM = '$Surname' And PRN ='$GivenName' And DAT_SRT IS NULL"
|
||||
|
||||
If ($EtatUtilisateurID) {
|
||||
|
||||
Set-ADUser -Identity $UserAD.sAMAccountName -EmployeeID $EtatUtilisateurID.MTR
|
||||
|
||||
Write-Host " - Mise en place de employee ID"
|
||||
}
|
||||
}
|
||||
}
|
||||
Else {
|
||||
# Passage d'un externe en interne
|
||||
}
|
||||
}
|
||||
$EtatUtilisateurD = $null
|
||||
$EtatUtilisateurU = $null
|
||||
|
||||
$CounterA++
|
||||
}
|
||||
|
||||
## Suppression des comptes de plus 1 mois
|
||||
|
||||
$OuPathDelete = "OU=_A_SUPPRIMER,OU=Utilisateurs,DC=fr,DC=dgs,DC=group"
|
||||
$ListeUserADDelete = Get-ADUser -Filter * -SearchBase $OuPathDelete -Properties cn,description,sAMAccountName
|
||||
|
||||
Foreach ($UserADDelete in $ListeUserADDelete) {
|
||||
# Barre de progression
|
||||
$percentCompleteB = $(($CounterB / $ListeUserADDelete.Count) * 100 )
|
||||
|
||||
$ProgressB = @{
|
||||
Activity = "Getting folder information for '$($UserADDelete.Name)'."
|
||||
Status = "Processing $CounterB of $($ListeUserADDelete.Count)"
|
||||
PercentComplete = $([math]::Round($percentCompleteB, 2))
|
||||
}
|
||||
|
||||
Write-Progress @ProgressB -Id 1
|
||||
|
||||
$InfoUserDelete = Get-ADUser -identity $UserADDelete.sAMAccountName -properties 'msDS-cloudExtensionAttribute2'
|
||||
|
||||
$ExtensionAttributeDelete2 = $InfoUserDelete.'msDS-cloudExtensionAttribute2'
|
||||
|
||||
If ($Enable -eq $False) {
|
||||
If ($DateDelete -gt $ExtensionAttributeDelete2) {
|
||||
Remove-ADUser -Identity $UserADDelete.sAMAccountName
|
||||
|
||||
$TitreB = "Suppression du compte Active Directory : $UserAD.sAMAccountName "
|
||||
|
||||
$MessageB = "Bonjour, `r`n `r`n" `
|
||||
+"Nous venons de supprimer le compte de : $DisplayName `r`n `r`n" `
|
||||
+"Prénom : $GivenName `r`n" `
|
||||
+"Nom : $Surname `r`n" `
|
||||
+"Mail : $Mail `r`n" `
|
||||
+"Matricule : $EmployeeID `r`n" `
|
||||
+"Fonction : $Title `r`n" `
|
||||
+"`r`n" `
|
||||
+"Conformément à la politique entreprise le compte est resté en état désactivé pendant 30 jours `r`n" `
|
||||
+"La suppression du compte GMAIL se fait également en automatique."
|
||||
|
||||
QueryGLPI $TitreB $MessageB "213"
|
||||
}
|
||||
}
|
||||
$EtatUtilisateur = $null
|
||||
|
||||
$CounterB++
|
||||
}
|
||||
|
||||
## Creation compte
|
||||
|
||||
$ListeNouveau = QuerySQLServer "SWDHBBDDP01.fr.dgs.group" "dhb_prd" "SELECT NOM,PRN,NOM_PAT,LIB_EMP,ADR_EML,MTR,NUM_ALC,COD_SEX,FLG_AGT,DAT_SRT,NUM_MAG_AGT FROM [dhb_prd].[dhbref].[TAB_RH_SAL] WHERE DTH_CRE >= '$DateCreation' ORDER BY DTH_CRE DESC"
|
||||
$ListeNouveau | Format-Table
|
||||
Pause
|
||||
If ($ListeNouveau) {
|
||||
Foreach ($NouveauUtilisateur in $ListeNouveau) {
|
||||
|
||||
$InfoUserNew = Get-ADUser -Filter * | Where-Object {$_.GivenName -like $NouveauUtilisateur.PRN -and $_.Surname -like $NouveauUtilisateur.NOM}
|
||||
|
||||
If ($InfoUserNew) {
|
||||
$InfoUserNewA = Get-ADUser -identity $InfoUserNew.sAMAccountName -properties 'msDS-cloudExtensionAttribute1','msDS-cloudExtensionAttribute2',mail,employeeID,EmployeeNumber,EmployeeType,Title,Initials
|
||||
}
|
||||
|
||||
$C = $InfoUserNew.c
|
||||
$City = $InfoUserNew.City
|
||||
$Cn = $InfoUserNew.cn
|
||||
$Company = $InfoUserNew.company
|
||||
$department = $InfoUserNew.department
|
||||
$DisplayName = $InfoUserNew.displayName
|
||||
$EmailAddress = $InfoUserNew.EmailAddress
|
||||
$Enable = $InfoUserNew.Enabled
|
||||
$GivenName = $InfoUserNew.GivenName
|
||||
$Name = $InfoUserNew.Name
|
||||
$Office = $InfoUserNew.Office
|
||||
$Organization = $InfoUserNew.Organization
|
||||
$PostalCode = $InfoUserNew.PostalCode
|
||||
$sn = $InfoUserNew.sn
|
||||
$Surname = $InfoUserNew.Surname
|
||||
|
||||
$ExtensionAttribute1 = $InfoUserNewA.'msDS-cloudExtensionAttribute1'
|
||||
$ExtensionAttribute2 = $InfoUserNewA.'msDS-cloudExtensionAttribute2'
|
||||
$Mail = $InfoUserNewA.Mail
|
||||
$EmployeeID = $InfoUserNewA.employeeID
|
||||
$EmployeeNumber = $InfoUserNewA.EmployeeNumber
|
||||
$EmployeeType = $InfoUserNewA.EmployeeType
|
||||
$Title = $InfoUserNewA.Title
|
||||
$Initials = $InfoUserNewA.Initials
|
||||
|
||||
If ($NouveauUtilisateur.MTR -eq $EmployeeID) {
|
||||
Write-host "Existe deja"
|
||||
}
|
||||
Else {
|
||||
Write-Host "A creer"
|
||||
|
||||
$Surnametmp = ($NouveauUtilisateur.NOM).ToLower()
|
||||
$GivenNametmp = ($NouveauUtilisateur.PRN).ToLower()
|
||||
$Titletmp = ($NouveauUtilisateur.LIB_EMP).ToLower()
|
||||
$Initialstmp = $NouveauUtilisateur.COD_SEX
|
||||
$CodeMagtmp = $NouveauUtilisateur.NUM_MAG_AGT
|
||||
|
||||
$SurnameNew = (Get-Culture).TextInfo.ToTitleCase($Surnametmp)
|
||||
$GivenNameNew = (Get-Culture).TextInfo.ToTitleCase($GivenNametmp)
|
||||
$TitleNew = (Get-Culture).TextInfo.ToTitleCase($Titletmp)
|
||||
$EmployeeIDNew = $NouveauUtilisateur.MTR
|
||||
|
||||
If ($NouveauUtilisateur.NOM_PAT) {
|
||||
$SurnamePattmp = ($NouveauUtilisateur.NOM_PAT).ToLower()
|
||||
$SurnamePatNew = (Get-Culture).TextInfo.ToTitleCase($SurnamePattmp)
|
||||
}
|
||||
|
||||
$NameNew = $GivenNameNew+" "+$SurnameNew
|
||||
$DisplayNameNew = $GivenNameNew+" "+$SurnameNew+" "+$SurnamePatNew
|
||||
$SamAccountNameNew = (("$GivenNameNew.$SurnameNew").Replace(' ','').Replace('é','e').Replace('è','e').Replace('ç','c').Replace('ï','i').Replace('î','i').Replace('ë','e').Replace('ö','o').Replace('ô','o')).ToLower()
|
||||
$UserPrincipalNameNew = (("$GivenNameNew.$SurnameNew@fr.dgs.group").Replace(' ','').Replace('é','e').Replace('è','e').Replace('ç','c').Replace('ï','i').Replace('î','i').Replace('ë','e').Replace('ö','o').Replace('ô','o')).ToLower()
|
||||
$MailNew = (("$GivenNameNew.$SurnameNew@saint-maclou.com").Replace(' ','').Replace('é','e').Replace('è','e').Replace('ç','c').Replace('ï','i').Replace('î','i').Replace('ë','e').Replace('ö','o').Replace('ô','o')).ToLower()
|
||||
$Password = ([System.Guid]::NewGuid()).ToString()
|
||||
|
||||
|
||||
If ($SamAccountNameNew.Length -gt 20) {
|
||||
$tmp = ($SamAccountNameNew).substring(0, 20)
|
||||
$SamAccountNameNew = $tmp
|
||||
}
|
||||
|
||||
Write-host $NameNew
|
||||
Write-host $DisplayNameNew
|
||||
Write-host $SamAccountNameNew
|
||||
Write-host $UserPrincipalNameNew
|
||||
Write-host $MailNew
|
||||
Write-host $Password
|
||||
Write-host $EmployeeIDNew
|
||||
Write-host $TitleNew
|
||||
|
||||
New-ADUser -Name "$NameNew" -DisplayName "$DisplayNameNew" -GivenName "$GivenNameNew" -Surname "$SurnameNew" -SamAccountName "$SamAccountNameNew" -UserPrincipalName "$UserPrincipalNameNew" -Path "OU=_ARRIVER,OU=Utilisateurs,DC=fr,DC=dgs,DC=group" -AccountPassword (ConvertTo-SecureString "$Password" -AsPlainText -force) -Enabled $true -EmailAddress $MailNew
|
||||
|
||||
sleep 10
|
||||
|
||||
Set-ADUser -Identity $SamAccountNameNew -replace @{c="FR";co="France";countrycode=250}
|
||||
Set-ADUser -Identity $SamAccountNameNew -Add @{'msDS-cloudExtensionAttribute1' = "Interne"}
|
||||
Set-ADUser -Identity $SamAccountNameNew -Add @{'EmployeeType' = "Interne"}
|
||||
Set-ADUser -Identity $SamAccountNameNew -Add @{'EmployeeID' = "$EmployeeIDNew"}
|
||||
Set-ADUser -Identity $SamAccountNameNew -Title "$TitleNew"
|
||||
Set-ADUser -Identity $SamAccountNameNew -Description "A remplir par le Helpdesk"
|
||||
Set-ADUser -Identity $SamAccountNameNew -City "A remplir par le Helpdesk"
|
||||
|
||||
If ($Initialstmp -eq "H") {
|
||||
Set-ADUser -Identity $SamAccountNameNew -Initials "Mr"
|
||||
Write-Host "Update civilite - Mr"
|
||||
}
|
||||
ElseIf ($Initialstmp -eq "F") {
|
||||
Set-ADUser -Identity $SamAccountNameNew -Initials "Mme"
|
||||
Write-Host "Update civilite - Mme"
|
||||
}
|
||||
Else {
|
||||
|
||||
}
|
||||
|
||||
$TitreC = "Creation du compte de : $DisplayNameNew "
|
||||
|
||||
$MessageC = "Bonjour, `r`n `r`n" `
|
||||
+"la creation de compte automatique a cree le compte de : $DisplayNameNew `r`n `r`n" `
|
||||
+"Prenom : $GivenNameNew `r`n" `
|
||||
+"Nom : $SurnameNew `r`n" `
|
||||
+"Mail : $MailNew `r`n" `
|
||||
+"Password temporaire : $Password `r`n" `
|
||||
+"Matricule : $EmployeeIDNew `r`n" `
|
||||
+"Fonction : $TitleNew `r`n"
|
||||
|
||||
QueryGLPI $TitreC $MessageC "104"
|
||||
|
||||
$C = $Null
|
||||
$City = $Null
|
||||
$Cn = $Null
|
||||
$Company = $Null
|
||||
$department = $Null
|
||||
$DisplayName = $Null
|
||||
$EmailAddress = $Null
|
||||
$Enable = $Null
|
||||
$GivenName = $Null
|
||||
$Name = $Null
|
||||
$Office = $Null
|
||||
$Organization = $Null
|
||||
$PostalCode = $Null
|
||||
$sn = $Null
|
||||
$Surname = $Null
|
||||
$ExtensionAttribute1 = $Null
|
||||
$ExtensionAttribute2 = $Null
|
||||
$Mail = $Null
|
||||
$EmployeeID = $Null
|
||||
$EmployeeNumber = $Null
|
||||
$EmployeeType = $Null
|
||||
$Title = $Null
|
||||
$Initials = $Null
|
||||
$Surnametmp = $Null
|
||||
$GivenNametmp = $Null
|
||||
$Titletmp = $Null
|
||||
$Initialstmp = $Null
|
||||
$CodeMagtmp = $Null
|
||||
$SurnameNew = $Null
|
||||
$SurnamePatNew = $Null
|
||||
$GivenNameNew = $Null
|
||||
$TitleNew = $Null
|
||||
$EmployeeIDNew = $Null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Stop-Transcript
|
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
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
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
|
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
|
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ÔT
|
||||
IMPRIMANTE;PRINTRONIX;P7210;6RV608150016;FOND ENTREPÔT
|
||||
IMPRIMANTE;KONICA MINOLTA;BIZHUB36;A45X02100P006;FOND ENTREPÔT
|
||||
IMPRIMANTE;KONICA MINOLTA;BIZHUB36;A45X021008070;FOND ENTREPÔT
|
||||
IMPRIMANTE;RICOH;MPC2050;V2294502701;FOND ENTREPÔT
|
||||
IMPRIMANTE;RICOH;1027;K2259600645;FOND ENTREPÔT
|
||||
IMPRIMANTE;RICOH;MP2550;M6584000997;FOND ENTREPÔT
|
||||
IMPRIMANTE;RICOH;MPC3500;L8974200939;FOND ENTREPÔT
|
||||
IMPRIMANTE;RICOH;3025;K8563804891;FOND ENTREPÔT
|
||||
IMPRIMANTE;RICOH;MPC5000;V1303000756;FOND ENTREPÔ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
|
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
233
LICENSE
233
LICENSE
@ -1,3 +1,232 @@
|
||||
Additional permission under GNU GPL version 3 section 7
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
If you modify this Program, or any covered work, by linking or combining it with [name of library] (or a modified version of that library), containing parts covered by the terms of [name of library's license], the licensors of this Program grant you additional permission to convey the resulting work. Corresponding Source for a non-source form of such a combination shall include the source code for the parts of [name of library] used as well as that of the covered work.
|
||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||
|
||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||
|
||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||
|
||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||
|
||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||
|
||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||
|
||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||
|
||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||
|
||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||
|
||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||
|
||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
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
|
137
NRPE/Check-WSUS.ps1
Normal file
137
NRPE/Check-WSUS.ps1
Normal file
@ -0,0 +1,137 @@
|
||||
###############################################################################
|
||||
# Windows PowerShell Skript to get WSUS statistics
|
||||
# output readable by NRPE for Nagios monitoring
|
||||
#
|
||||
# FORK FROM: http://www.monitoring-portal.org/wbb/index.php?page=Thread&threadID=16424
|
||||
###############################################################################
|
||||
|
||||
|
||||
# Variables - set these to fit your needs
|
||||
###############################################################################
|
||||
# The server name of your WSUS server
|
||||
$serverName = 'localhost'
|
||||
|
||||
# use SSL connection?
|
||||
$useSecureConnection = $False
|
||||
|
||||
# the port number of your WSUS IIS website
|
||||
$portNumber = 8530
|
||||
|
||||
# warn if a computer has not contacted the server for ... days
|
||||
$daysBeforeWarn = 14
|
||||
|
||||
|
||||
|
||||
# Script - don't change anything below this line!
|
||||
###############################################################################
|
||||
|
||||
# load WSUS framework
|
||||
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
|
||||
|
||||
# connect to specified WSUS server
|
||||
# see here for information of the IUpdateServer class
|
||||
# -> http://msdn.microsoft.com/en-us/library/microsoft.updateservices.administration.iupdateserver(VS.85).aspx
|
||||
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($serverName, $useSecureConnection, $portNumber)
|
||||
|
||||
# get general status information
|
||||
# see here for more infos about the properties of GetStatus()
|
||||
# -> http://msdn.microsoft.com/en-us/library/microsoft.updateservices.administration.updateserverstatus_properties(VS.85).aspx
|
||||
$status = $wsus.GetStatus()
|
||||
$totalComputers = $status.ComputerTargetCount
|
||||
|
||||
# computers with errors
|
||||
$computerTargetScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||
$computerTargetScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Failed
|
||||
$computersWithErrors = $wsus.GetComputerTargetCount($computerTargetScope)
|
||||
|
||||
# computers with needed updates
|
||||
$computerTargetScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotInstalled -bor [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot -bor [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Downloaded
|
||||
$computerTargetScope.ExcludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Failed
|
||||
$computersNeedingUpdates = $wsus.GetComputerTargetCount($computerTargetScope)
|
||||
|
||||
# computers without status
|
||||
$computerTargetScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||
$computerTargetScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Unknown
|
||||
$computerTargetScope.ExcludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Failed -bor [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::NotInstalled -bor [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::InstalledPendingReboot -bor [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::Downloaded
|
||||
$computersWithoutStatus = $wsus.GetComputerTargetCount($computerTargetScope)
|
||||
|
||||
|
||||
|
||||
# computers that are OK
|
||||
$computersOK = $totalComputers - $computersWithErrors - $computersNeedingUpdates - $computersWithoutStatus
|
||||
|
||||
|
||||
|
||||
# needed, but not approved updates
|
||||
$updateScope = new-object Microsoft.UpdateServices.Administration.UpdateScope
|
||||
$updateScope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::NotApproved
|
||||
$updateServerStatus = $wsus.GetUpdateStatus($updateScope, $False)
|
||||
$updatesNeededByComputersNotApproved = $updateServerStatus.UpdatesNeededByComputersCount
|
||||
|
||||
# computers that did not contact the server in $daysBeforeWarn days
|
||||
$timeSpan = new-object TimeSpan($daysBeforeWarn, 0, 0, 0)
|
||||
$computersNotContacted = $wsus.GetComputersNotContactedSinceCount([DateTime]::UtcNow.Subtract($timeSpan))
|
||||
|
||||
# computers in the "not assigned" group
|
||||
$computerTargetScope = new-object Microsoft.UpdateServices.Administration.ComputerTargetScope
|
||||
$computersNotAssigned = $wsus.GetComputerTargetGroup([Microsoft.UpdateServices.Administration.ComputerTargetGroupId]::UnassignedComputers).GetComputerTargets().Count
|
||||
|
||||
# output and return code
|
||||
# 0: OK
|
||||
# 1: WARNING
|
||||
# 2: CRITICAL
|
||||
# 3: UNKNOWN
|
||||
$returnCode = 0
|
||||
$output = ''
|
||||
|
||||
if ($computersNeedingUpdates -gt 0) {
|
||||
$returnCode = 1
|
||||
$output = "$computersNeedingUpdates PC Desactualizadas"
|
||||
}
|
||||
|
||||
if ($computersWithErrors -gt 0) {
|
||||
$returnCode = 2
|
||||
if ($output -ne '') {
|
||||
$output = $output + ', '
|
||||
}
|
||||
$output = $output + "$computersWithErrors PC Con Errores"
|
||||
}
|
||||
|
||||
if ($computersNotContacted -gt 0) {
|
||||
$returnCode = 2
|
||||
if ($output -ne '') {
|
||||
$output = $output + ', '
|
||||
}
|
||||
$output = $output + "$computersNotContacted PC Sin Contacto ($daysBeforeWarn d)"
|
||||
}
|
||||
|
||||
if ($computersNotAssigned -gt 0) {
|
||||
$returnCode = 2
|
||||
if ($output -ne '') {
|
||||
$output = $output + ', '
|
||||
}
|
||||
$output = $output + "$computersNotAssigned PC Sin Asignar"
|
||||
}
|
||||
|
||||
if ($updatesNeededByComputersNotApproved -gt 0) {
|
||||
$returnCode = 2
|
||||
if ($output -ne '') {
|
||||
$output = $output + ', '
|
||||
}
|
||||
$output = $output + "$updatesNeededByComputersNotApproved Upd. S/A"
|
||||
}
|
||||
|
||||
if ($output -eq '') {
|
||||
$output = 'Todas las Computadoras Asignadas, Activas y Al dia.'
|
||||
}
|
||||
|
||||
$output
|
||||
|
||||
# append performance data
|
||||
'|' + "'PC Desactualizadas'=$computersNeedingUpdates;;;0;$totalComputers"
|
||||
'|' + "'PC Con Errores'=$computersWithErrors;"
|
||||
"'PC Sin Estatus'=$computersWithoutStatus;"
|
||||
"'PC OK'=$computersOK;"
|
||||
|
||||
$host.SetShouldExit($returnCode)
|
||||
exit $returnCode
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user