private/Setting.ps1

function New-LocalAdmin {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$NewLocalAdmin,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$Password
    )

    if (Get-LocalUser -Name $NewLocalAdmin) {
        Write-Verbose -Message "User already exist, reseting the password..."
        Get-LocalUser -Name $NewLocalAdmin | Set-LocalUser -Password (ConvertTo-SecureString -AsPlainText $Password -Force)
    }
    else {
        New-LocalUser -Name $NewLocalAdmin -Password (ConvertTo-SecureString -AsPlainText $Password -Force) -FullName $NewLocalAdmin -Description "Ami-User"
        Write-Verbose -Message "$NewLocalAdmin local user created"
    }
    if ([bool]((Get-LocalGroupMember -Group "Administrateurs").Name -like ("*$NewLocalAdmin*"))) {
        Write-Verbose -Message "$NewLocalAdmin added to the local administrator group"
    }
    else {
        Write-Verbose -Message "$NewLocalAdmin is already in administrator group"
        Add-LocalGroupMember -Group "Administrateurs" -Member $NewLocalAdmin
    }
}

function Set-ConfigMode {
    [CmdletBinding(
        SupportsShouldProcess = $true
    )]
    Param(
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [bool]$Statut
    )

    if ($Statut -eq $true) {
        netsh advfirewall set allprofiles state off
        Enable-WSManCredSSP -Role server
    }
}

function Set-Accessibility {
    [CmdletBinding(
        SupportsShouldProcess = $true
    )]
    Param(
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [bool]$Statut
    )

    if ($Statut -eq $true) {
        Enable-PSRemoting -Force
        winrm quickconfig -q
        Start-Service WinRM
        Set-Service WinRM -StartupType Automatic
    }

}

function Set-Network {
    Param(
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$IPAddress,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$InterfaceIndex,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$PrefixLength,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [string]$DefaultGateway,
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [array]$Dns
    )

    if (!($IPAddress) -or !($PrefixLength) -or !($DefaultGateway) -or !($Dns)) {
        return
    }

    New-NetIPAddress -InterfaceIndex $InterfaceIndex -IPAddress $IPAddress -PrefixLength $PrefixLength -DefaultGateway $DefaultGateway
    Set-DnsClientServerAddress -InterfaceIndex $InterfaceIndex -ServerAddress $Dns

}