Francois

//Francois
Francois

Forum Replies Created

Viewing 8 posts - 76 through 83 (of 83 total)
  • Author
    Posts
  • Francois
    Participant
    Post count: 101

    Hi,

    Seems this is working with write-log.

    <code>
    #Region 5.0 Get-MonitorInfo
    Function Get-MonitorInfo
    {
        [CmdletBinding()]
        Param
        (
            [Parameter(
            Position=0,
            ValueFromPipeLine=$true,
            ValueFromPipeLineByPropertyName=$true)]
            [string]$name = '.'
        )
        Begin { 
    
    		## Get the name of this function and write header
    		[string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
    		Set-StrictMode -off
    			Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
    		Set-StrictMode -Version Latest
    
    	 }## End Begin Script Block 
     
        Process
        {
     
            [PSObject]$MonitorData= gwmi WmiMonitorID -Namespace root\wmi | &lt>

    Select @{n=”Model”;e={[System.Text.Encoding]::ASCII.GetString($_.UserFriendlyName -ne 00)}}, `
    @{n=”Serial Number”;e={[System.Text.Encoding]::ASCII.GetString($_.SerialNumberID -ne 00)}}

    $StrMonitorData = $MonitorData | Out-String

    Set-StrictMode -off
    Write-Log -Message “Information sur les écrans: $($StrMonitorData)” -Source ${CmdletName}
    Set-StrictMode -Version Latest

    Write-Output $StrMonitorData
    }
    End {

    Set-StrictMode -off
    Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
    Set-StrictMode -Version Latest

    }## End End
    }

    #************************************************************************************************************
    #EndRegion 5.0 Get-MonitorInfo
    #************************************************************************************************************
    $insttrousses=”c:\temp”
    [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
    [string]$moduleAppDeployToolkitMain = “$scriptDirectory\_Include\AppDeployToolkit\AppDeployToolkitMain.ps1″
    If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw ‘Le module n existe pas à l”endroit spécifié: [$moduleAppDeployToolkitMain].’ }
    Set-StrictMode -off
    #Ce module n’a pas été conçu pour fonctionner avec set-strictmode, il doit être exécuté avec des privilège élevé.
    #https://psappdeploytoolkit.codeplex.com/
    . $moduleAppDeployToolkitMain
    Set-StrictMode -Version Latest

    Get-MonitorInfo
    `
    ;/code

    • This reply was modified 2 years ago by  Francois.
  • Francois
    Participant
    Post count: 101

    Hi,

    I just made a test script with lesser script line and the problem is still appearing.
    Easy to reproduce:

    <code>
    #Region 5.0 Get-MonitorInfo
    Function Get-MonitorInfo
    {
        [CmdletBinding()]
        Param
        (
            [Parameter(
            Position=0,
            ValueFromPipeLine=$true,
            ValueFromPipeLineByPropertyName=$true)]
            [string]$name = &#039;.&#039;
        )
        Begin { 
    
    		## Get the name of this function and write header
    		[string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
    		Set-StrictMode -off
    			#Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
    		Set-StrictMode -Version Latest
    
    	 }## End Begin Script Block 
     
        Process
        {
     
            $ActiveMonitors = Get-WmiObject -Namespace root\wmi -Class wmiMonitorID -ComputerName $name
            $monitorInfo = @()
     
            foreach ($monitor in $ActiveMonitors)
            {
                $mon = New-Object PSObject
                $manufacturer = $null
                $product = $null
                $serial = $null
                $name = $null
                $week = $null
                $year = $null
     
                $monitor.ManufacturerName | foreach {$manufacturer += [char]$_}
                $monitor.ProductCodeID | foreach {$product += [char]$_}
                $monitor.SerialNumberID | foreach {$serial += [char]$_}
                $monitor.UserFriendlyName | foreach {$name += [char]$_}
     
                $mon | Add-Member NoteProperty Manufacturer $manufacturer
                $mon | Add-Member NoteProperty ProductCode $product
                $mon | Add-Member NoteProperty SerialNumber $serial
                $mon | Add-Member NoteProperty Name $name
                $mon | Add-Member NoteProperty Week $monitor.WeekOfManufacture
                $mon | Add-Member NoteProperty Year $monitor.YearOfManufacture
     
                $monitorInfo += $mon
            }
                    
    		[string]$StrMonitorData=$monitorInfo | Format-List | Out-String
    		Set-StrictMode -off
            	Write-Log -Message &amp;quot;Ecran: </code>

    n$($StrMonitorData)” -Source ${CmdletName}
    Set-StrictMode -Version Latest

    #Write-Log -Message $StrMonitorData -Source ${CmdletName}
    #Write-Output $StrMonitorData
    }
    End {

    Set-StrictMode -off
    #Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
    Set-StrictMode -Version Latest

    }## End End
    }

    #************************************************************************************************************
    #EndRegion 5.0 Get-MonitorInfo
    #************************************************************************************************************
    [string]$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
    [string]$moduleAppDeployToolkitMain = “$scriptDirectory\_Include\AppDeployToolkit\AppDeployToolkitMain.ps1″
    If (-not (Test-Path -Path $moduleAppDeployToolkitMain -PathType Leaf)) { Throw ‘Le module n existe pas à l”endroit spécifié: [$moduleAppDeployToolkitMain].’ }
    . $moduleAppDeployToolkitMain

    Get-MonitorInfo

    `

    • This reply was modified 2 years ago by  Francois.
  • Francois
    Participant
    Post count: 101

    I am running CMTrace 5.0.7804-1000 (32-bit). No the problem is still there.

    <code>
    [string]$StrMonitorData=$monitorInfo | Format-List | Out-String
    Write-Log -Message &amp;quot;Ecran: </code>

    n$($StrMonitorData)” -Source ${CmdletName}

    `

    In CMTrace it did not show up.
    With Notepad, I get:

    ]LOG]!><time=”14:39:30.046-300″ date=”11-13-2015″ component=”Get-PendingReboot” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: Période d’allumage: 0 jours 6 heures 16 minutes]LOG]!><time=”14:39:30.093-300″ date=”11-13-2015″ component=”” context=”xxx\xxx” type=”1″ thread=”3000″ file=””>
    <![LOG[[Installation] :: Ecran:

    Manufacturer : DEL
    ProductCode : A07E
    SerialNumber : xxx
    Name : DELL P2212H
    Week : 47
    Year : 2013

    Manufacturer : DEL
    ProductCode : A098
    SerialNumber : xxx
    Name : DELL P2214H
    Week : 28
    Year : 2015

    ]LOG]!><time=”14:39:30.155-300″ date=”11-13-2015″ component=”Get-MonitorInfo” context=”xxx\xxx” type=”1″ thread=”3000″ file=””>
    <![LOG[[Installation] :: ************************************************************************************************************]LOG]!><time=”14:39:30.155-300″ date=”11-13-2015″ component=”” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: Fin du traitement]LOG]!><time=”14:39:30.155-300″ date=”11-13-2015″ component=”” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: ************************************************************************************************************]LOG]!><time=”14:39:30.171-300″ date=”11-13-2015″ component=”” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: ============================================ Fin Script====================================]LOG]!><time=”14:39:30.171-300″ date=”11-13-2015″ component=”” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: CARRA_Info_Depannage_1.0_Fr_v1 Installation completed with exit code [0].]LOG]!><time=”14:39:30.186-300″ date=”11-13-2015″ component=”Exit-Script” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: ——————————————————————————-]LOG]!><time=”14:39:30.202-300″ date=”11-13-2015″ component=”Exit-Script” context=”xxx\xxx” type=”1″ thread=”3000″ file=”Info_Depannage1.0_Frv1.ps1″>

    If manually I am removing a line at the end of that list or between both monitor then I will be correct in CMTrace.

    • This reply was modified 2 years ago by  Francois.
  • Francois
    Participant
    Post count: 101

    Seems Write-log does love the empty line between monitors.

    Manufacturer : DEL
    ProductCode : A07E
    SerialNumber : xxx
    Name : DELL P2212H
    Week : 47
    Year : 2013

    Manufacturer : DEL
    ProductCode : A098
    SerialNumber : xxx
    Name : DELL P2214H
    Week : 28
    Year : 2015

    If I remove it manually or put === then everything is fine. Any idea how making write-log accepting it or replacing the empty line with === ?

  • Francois
    Participant
    Post count: 101

    Possibly the array cannot be directly pipe (even with | out-string) to the log. Any idea?

  • Francois
    Participant
    Post count: 101

    Hi,

    🙁 Seems not.

    <code>
    Function Get-MonitorInfo
    {
        [CmdletBinding()]
        Param
        (
            [Parameter(
            Position=0,
            ValueFromPipeLine=$true,
            ValueFromPipeLineByPropertyName=$true)]
            [string]$name = &#039;.&#039;
        )
        Begin { 
    
    		## Get the name of this function and write header
    		[string]${CmdletName} = $PSCmdlet.MyInvocation.MyCommand.Name
    		Set-StrictMode -off
    			#Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -CmdletBoundParameters $PSBoundParameters -Header
    		Set-StrictMode -Version Latest
    
    	 }## End Begin Script Block 
     
        Process
        {
     
            $ActiveMonitors = Get-WmiObject -Namespace root\wmi -Class wmiMonitorID -ComputerName $name
            $monitorInfo = @()
     
            foreach ($monitor in $ActiveMonitors)
            {
                $mon = New-Object PSObject
                $manufacturer = $null
                $product = $null
                $serial = $null
                $name = $null
                $week = $null
                $year = $null
     
                $monitor.ManufacturerName | foreach {$manufacturer += [char]$_}
                $monitor.ProductCodeID | foreach {$product += [char]$_}
                $monitor.SerialNumberID | foreach {$serial += [char]$_}
                $monitor.UserFriendlyName | foreach {$name += [char]$_}
     
                $mon | Add-Member NoteProperty Manufacturer $manufacturer
                $mon | Add-Member NoteProperty ProductCode $product
                $mon | Add-Member NoteProperty SerialNumber $serial
                $mon | Add-Member NoteProperty Name $name
                $mon | Add-Member NoteProperty Week $monitor.WeekOfManufacture
                $mon | Add-Member NoteProperty Year $monitor.YearOfManufacture
     
                $monitorInfo += $mon
            }
            #$monitorInfo
            [string]$StrMonitorData=$monitorInfo | Out-String
            Write-Log -Message $StrMonitorData -Source ${CmdletName}
    		Write-Output $StrMonitorData
        }
        End { 
    
    		Set-StrictMode -off
    			#Write-FunctionHeaderOrFooter -CmdletName ${CmdletName} -Footer
    		Set-StrictMode -Version Latest
    
    	}## End End 
    }
    </code>
    <code>
    $StrMonitorData=Get-MonitorInfo
    
    Write-Log &#039;************************************************************************************************************&#039;
    	Write-Log &#039;Fin du traitement&#039;
    	Write-Log &#039;************************************************************************************************************&#039;
    	Write-Log &#039;============================================ Fin Script====================================&#039; -LogFilename $VarJournalisation
    	Exit-Script -ExitCode 0
    </code>

    In CMTRace, I get nothing but with Notepad, I will get:

    <![LOG[[Installation] ::

    Manufacturer : DEL
    ProductCode : A07E
    SerialNumber : xxx
    Name : DELL P2212H
    Week : 47
    Year : 2013

    Manufacturer : DEL
    ProductCode : A098
    SerialNumber : xxx
    Name : DELL P2214H
    Week : 28
    Year : 2015

    ]LOG]!><time=”11:09:13.958-300″ date=”11-13-2015″ component=”Get-MonitorInfo” context=”xxx” type=”1″ thread=”7044″ file=””>
    <![LOG[[Installation] :: ************************************************************************************************************]LOG]!><time=”11:09:13.974-300″ date=”11-13-2015″ component=”” context=”xxx” type=”1″ thread=”7044″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: Fin du traitement]LOG]!><time=”11:09:13.974-300″ date=”11-13-2015″ component=”” context=”xxx” type=”1″ thread=”7044″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: ************************************************************************************************************]LOG]!><time=”11:09:13.989-300″ date=”11-13-2015″ component=”” context=”xxx” type=”1″ thread=”7044″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: ============================================ Fin Script====================================]LOG]!><time=”11:09:13.989-300″ date=”11-13-2015″ component=”” context=”xxx” type=”1″ thread=”7044″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: xxx_Info_Depannage_1.0_Fr_v1 Installation completed with exit code [0].]LOG]!><time=”11:09:14.005-300″ date=”11-13-2015″ component=”Exit-Script” context=”xxx” type=”1″ thread=”7044″ file=”Info_Depannage1.0_Frv1.ps1″>
    <![LOG[[Installation] :: ——————————————————————————-]LOG]!><time=”11:09:14.020-300″ date=”11-13-2015″ component=”Exit-Script” context=”xxx” type=”1″ thread=”7044″ file=”Info_Depannage1.0_Frv1.ps1″>

    • This reply was modified 2 years ago by  Francois.
  • Francois
    Participant
    Post count: 101

    I would like uploading the CMTrace log but I can’t find how. Any help would be appreciate. I don’t have access to cloud.

  • Francois
    Participant
    Post count: 101

    Hi,

    I would answer why using deploy-applications? Just create your own script.

    Thanks,

Viewing 8 posts - 76 through 83 (of 83 total)