FeaturedPower ShellSCCMScripts

Copy Logs

This is my new script which wrote to copy logs to a shared location. We recently started to upgrade user devices and some failed.

To make it easy for helpdesk, i created this script they can run after failure so i could get what happened with upgrade.


   Copy sccm logs from your computer and save it a shared location
   This script help you copy logs when TS or any pacakge installation fails. 
   you can copy different logs like 'smsts.log','policyagent.log' ... etc just mentiong the log name
   .\Copy_log_V2  get-log -log smsts.log 
   get-log -log smsts.log 

     get-log -log smsts.log -path c:\windows\ccm\logs -destination \\server-path\logfolder

   By Hashmat Mohammadi
function get-log
        # Param1 help description

        [string]$log = 'smsts*.log',
        [string]$destination = '\\server.domain.local\osd\Logs\',
        [string]$path = 'c:\windows\ccm\logs',
        [string]$computername = $env:computername

        #get default Policy
        $policy = Get-ExecutionPolicy
        #chagne execution policy to remotesidned
        Set-ExecutionPolicy bypass -Force

        #create colder on destination
        $folder = New-Item -path $destination -name $computername -ItemType directory -Force
        #Copy the logs to the Destination folder
        copy-item -Path $path\$log -destination $folder -Recurse

        #set policy to default policy 
         Set-ExecutionPolicy $policy -Force


Show More

Related Articles

Back to top button