ADSQL.ps1


<#PSScriptInfo
 
.VERSION 1.0
 
.GUID e628b5fb-a151-4cfa-a8d7-2d6f830f0865
 
.AUTHOR Gabriel Mbanda
 
.COMPANYNAME Medica-Medizintechnik GmbH
 
.COPYRIGHT � 2015 Medica-Medizintechnik. All rights reserved.
 
.TAGS
 
.LICENSEURI https://www.powershellgallery.com/
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
contoso script now supports following features
Feature 1: Portability Without ADModule
Feature 2: LOG REports
Feature 3: Mail Reports on Failed updated Users
 
#>


<#
 
.DESCRIPTION
 This Script will query Informationen based on the Query Provided from ConfidentialTable or any Sql Table and then Populate it to the Active-Directory. the script has some error handle before the Population. and at every step if a wrong Data or an unknown Datatype is met, an E-mail will be sent to the it-service@thera-trainer.de
 
#>
 

Param(
    [Parameter(Mandatory = $False,
               HelpMessage = "ConnectionString: Enter the Username of the SqlUser",
               Position = 0)]
    [ValidateNotNullOrEmpty()]
    [STRING]$Username = "SqlSearch",
    [Parameter(Mandatory = $False,
               HelpMessage = "ConnectionString:Enter the Password of the SqlUser in PlainText",
               Position = 1)]
    [ValidateNotNullOrEmpty()]
    [STRING]$Password = "med_search",
    [Parameter(Mandatory = $False,
               HelpMessage = "Enter THe SqlQuery in format Here-String")]
    [ValidateNotNullOrEmpty()]
    $SQLQuery = @"
          SELECT
            [E-Mail],
            Personalnr,
            Vorname,
            Nachname,
            Durchwahl,
            case when SIG_E is null then [SIG_D] else concat (SIG_D,' |') end as [SIG_D],
            case when SIG_E2 is null then [SIG_D2] else concat (SIG_D2,' |') end as [SIG_D2],
            [SIG_E],
            [SIG_E2],
            case when SIG_TITELE is null then [SIG_TITEL] else concat (SIG_TITEL,' |') end as [SIG_TITEL],
            [SIG_TITELE],
            LastUpdate
    
            FROM (
            Select
              [Medica Medizintechnik GmbH`$Employee].[Company E-Mail] As [E-Mail],
              [Medica Medizintechnik GmbH`$Employee].No_ As Personalnr,
              [Medica Medizintechnik GmbH`$Employee].[First Name] As Vorname,
              [Medica Medizintechnik GmbH`$Employee].[Last Name] As Nachname,
              [Medica Medizintechnik GmbH`$Confidential Information].[Confidential Code] As
              SignaturCode,
              [Medica Medizintechnik GmbH`$Confidential Information].Description As
              Beschreibung,
               
               case when [Medica Medizintechnik GmbH`$Employee].[Job Title] = 'EXP_AD' then concat(
               
               
              Case
              When Len([Medica Medizintechnik GmbH`$Employee].Extension) = 3 Then
                Concat('+49 7355-93 14', [Medica Medizintechnik GmbH`$Employee].Extension)
                Else Case
                  When Len([Medica Medizintechnik GmbH`$Employee].Extension) =
                  4 Then Concat('+49 7355-93 14',
                  [Medica Medizintechnik GmbH`$Employee].Extension)
                  Else Concat('+49 ', Right([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_], Case
        When Len([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_]) > 2 Then Len([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_]) - 1 Else 0 End)) End
              End,' / ',Concat('+49 ', Right([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_], Case
        When Len([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_]) > 2 Then Len([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_]) - 1 Else 0 End))) else
               
               
               
              Case
              When Len([Medica Medizintechnik GmbH`$Employee].Extension) = 3 Then
                Concat('+49 7355-93 14', [Medica Medizintechnik GmbH`$Employee].Extension)
                Else Case
                  When Len([Medica Medizintechnik GmbH`$Employee].Extension) =
                  4 Then Concat('+49 7355-93 14',
                  [Medica Medizintechnik GmbH`$Employee].Extension)
                  Else Concat('+49 ', Right([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_], Case
        When Len([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_]) > 2 Then Len([Medica Medizintechnik GmbH`$Employee].[Mobile Phone No_]) - 1 Else 0 End)) End
              End
               
               
               end As Durchwahl,
              SubQuery.last_user_update1 As LastUpdate
            From
              [Medica Medizintechnik GmbH`$Employee] Inner Join
             [Medica Medizintechnik GmbH`$Confidential Information]
                On [Medica Medizintechnik GmbH`$Confidential Information].[Employee No_] =
                [Medica Medizintechnik GmbH`$Employee].No_,
              (Select
              case when Max(Distinct sys.dm_db_index_usage_stats.last_user_update) is null then Max(Distinct sys.dm_db_index_usage_stats.last_user_seek) else Max(Distinct sys.dm_db_index_usage_stats.last_user_update) end As
              last_user_update1
            From
              sys.dm_db_index_usage_stats Inner Join
              sys.objects
                On sys.objects.object_id = sys.dm_db_index_usage_stats.object_id
            Where
              (sys.dm_db_index_usage_stats.object_id = 2007730255) Or
              (sys.dm_db_index_usage_stats.object_id = 1447728260)) As SubQuery) as s
            PIVOT
            (
                MAX(Beschreibung)
                FOR [SignaturCode] IN ([SIG_D],[SIG_D2],[SIG_E],[SIG_E2],[SIG_TITEL],[SIG_TITELE])
            )AS pvt
"@
,
    [Parameter(Mandatory = $False,
               HelpMessage = "Enter the Database Instance Name")]
    [ValidateNotNullOrEmpty()]
    [STRING]$Server = "SvrNavDb01",
    [Parameter(Mandatory = $False,
               HelpMessage = "Enter the Database Name")]
    [ValidateNotNullOrEmpty()]
    [STRING]$Database = "NAV_Live_2013",
    
    #CheckDate
    [Parameter(HelpMessage = "CheckUpdatePath")]
    [ValidateScript({Test-Path $(Split-Path $_ -Parent)})]
    [ValidateNotNullOrEmpty()]
    [STRING]$CheckDatePath = "C:\Scripts\ADNAV\DatePath.txt"
)

