Skip to content

Instantly share code, notes, and snippets.

@DeploymentMX
Created April 21, 2020 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeploymentMX/711f3b9c363dbd0c5939a849393b8a3c to your computer and use it in GitHub Desktop.
Save DeploymentMX/711f3b9c363dbd0c5939a849393b8a3c to your computer and use it in GitHub Desktop.
#In colaboration with Damien Van R. Syst And Deploy and DeploymentMX
$Current_Folder = split-path $MyInvocation.MyCommand.Path
$SystemRoot = $env:SystemRoot
$Log_File = "C:\Windows\Debug\Install_CCM_Client.log"
Function Write_Log
{
param(
$Message_Type,
$Message
)
$MyDate = "[{0:MM/dd/yy} {0:HH:mm:ss}]" -f (Get-Date)
Add-Content $Log_File "$MyDate - $Message_Type : $Message"
}
write-host "Running ccmsetup.exe"
Write_Log -Message_Type "INFO" -Message "Running ccmsetup.exe"
Add-content $Log_File ""
$CCMSetup_Installer = "$Current_Folder\ccmsetup.exe"
Try
{
$Arguments = 'TOKEN-CMG'
# start-process -FilePath $Docker_Installer -ArgumentList "install --quiet" -Wait
start-process -FilePath $CCMSetup_Installer -ArgumentList $Arguments -Wait
Write_Log -Message_Type "SUCCESS" -Message "CCMSetup.exe has been successfully installed"
write-host "CCMSetup.exe has been successfully installed"
$CCMSetup_Status_Install = $True
}
Catch
{
Write_Log -Message_Type "ERROR" -Message "CCMSetup.exe has not been successfully installed"
write-warning "CCMSetup.exe has not been successfully installed"
$CCMSetup_Status_Install = $False
}
Add-content $Log_File ""
write-host ""
If($CCMSetup_Status_Install -eq $True)
{
Write_Log -Message_Type "INFO" -Message "Opening ccmsetup.log with CMTrace"
write-host "Opening ccmsetup.log with CMTrace"
Add-content $Log_File ""
write-host ""
$CMTRace = "$Current_Folder\cmtrace.exe"
$CCM_Log_file = "$SystemRoot\ccmsetup\Logs\ccmsetup.log"
If(test-path $CCM_Log_file)
{
Try
{
& $CMTRace $CCM_Log_file
Write_Log -Message_Type "SUCCESS" -Message "ccmsetup.log has been opened in CMTrace.exe"
write-host "ccmsetup.log has been opened in CMTrace.exe"
}
Catch
{
Write_Log -Message_Type "INFO" -Message "ccmsetup.log has not been opened in CMTrace.exe"
write-warning "ccmsetup.log has not been opened in CMTrace.exe"
}
}
Else
{
Write_Log -Message_Type "ERROR" -Message "Can not find the file $CCM_Log_file"
write-warning "Can not find the file $CCM_Log_file"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment