Functions/Invoke-CreateAutopilotPartnerCsv.ps1


function Invoke-CreateAutopilotPartnerCsv {
    [CmdletBinding()]
    param (
        [Parameter()] [string] $InputFile,
        [Parameter(Mandatory)] [string] $OutFile,
        [Parameter()] [string] $Blank
    )


    $ErrorActionPreference = "Stop"
    $Result = @()
    if ($InputFile) {
        $ExcelData = Import-Excel $InputFile
    } else {
        $ExcelData = [PSCustomObject]@{
            Serienummer = $null
            Merk        = $null
            Type        = $null
        }
    }

    foreach ($e in $ExcelData) {

        $obj = [PSCustomObject]@{
            "Device Serial Number" = $e.Serienummer
            "Windows Product ID"   = ""
            "Hardware Hash"        = ""
            "Manufacturer name"    = $e.Merk
            "Device model"         = $e.Type
        }
        $Result += $obj

    }

    Write-Verbose "Device Serial Number,Windows Product ID,Hardware Hash,Manufacturer name,Device model"

    # $Result | Format-Table
    $Result | Export-Csv $OutFile -NoTypeInformation
    (Get-Content $OutFile).Replace('"', '') | Out-File $OutFile


}