public/Core.ps1

function Ami {
    [CmdletBinding(
        SupportsShouldProcess = $true
    )]
    param (
        [Parameter(Mandatory = $true,
            Position = 0,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true,
            HelpMessage = "Path to one or more locations.")]
        [Alias("PSPath")]
        [ValidateNotNullOrEmpty()]
        [string]
        $ProfilPath
    )

    begin {
        if (!(Test-HtPsRunAs)) {
            Write-Host "You must launch Ami as admin, exit..."
            pause
            exit
        }
    
        if (!(Test-Path "$($InstallPath)/Installed.txt") -or !(Test-Path $InstallPath)) {
            ForEach ($Folder in @("data", "download", "config")) {
                New-Item -Path (Join-Path $InstallPath $Folder) -ItemType Directory | Out-Null
            }
            Install-PackageProvider -Name Nuget -Force
            Get-Date | Out-File -Encoding UTF8 -FilePath "$($InstallPath)/Installed.txt"
        }
        else {
            Write-Host "Install folder is Already created !"
        }

        Read-Host "Start..., press enter"
    }
    process {
        if ([string]$ProfilPath) {
            $configuration = Confirm-Configuration -Configuration (Import-Configuration -Profile $ProfilPath)

            <##
 
            foreach ($Section in $configuration.PSobject.Properties) {
                if (![bool]($Section -match "Filename")) {
                    $Section
                }
            }
 
            #>


            if ([bool]($configuration.PSobject.Properties.name -match "New-LocalAdmin")) {
                New-LocalAdmin -NewLocalAdmin $configuration.("New-LocalAdmin").NewLocalAdmin -Password $configuration.("New-LocalAdmin").Password
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Set-Network")) {
                $NetworkCards = Get-NetAdapter | Where-Object "MediaConnectionState" -Match "Connected" | Select-Object *
                foreach ($Card in $NetworkCards) {
                    $Ip = Get-NetIPAddress -InterfaceAlias $Card.InterfaceAlias | Where-Object "AddressFamily" -Match "IPv4" | Select-Object *
                    Write-Host "Card Index:" $Card.InterfaceIndex " -- Card Name: " $Card.InterfaceAlias " -- with ip: " $Ip.IPAddress
                }
                if (!($InterfaceIndex = Read-Host "which card do you want to set ? (Card Index or press enter to return)")) {
                    return
                }
                Set-Network -InterfaceIndex $InterfaceIndex -IPAddress $configuration.("Set-Network").IPAddress -PrefixLength $configuration.("Set-Network").PrefixLength -DefaultGateway $configuration.("Set-Network").DefaultGateway -Dns $configuration.("Set-Network").Dns
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Set-Accessibility")) {
                Set-Accessibility -Statut $configuration.("Set-Accessibility").Statut
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Set-ConfigMode")) {
                Set-ConfigMode -Statut $configuration.("Set-ConfigMode").Statut
            }


            
            if ([bool]($configuration.PSobject.Properties.name -match "Install-Features")) { 
                Install-Features -Features $configuration.("Install-Features").Features
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Install-NiniteApps")) {
                Install-NiniteApps -Apps $configuration.("Install-NiniteApps").Apps
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Install-ChocoApps")) {
                Install-ChocoApps -Apps $configuration.("Install-ChocoApps").Apps
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Copy-FileApp")) {
                Copy-FileApp -Path $configuration.("Copy-FileApp").Path -DesktopLink $configuration.("Copy-FileApp").DesktopLink
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Install-ExeApp")) {
                Install-ExeApp -Path $configuration.("Install-ExeApp").Path -SetupArgs $configuration.("Install-ExeApp").SetupArgs
            }

            if ([bool]($configuration.PSobject.Properties.name -match "Install-MsiApp")) {
                Install-MsiApp -Path $configuration.("Install-MsiApp").Path -SetupArgs $configuration.("Install-MsiApp").SetupArgs
            }
    
            Save-Configuration -Configuration $configuration
        }
    
        Read-Host "End..., press enter"
    }
}