Cmrcviewer logging with powershell

 

 

A while back a user on reddit in the/R/SCCM section asked a question regarding Cmrcviewer.exe and if it was possible to see the history of the connections you had made since the user always forgot to write down which IP or Computer name he was connecting to. You can find the post here tho the users question has been deleted, the answers are still there. The user also wanted it to be persistent so he didn’t had to open a new powershell session every time so thanks to /U/BIGINIME for answering that.

 

A simple solution i came up with for solving this problem was to write a powershell script that launched Cmrcviewer.exe and which also created a .log file with Date/Time and computer name for each connection.

 

The Script

 

While (1 -eq 1)
{

$Computername = read-host "Enter Computer name"
$logpath = "C:\cmrcviewer.log"
$CmRcViewer = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\i386\CmRcViewer.exe"  

if ($Computername -ne $Null) 
{ 
    & $CmRcViewer $Computername $date = Get-Date Out-File -FilePath $logpath -InputObject "$date - $Computername" -Append 
}   
} 

The only changes you need to do is to the 2 variables $logpath if you want another path and to $Cmrcviewer where you need to specify where the Cmrcviewer.exe is located.

 

Process

 

First of all save the powershell script to a .ps1 file and start with right clicking on it and choose “Run with powershell”

 

3

 

Enter computer name or IP to which computer you want to connect to in to the powershell window and press enter

 

4

 

From there cmrcviewer.exe will start and the log file will update

5

6

 

Until next time, cheers Timmy !

 

You can find me over at

[twitter-follow screen_name=’Timmyitdotcom’]

 

 

4 comments

  1. Thank you for the post. I am trying to follow and created the following project:
    $logpath = “c:windowsTempcmrcviewer.log”

    $frmCmrcviewer_Load={
    #TODO: Initialize Form Controls here

    }

    $textbox1_TextChanged={
    #TODO: Place custom script here

    }

    $btnConnect_Click={
    #TODO: Place custom script here
    if (not $textbox1.Text)
    {
    [Systems.Windows.Forms.Messages]::Show(‘No computer specified’, ‘Error’)
    Throw ‘No COmputer specified’
    }
    else
    {
    $computername = $textbox1.Text
    $date = Get-Date
    $CmRcViewer = “C:Program Files (x86)Microsoft Configuration ManagerAdminConsolebini386CmRcViewer.exe”
    & $CmRcViewer $computername
    Out-File -FilePath -InputObject “$date – $computername” -Append
    }
    }

    $buttonHistory_Click={
    #TODO: Place custom script here
    Invoke-Item $logpath
    }

    However when i click on the exe, none of the buttons are generating anything?

    I am also not able to connect manually, but why should it stop from creating a log file?

    1. Sounds like the variables for the buttons are wrong, probably wrong name or something like that. i would start looking at that

Leave a Reply