Francois

//Francois
Francois

Forum Replies Created

Viewing 12 posts - 76 through 87 (of 87 total)
  • Author
    Posts
  • Francois
    Participant
    Post count: 105

    Hi,

    The downside of reg.exe or regedit is the UAC. When we are running regedit or reg there is a command window appearing and it takes a time before running. It will but it takes time. So there is a possibility a user would just close the window.

    Yes, I know Active setup. Personnally, I believe all whose scenarios are usefull.

    1. When configuring a new computer Invoke-HKCURegistrySettingsForAllUsers will make ready a computer for everyone for HKCU.
    2. Set-RegistryKey is good for new computers and for change during software installation
    3. Set-ActiveSetup is usefull to configure diverses user components. But the UAC might be a problem while changing HKCU with reg.exe or regedit as it might takes time. Is it a way to make it run minimize or hidden?

    Thanks,

    • This reply was modified 2 years, 1 month ago by  Francois.
  • Francois
    Participant
    Post count: 105

    Hi,

    So:
    Set-RegistryKey–> Set registry but not from a reg file.
    Set-ActiveSetup–> To use a .reg file and then set on HKCU from active setup
    Invoke-HKCURegistrySettingsForAllUsers –> To set HKCU from HKU hive and will set default user as already create user and future user. But does not support .reg file. This one would be insteresting by just reading . reg file and set the value.

    Thanks,

    François

  • Francois
    Participant
    Post count: 105

    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, 10 months ago by  Francois.
  • Francois
    Participant
    Post count: 105

    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, 10 months ago by  Francois.
  • Francois
    Participant
    Post count: 105

    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, 10 months ago by  Francois.
  • Francois
    Participant
    Post count: 105

    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: 105

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

  • Francois
    Participant
    Post count: 105

    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, 10 months ago by  Francois.
  • Francois
    Participant
    Post count: 105

    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: 105

    Hi,

    With Active Setup it will work… but a window is appearing and after a time the job will be done but before that, if you click on the Window, the prompt will appear.

    Wise? Who is still using Wise? 🙂

    Thanks,

  • Francois
    Participant
    Post count: 105

    Hi,

    With regedit /s …reg there is an annoying window from the Windows security will set-activesetup doing better?

    Thanks,

  • Francois
    Participant
    Post count: 105

    Hi,

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

    Thanks,

Viewing 12 posts - 76 through 87 (of 87 total)