###################������������������������������������������������������������������������������##########

function ConvertTo-EnhancedHTML {
<#
.SYNOPSIS
Provides an enhanced version of the ConvertTo-HTML command that includes
inserting an embedded CSS style sheet, JQuery, and JQuery Data Tables for
interactivity. Intended to be used with HTML fragments that are produced
by ConvertTo-EnhancedHTMLFragment. This command does not accept pipeline
input.
  
  
.PARAMETER jQueryURI
A Uniform Resource Indicator (URI) pointing to the location of the
jQuery script file. You can download jQuery from www.jquery.com; you should
host the script file on a local intranet Web server and provide a URI
that starts with http:// or https://. Alternately, you can also provide
a file system path to the script file, although this may create security
issues for the Web browser in some configurations.
  
  
Tested with v1.8.2.
  
  
Defaults to http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js, which
will pull the file from Microsoft's ASP.NET Content Delivery Network.
  
  
.PARAMETER jQueryDataTableURI
A Uniform Resource Indicator (URI) pointing to the location of the
jQuery Data Table script file. You can download this from www.datatables.net;
you should host the script file on a local intranet Web server and provide a URI
that starts with http:// or https://. Alternately, you can also provide
a file system path to the script file, although this may create security
issues for the Web browser in some configurations.
  
  
Tested with jQuery DataTable v1.9.4
  
  
Defaults to http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.min.js,
which will pull the file from Microsoft's ASP.NET Content Delivery Network.
  
  
.PARAMETER CssStyleSheet
The CSS style sheet content - not a file name. If you have a CSS file,
you can load it into this parameter as follows:
  
  
    -CSSStyleSheet (Get-Content MyCSSFile.css)
  
  
Alternately, you may link to a Web server-hosted CSS file by using the
-CssUri parameter.
  
  
.PARAMETER CssUri
A Uniform Resource Indicator (URI) to a Web server-hosted CSS file.
Must start with either http:// or https://. If you omit this, you
can still provide an embedded style sheet, which makes the resulting
HTML page more standalone. To provide an embedded style sheet, use
the -CSSStyleSheet parameter.
  
  
.PARAMETER Title
A plain-text title that will be displayed in the Web browser's window
title bar. Note that not all browsers will display this.
  
  
.PARAMETER PreContent
Raw HTML to insert before all HTML fragments. Use this to specify a main
title for the report:
  
  
    -PreContent "<H1>My HTML Report</H1>"
  
  
.PARAMETER PostContent
Raw HTML to insert after all HTML fragments. Use this to specify a
report footer:
  
  
    -PostContent "Created on $(Get-Date)"
  
  
.PARAMETER HTMLFragments
One or more HTML fragments, as produced by ConvertTo-EnhancedHTMLFragment.
  
  
    -HTMLFragments $part1,$part2,$part3
.EXAMPLE
For examples, please see the free ebooks, "Creating HTML Reports in PowerShell,"
available at http://powershell.org/ebooks.
  
  
  
#>

    [CmdletBinding()]
    param(
        [string]$jQueryURI = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js',
        [string]$jQueryDataTableURI = 'http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.min.js',
        [Parameter(ParameterSetName='CSSContent')][string[]]$CssStyleSheet,
        [Parameter(ParameterSetName='CSSURI')][string[]]$CssUri,
        [string]$Title = 'Report',
        [string]$PreContent,
        [string]$PostContent,
        [Parameter(Mandatory=$True)][string[]]$HTMLFragments
    )


    <#
        Add CSS style sheet. If provided in -CssUri, add a <link> element.
        If provided in -CssStyleSheet, embed in the <head> section.
        Note that BOTH may be supplied - this is legitimate in HTML.
    #>

    Write-Verbose "Making CSS style sheet"
    $stylesheet = ""
    if ($PSBoundParameters.ContainsKey('CssUri')) {
        $stylesheet = "<link rel=`"stylesheet`" href=`"$CssUri`" type=`"text/css`" />"
    }
    if ($PSBoundParameters.ContainsKey('CssStyleSheet')) {
        $stylesheet = "<style>$CssStyleSheet</style>" | Out-String
    }


    <#
        Create the HTML tags for the page title, and for
        our main javascripts.
    #>

    Write-Verbose "Creating <TITLE> and <SCRIPT> tags"
    $titletag = ""
    if ($PSBoundParameters.ContainsKey('title')) {
        $titletag = "<title>$title</title>"
    }
    $script += "<script type=`"text/javascript`" src=`"$jQueryURI`"></script>`n<script type=`"text/javascript`" src=`"$jQueryDataTableURI`"></script>"


    <#
        Render supplied HTML fragments as one giant string
    #>

    Write-Verbose "Combining HTML fragments"
    $body = $HTMLFragments | Out-String


    <#
        If supplied, add pre- and post-content strings
    #>

    Write-Verbose "Adding Pre and Post content"
    if ($PSBoundParameters.ContainsKey('precontent')) {
        $body = "$PreContent`n$body"
    }
    if ($PSBoundParameters.ContainsKey('postcontent')) {
        $body = "$body`n$PostContent"
    }


    <#
        Add a final script that calls the datatable code
        We dynamic-ize all tables with the .enhancedhtml-dynamic-table
        class, which is added by ConvertTo-EnhancedHTMLFragment.
    #>

    Write-Verbose "Adding interactivity calls"
    $datatable = ""
    $datatable = "<script type=`"text/javascript`">"
    $datatable += '$(document).ready(function () {'
    $datatable += "`$('.enhancedhtml-dynamic-table').dataTable();"
    $datatable += '} );'
    $datatable += "</script>"


    <#
        Datatables expect a <thead> section containing the
        table header row; ConvertTo-HTML doesn't produce that
        so we have to fix it.
    #>

    Write-Verbose "Fixing table HTML"
    $body = $body -replace '<tr><th>','<thead><tr><th>'
    $body = $body -replace '</th></tr>','</th></tr></thead>'


    <#
        Produce the final HTML. We've more or less hand-made
        the <head> amd <body> sections, but we let ConvertTo-HTML
        produce the other bits of the page.
    #>

    Write-Verbose "Producing final HTML"
    ConvertTo-HTML -Head "$stylesheet`n$titletag`n$script`n$datatable" -Body $body  
    Write-Debug "Finished producing final HTML"


}#End EnhanceHtml
function ConvertTo-EnhancedHTMLFragment {
<#
.SYNOPSIS
Creates an HTML fragment (much like ConvertTo-HTML with the -Fragment switch
that includes CSS class names for table rows, CSS class and ID names for the
table, and wraps the table in a <DIV> tag that has a CSS class and ID name.
  
  
.PARAMETER InputObject
The object to be converted to HTML. You cannot select properties using this
command; precede this command with Select-Object if you need a subset of
the objects' properties.
  
  
.PARAMETER EvenRowCssClass
The CSS class name applied to even-numbered <TR> tags. Optional, but if you
use it you must also include -OddRowCssClass.
  
  
.PARAMETER OddRowCssClass
The CSS class name applied to odd-numbered <TR> tags. Optional, but if you
use it you must also include -EvenRowCssClass.
  
  
.PARAMETER TableCssID
Optional. The CSS ID name applied to the <TABLE> tag.
  
  
.PARAMETER DivCssID
Optional. The CSS ID name applied to the <DIV> tag which is wrapped around the table.
  
  
.PARAMETER TableCssClass
Optional. The CSS class name to apply to the <TABLE> tag.
  
  
.PARAMETER DivCssClass
Optional. The CSS class name to apply to the wrapping <DIV> tag.
  
  
.PARAMETER As
Must be 'List' or 'Table.' Defaults to Table. Actually produces an HTML
table either way; with Table the output is a grid-like display. With
List the output is a two-column table with properties in the left column
and values in the right column.
  
  
.PARAMETER Properties
A comma-separated list of properties to include in the HTML fragment.
This can be * (which is the default) to include all properties of the
piped-in object(s). In addition to property names, you can also use a
hashtable similar to that used with Select-Object. For example:
  
  
 Get-Process | ConvertTo-EnhancedHTMLFragment -As Table `
               -Properties Name,ID,@{n='VM';
                                     e={$_.VM};
                                     css={if ($_.VM -gt 100) { 'red' }
                                          else { 'green' }}}
  
  
This will create table cell rows with the calculated CSS class names.
E.g., for a process with a VM greater than 100, you'd get:
  
  
  <TD class="red">475858</TD>
    
You can use this feature to specify a CSS class for each table cell
based upon the contents of that cell. Valid keys in the hashtable are:
  
  
  n, name, l, or label: The table column header
  e or expression: The table cell contents
  css or csslcass: The CSS class name to apply to the <TD> tag
    
Another example:
  
  
  @{n='Free(MB)';
    e={$_.FreeSpace / 1MB -as [int]};
    css={ if ($_.FreeSpace -lt 100) { 'red' } else { 'blue' }}
      
This example creates a column titled "Free(MB)". It will contain
the input object's FreeSpace property, divided by 1MB and cast
as a whole number (integer). If the value is less than 100, the
table cell will be given the CSS class "red." If not, the table
cell will be given the CSS class "blue." The supplied cascading
style sheet must define ".red" and ".blue" for those to have any
effect.
  
  
.PARAMETER PreContent
Raw HTML content to be placed before the wrapping <DIV> tag.
For example:
  
  
    -PreContent "<h2>Section A</h2>"
  
  
.PARAMETER PostContent
Raw HTML content to be placed after the wrapping <DIV> tag.
For example:
  
  
    -PostContent "<hr />"
  
  
.PARAMETER MakeHiddenSection
Used in conjunction with -PreContent. Adding this switch, which
needs no value, turns your -PreContent into clickable report
section header. The section will be hidden by default, and clicking
the header will toggle its visibility.
  
  
When using this parameter, consider adding a symbol to your -PreContent
that helps indicate this is an expandable section. For example:
  
  
    -PreContent '<h2>&diams; My Section</h2>'
  
  
If you use -MakeHiddenSection, you MUST provide -PreContent also, or
the hidden section will not have a section header and will not be
visible.
  
  
.PARAMETER MakeTableDynamic
When using "-As Table", makes the table dynamic. Will be ignored
if you use "-As List". Dynamic tables are sortable, searchable, and
are paginated.
  
  
You should not use even/odd styling with tables that are made
dynamic. Dynamic tables automatically have their own even/odd
styling. You can apply CSS classes named ".odd" and ".even" in
your CSS to style the even/odd in a dynamic table.
  
  
.EXAMPLE
 $fragment = Get-WmiObject -Class Win32_LogicalDisk |
             Select-Object -Property PSComputerName,DeviceID,FreeSpace,Size |
             ConvertTo-HTMLFragment -EvenRowClass 'even' `
                                    -OddRowClass 'odd' `
                                    -PreContent '<h2>Disk Report</h2>' `
                                    -MakeHiddenSection `
                                    -MakeTableDynamic
  
  
 You will usually save fragments to a variable, so that multiple fragments
 (each in its own variable) can be passed to ConvertTo-EnhancedHTML.
  
.NOTES
Consider adding the following to your CSS when using dynamic tables
(replace the * with .):
  
  
    *paginate_enabled_next, .paginate_enabled_previous {
        cursor:pointer;
        border:1px solid #222222;
        background-color:#dddddd;
        padding:2px;
        margin:4px;
        border-radius:2px;
    }
    *paginate_disabled_previous, .paginate_disabled_next {
        color:#666666;
        cursor:pointer;
        background-color:#dddddd;
        padding:2px;
        margin:4px;
        border-radius:2px;
    }
    *dataTables_info { margin-bottom:4px; }
  
  
This applies appropriate coloring to the next/previous buttons,
and applies a small amount of space after the dynamic table.
  
  
If you choose to make sections hidden (meaning they can be shown
and hidden by clicking on the section header), consider adding
the following to your CSS (replace the * with .):
  
  
    *sectionheader { cursor:pointer; }
    *sectionheader:hover { color:red; }
  
  
This will apply a hover-over color, and change the cursor icon,
to help visually indicate that the section can be toggled.
#>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
        [object[]]$InputObject,


        [string]$EvenRowCssClass,
        [string]$OddRowCssClass,
        [string]$TableCssID,
        [string]$DivCssID,
        [string]$DivCssClass,
        [string]$TableCssClass,


        [ValidateSet('List','Table')]
        [string]$As = 'Table',


        [object[]]$Properties = '*',


        [string]$PreContent,


        [switch]$MakeHiddenSection,


        [switch]$MakeTableDynamic,


        [string]$PostContent
    )
    BEGIN {
        <#
            Accumulate output in a variable so that we don't
            produce an array of strings to the pipeline, but
            instead produce a single string.
        #>

        $out = ''


        <#
            Add the section header (pre-content). If asked to
            make this section of the report hidden, set the
            appropriate code on the section header to toggle
            the underlying table. Note that we generate a GUID
            to use as an additional ID on the <div>, so that
            we can uniquely refer to it without relying on the
            user supplying us with a unique ID.
        #>

        Write-Verbose "Precontent"
        if ($PSBoundParameters.ContainsKey('PreContent')) {
            if ($PSBoundParameters.ContainsKey('MakeHiddenSection')) {
               [string]$tempid = [System.Guid]::NewGuid()
               $out += "<span class=`"sectionheader`" onclick=`"`$('#$tempid').toggle(500);`">$PreContent</span>`n"
            } else {
                $out += $PreContent
                $tempid = ''
            }
        }


        <#
            The table will be wrapped in a <div> tag for styling
            purposes. Note that THIS, not the table per se, is what
            we hide for -MakeHiddenSection. So we will hide the section
            if asked to do so.
        #>

        Write-Verbose "DIV"
        if ($PSBoundParameters.ContainsKey('DivCSSClass')) {
            $temp = " class=`"$DivCSSClass`""
        } else {
            $temp = ""
        }
        if ($PSBoundParameters.ContainsKey('MakeHiddenSection')) {
            $temp += " id=`"$tempid`" style=`"display:none;`""
        } else {
            $tempid = ''
        }
        if ($PSBoundParameters.ContainsKey('DivCSSID')) {
            $temp += " id=`"$DivCSSID`""
        }
        $out += "<div $temp>"


        <#
            Create the table header. If asked to make the table dynamic,
            we add the CSS style that ConvertTo-EnhancedHTML will look for
            to dynamic-ize tables.
        #>

        Write-Verbose "TABLE"
        $_TableCssClass = ''
        if ($PSBoundParameters.ContainsKey('MakeTableDynamic') -and $As -eq 'Table') {
            $_TableCssClass += 'enhancedhtml-dynamic-table '
        }
        if ($PSBoundParameters.ContainsKey('TableCssClass')) {
            $_TableCssClass += $TableCssClass
        }
        if ($_TableCssClass -ne '') {
            $css = "class=`"$_TableCSSClass`""
        } else {
            $css = ""
        }
        if ($PSBoundParameters.ContainsKey('TableCSSID')) {
            $css += "id=`"$TableCSSID`""
        } else {
            if ($tempid -ne '') {
                $css += "id=`"$tempid`""
            }
        }
        $out += "<table $css>"


        <#
            We're now setting up to run through our input objects
            and create the table rows
        #>

        $fragment = ''
        $wrote_first_line = $false
        $even_row = $false


        if ($properties -eq '*') {
            $all_properties = $true
        } else {
            $all_properties = $false
        }


    }
    PROCESS {


        foreach ($object in $inputobject) {
            Write-Verbose "Processing object"
            $datarow = ''
            $headerrow = ''


            <#
                Apply even/odd row class. Note that this will mess up the output
                if the table is made dynamic. That's noted in the help.
            #>

            if ($PSBoundParameters.ContainsKey('EvenRowCSSClass') -and $PSBoundParameters.ContainsKey('OddRowCssClass')) {
                if ($even_row) {
                    $row_css = $OddRowCSSClass
                    $even_row = $false
                    Write-Verbose "Even row"
                } else {
                    $row_css = $EvenRowCSSClass
                    $even_row = $true
                    Write-Verbose "Odd row"
                }
            } else {
                $row_css = ''
                Write-Verbose "No row CSS class"
            }


            <#
                If asked to include all object properties, get them.
            #>

            if ($all_properties) {
                $properties = $object | Get-Member -MemberType Properties | Select -ExpandProperty Name
            }


            <#
                We either have a list of all properties, or a hashtable of
                properties to play with. Process the list.
            #>

            foreach ($prop in $properties) {
                Write-Verbose "Processing property"
                $name = $null
                $value = $null
                $cell_css = ''


                <#
                    $prop is a simple string if we are doing "all properties,"
                    otherwise it is a hashtable. If it's a string, then we
                    can easily get the name (it's the string) and the value.
                #>

                if ($prop -is [string]) {
                    Write-Verbose "Property $prop"
                    $name = $Prop
                    $value = $object.($prop)
                } elseif ($prop -is [hashtable]) {
                    Write-Verbose "Property hashtable"
                    <#
                        For key "css" or "cssclass," execute the supplied script block.
                        It's expected to output a class name; we embed that in the "class"
                        attribute later.
                    #>

                    if ($prop.ContainsKey('cssclass')) { $cell_css = $Object | ForEach $prop['cssclass'] }
                    if ($prop.ContainsKey('css')) { $cell_css = $Object | ForEach $prop['css'] }


                    <#
                        Get the current property name.
                    #>

                    if ($prop.ContainsKey('n')) { $name = $prop['n'] }
                    if ($prop.ContainsKey('name')) { $name = $prop['name'] }
                    if ($prop.ContainsKey('label')) { $name = $prop['label'] }
                    if ($prop.ContainsKey('l')) { $name = $prop['l'] }


                    <#
                        Execute the "expression" or "e" key to get the value of the property.
                    #>

                    if ($prop.ContainsKey('e')) { $value = $Object | ForEach $prop['e'] }
                    if ($prop.ContainsKey('expression')) { $value = $Object | ForEach $prop['expression'] }


                    <#
                        Make sure we have a name and a value at this point.
                    #>

                    if ($name -eq $null -or $value -eq $null) {
                        Write-Error "Hashtable missing Name and/or Expression key"
                    }
                } else {
                    <#
                        We got a property list that wasn't strings and
                        wasn't hashtables. Bad input.
                    #>

                    Write-Warning "Unhandled property $prop"
                }


                <#
                    When constructing a table, we have to remember the
                    property names so that we can build the table header.
                    In a list, it's easier - we output the property name
                    and the value at the same time, since they both live
                    on the same row of the output.
                #>

                if ($As -eq 'table') {
                    Write-Verbose "Adding $name to header and $value to row"
                    $headerrow += "<th>$name</th>"
                    $datarow += "<td$(if ($cell_css -ne '') { ' class="'+$cell_css+'"' })>$value</td>"
                } else {
                    $wrote_first_line = $true
                    $headerrow = ""
                    $datarow = "<td$(if ($cell_css -ne '') { ' class="'+$cell_css+'"' })>$name :</td><td$(if ($cell_css -ne '') { ' class="'+$cell_css+'"' })>$value</td>"
                    $out += "<tr$(if ($row_css -ne '') { ' class="'+$row_css+'"' })>$datarow</tr>"
                }
            }


            <#
                Write the table header, if we're doing a table.
            #>

            if (-not $wrote_first_line -and $as -eq 'Table') {
                Write-Verbose "Writing header row"
                $out += "<tr>$headerrow</tr><tbody>"
                $wrote_first_line = $true
            }


            <#
                In table mode, write the data row.
            #>

            if ($as -eq 'table') {
                Write-Verbose "Writing data row"
                $out += "<tr$(if ($row_css -ne '') { ' class="'+$row_css+'"' })>$datarow</tr>"
            }
        }
    }
    END {
        <#
            Finally, post-content code, the end of the table,
            the end of the <div>, and write the final string.
        #>

        Write-Verbose "PostContent"
        if ($PSBoundParameters.ContainsKey('PostContent')) {
            $out += "`n$PostContent"
        }
        Write-Verbose "Done"
        $out += "</tbody></table></div>"
        Write-Output $out
    }
}#End EnhanceHtmlFragment
function Log {
<#
 .Synopsis
  Function to log input string to file and display it to screen
 
 .Description
  Function to log input string to file and display it to screen. Log entries in the log file are time stamped. Function allows for displaying text to screen in different colors.
 
 .Parameter String
  The string to be displayed to the screen and saved to the log file
 
 .Parameter Color
  The color in which to display the input string on the screen
  Default is White
  Valid options are
    Black
    Blue
    Yellow
    DarkBlue
    DarkYellow
    DarkGray
    DarkGreen
    DarkMagenta
    DarkRed
    DarkYellow
    Gray
    Green
    Magenta
    Red
    White
    Yellow
 
 .Parameter LogFile
  Path to the file where the input string should be saved.
  Example: c:\log.txt
  If absent, the input string will be displayed to the screen only and not saved to log file
 
 .Example
  Log -String "Hello World" -Color Yellow -LogFile c:\log.txt
  This example displays the "Hello World" string to the console in yellow, and adds it as a new line to the file c:\log.txt
  If c:\log.txt does not exist it will be created.
  Log entries in the log file are time stamped. Sample output:
    2014.08.06 06:52:17 AM: Hello World
 
 .Example
  Log "$((Get-Location).Path)" Yellow
  This example displays current path in Yellow, and does not log the displayed text to log file.
 
 .Example
  "$((Get-Process | select -First 1).name) process ID is $((Get-Process | select -First 1).id)" | log -color DarkYellow
  Sample output of this example:
    "MDM process ID is 4492" in dark yellow
 
 .Example
  log "Found",(Get-ChildItem -Path .\ -File).Count,"files in folder",(Get-Item .\).FullName Green,Yellow,Green,Yellow .\mylog.txt
  Sample output will look like:
    Found 520 files in folder D:\Sandbox - and will have the listed foreground colors
 
 .Link
  https://superwidgets.wordpress.com/category/powershell/
 
 .Notes
  Function by Sam Boutros
  v1.0 - 08/06/2014
  v1.1 - 12/01/2014 - added multi-color display in the same line
 
#>


    [CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')] 
    Param(
        [Parameter(Mandatory=$true,
                   ValueFromPipeLine=$true,
                   ValueFromPipeLineByPropertyName=$true,
                   Position=0)]
            [String[]]$String, 
        [Parameter(Mandatory=$false,
                   Position=1)]
            [ValidateSet("Black","Blue","Yellow","DarkBlue","DarkYellow","DarkGray","DarkGreen","DarkMagenta","DarkRed","DarkYellow","Gray","Green","Magenta","Red","White","Yellow")]
            [String[]]$Color = "Green", 
        [Parameter(Mandatory=$false,
                   Position=2)]
            [String]$LogFile,
        [Parameter(Mandatory=$false,
                   Position=3)]
            [Switch]$NoNewLine
    )

    if ($String.Count -gt 1) {
        $i=0
        foreach ($item in $String) {
            if ($Color[$i]) { $col = $Color[$i] } else { $col = "White" }
            Write-Host "$item " -ForegroundColor $col -NoNewline
            $i++
        }
        if (-not ($NoNewLine)) { Write-Host " " }
    } else { 
        if ($NoNewLine) { Write-Host $String -ForegroundColor $Color[0] -NoNewline }
            else { Write-Host $String -ForegroundColor $Color[0] }
    }

    if ($LogFile.Length -gt 2) {
        "$(Get-Date -format "yyyy.MM.dd hh:mm:ss tt"): $($String -join " ")" | Out-File -Filepath $Logfile -Append 
    } else {
        Write-Verbose "Log: Missing -LogFile parameter. Will not save input string to log file.."
    }
}#End Log
Function Test-Entry {
<#
.Synopsis
   This Function Returns a BOOL or the Entry itself , after checking his length
.DESCRIPTION
   Lange Beschreibung
.EXAMPLE
   Beispiel f�r die Verwendung dieses Cmdlets
.EXAMPLE
   Ein weiteres Beispiel f�r die Verwendung dieses Cmdlets
#>

[Cmdletbinding()]
    param ( # Entry to be tested
        [Parameter(Mandatory=$False,
                   ValueFromPipeLine=$true,
                   Position=0)]
        [String]$Item
    )
    Process{
        if(($item -eq $null) -or ($Item.length -eq 1) -or ($Item.length -eq 0)) {Return [bool]$False} 
        Else {$Item}
    }
}#End TestEntry
function Invoke-SqlCommand {
    <#
        .SYNOPSIS
            Executes an SQL statement. Executes using Windows Authentication unless the Username and Password are provided.

        .PARAMETER Server
            The SQL Server instance name.

        .PARAMETER Database
            The SQL Server database name where the query will be executed.

        .PARAMETER Timeout
            The connection timeout.

        .PARAMETER Connection
            The System.Data.SqlClient.SQLConnection instance used to connect.

        .PARAMETER Username
            The SQL Authentication Username.

        .PARAMETER Password
            The SQL Authentication Password.

        .PARAMETER CommandType
            The System.Data.CommandType value specifying Text or StoredProcedure.

        .PARAMETER Query
            The SQL query to execute.

         .PARAMETER Path
            The path to an SQL script.

        .PARAMETER Parameters
            Hashtable containing the key value pairs used to generate as collection of System.Data.SqlParameter.

        .PARAMETER As
            Specifies how to return the result.

            PSCustomObject
             - Returns the result set as an array of System.Management.Automation.PSCustomObject objects.
            DataSet
             - Returns the result set as an System.Data.DataSet object.
            DataTable
             - Returns the result set as an System.Data.DataTable object.
            DataRow
             - Returns the result set as an array of System.Data.DataRow objects.
            Scalar
             - Returns the first column of the first row in the result set. Should be used when a value with no column name is returned (i.e. SELECT COUNT(*) FROM Test.Sample).
            NonQuery
             - Returns the number of rows affected. Should be used for INSERT, UPDATE, and DELETE.

        .EXAMPLE
            PS C:\> Invoke-SqlCommand -Server "DATASERVER" -Database "Web" -Query "SELECT TOP 1 * FROM Test.Sample"

            datetime2 : 1/17/2013 8:46:22 AM
            ID : 202507
            uniqueidentifier1 : 1d0cf1c0-9fb1-4e21-9d5a-b8e9365400fc
            bool1 : False
            datetime1 : 1/17/2013 12:00:00 AM
            double1 : 1
            varchar1 : varchar11
            decimal1 : 1
            int1 : 1

            Returned the first row as a System.Management.Automation.PSCustomObject.

        .EXAMPLE
            PS C:\> Invoke-SqlCommand -Server "DATASERVER" -Database "Web" -Query "SELECT COUNT(*) FROM Test.Sample" -As Scalar

            9544
    #>

    [CmdletBinding(DefaultParameterSetName="Default")]
    param(
        [Parameter(Mandatory=$true, Position=0)]
        [string]$Server,

        [Parameter(Mandatory=$true, Position=1)]
        [string]$Database,

        [Parameter(Mandatory=$false, Position=2)]
        [int]$Timeout=30,

        [System.Data.SqlClient.SQLConnection]$Connection,

        [string]$Username,

        [string]$Password,

        [System.Data.CommandType]$CommandType = [System.Data.CommandType]::Text,

        [string]$Query,

        [ValidateScript({ Test-Path -Path $_ })]
        [string]$Path,

        [hashtable]$Parameters,

        [ValidateSet("DataSet", "DataTable", "DataRow", "PSCustomObject", "Scalar", "NonQuery")]
        [string]$As="PSCustomObject"
    )

    begin {
        if($Path) {
            $Query = [System.IO.File]::ReadAllText("$((Resolve-Path -Path $Path).Path)")
        } else {
            if(-not $Query) {
                throw (New-Object System.ArgumentNullException -ArgumentList "Query","The query statement is missing.")
            }
        }

        $createConnection = (-not $Connection)

        if($createConnection) {
            $Connection = New-Object System.Data.SqlClient.SQLConnection
            if($Username -and $Password) {
                $Connection.ConnectionString = "Server=$($Server);Database=$($Database);User Id=$($Username);Password=$($Password);"
            } else {
                $Connection.ConnectionString = "Server=$($Server);Database=$($Database);Integrated Security=SSPI;"
            }
            if($PSBoundParameters.Verbose) {
                $Connection.FireInfoMessageEventOnUserErrors=$true
                $Connection.Add_InfoMessage([System.Data.SqlClient.SqlInfoMessageEventHandler] { Write-Verbose "$($_)"} )
            }
        }

        if(-not ($Connection.State -like "Open")) { try { $Connection.Open() } catch [Exception] { throw $_ } }
    }

    process {
        $command = New-Object System.Data.SqlClient.SqlCommand ($query, $Connection)
        $command.CommandTimeout = $Timeout
        $command.CommandType = $CommandType
        if($Parameters) {
            foreach ($p in $Parameters.Keys) {
                $command.Parameters.AddWithValue($p, $Parameters[$p]) | Out-Null
            }
        }

        $scriptBlock = {
            $result = @()
            $reader = $command.ExecuteReader()
            if($reader) {
                $counter = $reader.FieldCount
                $columns = @()
                for ($i = 0; $i -lt $counter; $i++) {
                    $columns += $reader.GetName($i)
                }

                if($reader.HasRows) {
                    while ($reader.Read()) {
                        $row = @{}
                        for ($i = 0; $i -lt $counter; $i++) {
                            $row[$columns[$i]] = $reader.GetValue($i)
                        }
                        $result += [PSCustomObject]$row
                    }
                }
            }
            $result
        }

        if($As) {
            switch($As) {
                "Scalar" {
                    $scriptBlock = {
                        $result = $command.ExecuteScalar()
                        $result
                    }
                }
                "NonQuery" {
                    $scriptBlock = {
                        $result = $command.ExecuteNonQuery()
                        $result
                    }
                }
                default {
                    if("DataSet", "DataTable", "DataRow" -contains $As) {
                        $scriptBlock = {
                            $ds = New-Object System.Data.DataSet
                            $da = New-Object System.Data.SqlClient.SqlDataAdapter($command)
                            $da.Fill($ds) | Out-Null
                            switch($As) {
                                "DataSet" { $result = $ds }
                                "DataTable" { $result = $ds.Tables }
                                default { $result = $ds.Tables | ForEach-Object -Process { $_.Rows } }
                            }                            
                            $result
                        }
                    }
                }
            }
        }

        $result = Invoke-Command -ScriptBlock $ScriptBlock
        $command.Parameters.Clear()
    }

    end {
        if($createConnection) { $Connection.Close() }

        $result
    }
}#End SqlCommand
function Check-DBUpdate {
<#
.Synopsis
   Kurzbeschreibung
.DESCRIPTION
   Lange Beschreibung
.EXAMPLE
   Beispiel f�r die Verwendung dieses Cmdlets
.EXAMPLE
   Ein weiteres Beispiel f�r die Verwendung dieses Cmdlets
#>


    [CmdletBinding()]
    [Alias()]
    #[OutputType([int])]
    Param
    (
        # Reference Date from last record
        [Parameter(Mandatory=$False,
                   ValueFromPipeline=$true,
                   Position=0)]
        [ValidateScript({Test-Path $(Split-Path $_ -Parent) -PathType Container})]
        [ValidateNotNullOrEmpty()]
        [String]$PathDate = "c:\DBUpdate\DBUpdate.txt",

        # Last Change from the Database
        [datetime]$DBDate,

        #TimeSPan Property
        [Parameter(Mandatory = $True)]
        [ValidateSet("TotalMilliSeconds","TotalSeconds","TotalMinutes","TotalHours","TotalDays")]
        [ValidateNotNullOrEmpty()]
        [String]$Property = "TotalHours",

        # TimeSpan Span
        [Parameter(Mandatory = $True)]
        [ValidateScript({$_ -gt 0})]
        [ValidateNotNullOrEmpty()]
        [int16]$TimeSpan = "6"
    )

    Begin{}
    Process{
        If (!(Test-Path $PathDate)){
            $DBDate | Out-File -FilePath $PathDate
        }
        Else{#Try-Catch to insure the Content of the Datetime on the File
            $MyVar = (Get-Content $PathDate)
            $RefDate = [datetime]::Parse("$MyVar")
            IF((New-TimeSpan -Start $RefDate -End $DBDate).$Property -lt $TimeSpan){
                Write-Verbose "No Updates Available"
                Break
            }
            Else{Write-Verbose "Updates are Available"
                 $DBDate | Out-File -FilePath $PathDate
            }
        }
    }
    End{}
}#End DbUpdate

###################������������������������������������������������������������������������������##########

$Params = @{Username  = $Username
            Password  = $Password
            Server = $Server
            Database  = $Database
            Query = $SqlQuery
           }
$Datas = Invoke-SqlCommand @Params -As PSCustomObject

Check-DBUpdate -path $CheckDatePath `
               -DBDate $($Datas[0].LastUpdate) `
               -Property TotalHours -TimeSpan 6

Log "Connecting to the SQL Database ...." -Color Yellow -LogFile "$(Split-Path $CheckDatePath -Parent)\LOG.txt"

$Users = $Datas | ? {($_."E-Mail" -ne '') -and ($_."SIG_D" -ne '')}
[array]$WRONG += $Datas | ? {($_."E-Mail" -ne '') -xor ($_."SIG_D" -ne '')}
foreach ($User in $Users){
    write-verbose "Getting Users-Data from the AD-Database for: $user"
    Log "Gathering user-Properties for: ","$($user.NachName)" -Color Yellow
    TRY{ $Continue = $True
         $ADUser = ([adsisearcher]"(&(ObjectClass=user)(mail=$($user.'E-Mail')))").FindOne().GetDirectoryEntry()}
    CATCH{ Log "Error on $($user.NachName)", "Continue Set to - False" -Color Yellow -LogFile "$(Split-Path $CheckDatePath -Parent)\LOG.txt"
           $Continue = $false
           [array]$WRONG += $User}
    If($Continue){
        Write-Debug "Testing the Output of the Queried Data / Setting User Properties for: `t$($ADUser.name)"
                $Prop = @{  "mail"            = Test-Entry $ADUser."mail".ToString()
                            "employeenumber"  = Test-entry $User."personalnr".ToString()
                            "description"     = Test-entry $user."Sig_D".ToString()
                            "title"           = Test-entry $User."Sig_TItel".ToString()
                            "telephoneNumber" = Test-entry $user."Durchwahl".ToString()
                            "info"            = Test-entry $User."Sig_D2".tostring()
                            "employeeType"    = Test-entry $user."Sig_E2".tostring()
                            "personalTitle"   = Test-entry $User."Sig_E".ToString()
                            "comment"         = Test-entry $User."SIG_TITELE".ToString()
                         }
        TRY{ Write-Debug "Writing Informations to the DATABASE"
             Log "Updating Properties on - $($Aduser.name)...." -Color Yellow -LogFile "$(Split-Path $CheckDatePath -Parent)\LOG.txt"
                $Prop.GetEnumerator() |
                    % { If ($_.Value) {  Write-Debug "Updating / Adding - $($_.Key)"
                                         #$ADUSER.PSBase.InvokeSet($($_.Key),$($_.Value))
                                         $ADUser.Put($($_.Key),$($_.Value))
                                         $ADUser.Setinfo()
                                      }
                        ElseIF (($_.Value -eq $false) -or ($_.Value -eq 0)){
                                <# Const ADS_PROPERTY_CLEAR = 1
                                   Const ADS_PROPERTY_UPDATE = 2
                                   Const ADS_PROPERTY_APPEND = 3
                                   Const ADS_PROPERTY_DELETE = 4 #>

                                Write-Debug "Updating - Clearing Infos in AD"
                                $ADUser.PutEx(1,$($_.Key),0)
                                $ADUser.Setinfo()
                        }
                      }
             Log "Success !!!" -Color Yellow -LogFile "$(Split-Path $CheckDatePath -Parent)\LOG.txt"

        } CATCH{ LOG "Could not Update Any Property on - $($ADuser.Name)" -Color Yellow -LogFile "$(Split-Path $CheckDatePath -Parent)\LOG.txt"
                 [array]$WRONG += $User}
    }
    ELSE{Write-Debug "Getting Users-Data From the AD-Database Failed for: $($user.'Email')"
          [array]$WRONG += $User
    }
}
If ($WRONG){
$style = @"
<style>
body {
    color:#333333;
    font-family:Calibri,Tahoma;
    font-size: 10pt;
}
h1 {
    text-align:center;
}
h2 {
    border-top:1px solid #666666;
}
h5 {
    test-align:right
    border-top:1px solid #666666;
}
 
th {
    font-weight:bold;
    color:#eeeeee;
    background-color:#333333;
    cursor:pointer;
}
.odd { background-color:#ffffff; }
.even { background-color:#dddddd; }
.paginate_enabled_next, .paginate_enabled_previous {
    cursor:pointer;
    border:1px solid #222222;
    background-color:#dddddd;
    padding:2px;
    margin:4px;
    border-radius:2px;
}
.paginate_disabled_previous, .paginate_disabled_next {
    color:#666666;
    cursor:pointer;
    background-color:#dddddd;
    padding:2px;
    margin:4px;
    border-radius:2px;
}
.dataTables_info { margin-bottom:4px; }
.sectionheader { cursor:pointer; }
.sectionheader:hover { color:red; }
.grid { width:100% }
.red {
    color:red;
    font-weight:bold;
}
.green {
    color:green;
    font-weight:bold;
}
.Yellow {
    color:DarkOrange;
    font-weight:bold;
}
</style>
"@

        $params = @{'As'='Table';
                    'PreContent'='<h2>&diams; Bei der Unten genannten Benutzer Sind Eingabe Fehler oder Fehlende Informationen aufgetreten</h2>';
                    'EvenRowCssClass'='even';
                    'OddRowCssClass'='odd';
                    'MakeHiddenSection'=$false;                    
                    'TableCssClass'='grid';
                    'Properties'= @{n='Name' ; e={$_.nachname}},
                                  @{n='vorname' ; e={$_.Vorname}},
                                  @{n='Telefon' ; e={$_.Durchwahl}},
                                  @{n='Details' ; e={$_.'Sig_D2'} ; css={if($_.'Sig_D2'.Tostring().Length -lt 4){'red'}}},
                                  @{n='Abteilung' ; e={$_.'SIg_D'} ; css={if($_.'Sig_D2'.Tostring().Length -lt 4){'red'}}},
                                  @{n='Title1' ; e={$_.'SIG_TITEL'} ; css={if($_.'SIG_TITEL'.Tostring().Length -lt 4){'red'}}},
                                  @{n='Hr.Nummer' ; e={$_.'Personalnr'} ; css={if($_.'Personalnr'.Tostring().Length -lt 4){'red'}}},
                                  @{n='Mail' ; e={$_.'E-Mail'} ; css={if($_.'E-Mail'.Tostring().Length -lt 4){'red'}}},
                                  @{n='Title2' ; e={$_.'SIG_E'} ; css={if($_.'SIG_E'.Tostring().Length -lt 4){'red'}}},
                                  @{n='Title3' ; e={$_.'SIG_E2'} ; css={if($_.'SIG_E2'.Tostring().Length -lt 4){'red'}}}
                    
                    }
        $html_Wrong = $Wrong | ConvertTo-EnhancedHTMLFragment @params

        $params = @{'CssStyleSheet'=$style;
                    'Title'="ADNAV: medica-Medizintechnik GmbH";
                    'PreContent'="<h1>SCRIPT BERICHT: Personal- Infos (Signatur)</h1>";
                    'PostContent' = "<br/><br/><b>$($myinvocation.MyCommand.Name)</b> - <i>runned on: $($(Get-date -UFormat "%A, %d-%m-%Y / %H:%M"))" + " $(([System.TimeZone]::CurrentTimeZone).DaylightName) <br/>Credit: Gabriel Mbanda </i><hr />";
                    'HTMLFragments'=@($html_Wrong);
                    'jQueryDataTableUri'='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.min.js';
                    'jQueryUri'='http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js'}         
        $Message = ConvertTo-EnhancedHTML @params #| Out-File -FilePath "\\medica.med\administration\It\ReportTest1.html"

Log "Update failed on -","$($Wrong.count) - User" -Color Yellow -LogFile "$(Split-Path $CheckDatePath -Parent)\LOG.txt"
$MailParam = @{ From = "it-service@thera-trainer.de"
                Subject = "AdScript on svrDC03"
                Body = "$Message"
                BodyAsHTML = $True
                SmtpServer = "smtp.medica.med"
                #Credential = $Mailcred
              }
$usermail = "it-service@thera-trainer.de"
#$usermail = "gabriel.mbanda@thera-trainer.de"
Foreach ($Entry in $Usermail){
    $MailParam.to = $Entry
    Send-MailMessage @MailParam
}

    
}#End Wrong

###################������������������������������������������������������������������������������##########

# SIG # Begin signature block
# MIIJmQYJKoZIhvcNAQcCoIIJijCCCYYCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUU51y7HMvaqlRn5jLZn7jIG6z
# rlagggcAMIIG/DCCBeSgAwIBAgITFAAAAEdx1EUbJ/KLSAAAAAAARzANBgkqhkiG
# 9w0BAQUFADBLMRMwEQYKCZImiZPyLGQBGRYDbWVkMRYwFAYKCZImiZPyLGQBGRYG
# bWVkaWNhMRwwGgYDVQQDExNtZWRpY2EtU1ZSRVhDSDAxLUNBMB4XDTE2MDkwOTA1
# NDIyNloXDTE4MDkwOTA1NTIyNlowgZAxEzARBgoJkiaJk/IsZAEZFgNtZWQxFjAU
# BgoJkiaJk/IsZAEZFgZtZWRpY2ExEDAOBgNVBAsMB19NZWRpY2ExGDAWBgNVBAsM
# D19BRE1pbmlzdHJhdGlvbjEMMAoGA1UECwwDX0lUMQ4wDAYDVQQLEwVVc2VyczEX
# MBUGA1UEAxMOR2FicmllbCBNYmFuZGEwggEiMA0GCSqGSIb3DQEBAQUAA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