Misc/helper.psm1

# Helper functions to be used across resources

Function New-DellEventLog{
[CmdletBinding()]
    param( 
            [Parameter (Mandatory=$false)][System.string] $LogName="DellClientBIOS PowerShell",
            [Parameter (Mandatory=$false)][System.string] $SourceName="DellBIOSProvider DSC"
         )

         $CustomLog = Get-EventLog -list | Where-object { $_.logdisplayname -eq $LogName}
         if (! $CustomLog) {
             $ErrorActionPreference = "Continue"
             try{
                 New-EventLog -LogName $LogName -Source $SourceName
                 Write-EventLog -LogName $LogName -Source $SourceName -EntryType Information -EventID 0 -Message "DellBIOSProvider DSC started."
             }
         
             catch [System.Security.SecurityException] {
              Write-Error "Error: Run as elevated user. Unable to write or read to event logs."
            }
         }
         

}

Function Write-DellEventLog{

[CmdletBinding()]
  [OutputType([int])]
    param(
       [Parameter (Mandatory=$false)] [System.string]$LogName="DellClientBIOS PowerShell",
       [Parameter (Mandatory=$false)] [System.string] $SourceName = "DellBIOSProvider DSC",
       [Parameter (Mandatory=$false)] [System.Int16] $EventID=0,
       [Parameter (Mandatory=$false)] [System.String] $EntryType='Information',
       [Parameter(Mandatory=$true)]   [string]$Message
    )

     $CustomLog = Get-EventLog -list | Where-object { $_.logdisplayname -eq $LogName}
         if (! $CustomLog) {
            New-DellEventLog
         }
    Write-EventLog -LogName $LogName -Source $SourceName -EntryType $EntryType -EventID $EventID -Message $Message


}

function Confirm-DellPSDrive{
 [CmdletBinding()]

    # Check if DellBIOSProvider module has already been loaded into the PS session

    $DellPSProvider = Get-Module -name DellBIOSProvider

    if ( !$DellPSProvider)
    {
        Write-Verbose "Drive DellSmbios is not found. Importing DellBiosProvider."
        import-module -name DellBiosProvider -verbose -force -ErrorVariable errorInModule
        If ($errorInModule)
        {
             $Message = �Module DellBiosProvider failed to import. Errors returned: $($errorInModule.exception.message)
             Throw $Message
        }
        else {
            return $false # Module was not already loaded
        }
    }
    else
    {
        return $true}
}


function CheckModuleLoaded{
 [CmdletBinding()]

    # Check if DellBIOSProvider module has already been loaded into the PS session

    $DellPSProvider = Get-Module -name DellBIOSProvider

    if ( !$DellPSProvider)
    {
            return $false # Module was not already loaded
    }
    else
    {
        return $true
    }
}
# SIG # Begin signature block
# MIIVqQYJKoZIhvcNAQcCoIIVmjCCFZYCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCC6x9zLFGpcQgL3
# nD3MHa+Ep3xyKa03AHXTmy14xLaVWKCCCiMwggTCMIIDqqADAgECAhAiNl3Koo7M
# bamHXZYvcHGpMA0GCSqGSIb3DQEBCwUAMH8xCzAJBgNVBAYTAlVTMR0wGwYDVQQK
# ExRTeW1hbnRlYyBDb3Jwb3JhdGlvbjEfMB0GA1UECxMWU3ltYW50ZWMgVHJ1c3Qg
# TmV0d29yazEwMC4GA1UEAxMnU3ltYW50ZWMgQ2xhc3MgMyBTSEEyNTYgQ29kZSBT
# aWduaW5nIENBMB4XDTE4MDkyNzAwMDAwMFoXDTIxMDkyNjIzNTk1OVowWjELMAkG
# A1UEBhMCVVMxDjAMBgNVBAgMBVRleGFzMRMwEQYDVQQHDApSb3VuZCBSb2NrMRIw
# EAYDVQQKDAlEZWxsIEluYy4xEjAQBgNVBAMMCURlbGwgSW5jLjCCASIwDQYJKoZI
# hvcNAQEBBQADggEPADCCAQoCggEBAK2E5sUV7O7RXKt547mMdmq27CulgmONL6w3
# 2c5gs7vQsH3KWy9Q5rQ83MEPnRncZy71Alrky1G3dV3d1CxH7kH8xfu+YOUR+OVo
# VOFgkoT4tY2xST2B+WfS1jXJKzj5VQuOTn/f2Qie3mA02e3/YlTAMUmOqi4a2gNH
# 3r/de81Yj3e/DqzFV5rWrTfdZ7SQNoWVKA/cVu5KrPdXPjqMpRMxnjP4WPzs6eR0
# 4ONH6tvUNWP6PCrRxg5EIpKhbW0DZxvp1VqXDCyQLe98cjgbgD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