

Write-Verbose $SamAccountName "found on multiple PC's" $Computers ', selecting first to remote' -ForegroundColor Yellow Write-Verbose $SamAccountName 'found on PC' $Computers. $Test = Test-Connection -ComputerName $Account -Count 2 Write-Verbose 'Testing connection(s).' -ForegroundColor Cyan $Computers = Get-WmiObject -namespace $SCCMNameSpace -computer $SCCMServer -query "select Name from sms_r_system where LastLogonUserName='$SamAccountName'" | select Name $SCCMNameSpace = "root\sms\site_$SiteName" $SCCMRemoteExe = 'C:\Safe\SCCM Remote\CmRcViewer.exe' If ( Test-Path -Path $LogFile -ea Silentl圜ontinue ) #Log File doesn't existĪdd-Content -Path $LogFile -Value "$Message"Īdd-Content -Path $LogFile -Value "$Message" -Force Write-EventLog -LogName Application -Source $ScriptSource -EventID 9999 -EntryType Error -Message "Please provide log file to script if you would like it to write to the file" Write-EventLog -LogName Application -Source $ScriptSource -EventID $EventNumber -EntryType $Type -Message $Message Length -eq 0 ) -or ( $LogFile -eq $NULL ) ) #File not provided $Type = "Warning" #Don't think it's appropriate to ask for a corrected response so this will cause somebody to scratch there head and review code.most likely

If ( ( $Type -notcontains "Error" ) -and ( $Type -notcontains "Warning" ) -and ( $Type -notcontains "Information" ) ) #Error Checking on $Type allowed values are Error, Warning, Information, SuccessAudit, FailureAudit $Date = Get-Date -Format u #UniversalSortableDateTimePattern using the format for universal time display New-EventLog -Source $ScriptSource -LogName Application -ea Silentl圜ontinue #Need to run the following with Admin rights if you want to create the Windows Event Log
