Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

how to get a content of a file to event log

$
0
0

I have got PS script to get the Regkey count to a text file. I am using this script in Task Scheduler & Can you please let me know if we can get the content of that file and have that logged to event viewer once the task is ran? Script is mentioned below -

if (!([diagnostics.process]::GetCurrentProcess().Path -match'\\syswow64\\'))

{

$uninstallPath = "\Software\Microsoft\Windows\CurrentVersion\Uninstall\"

$uninstallWow6432Path ="\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"

@(

if (Test-Path "HKLM:$uninstallWow6432Path" ) {Get-ChildItem "HKLM:$uninstallWow6432Path"-Recurse | Measure-Object | Out-File "C:\PS Output\Total6432.txt"}

if (Test-Path "HKLM:$uninstallpath" ) {Get-ChildItem "HKLM:$UninstallPath" -Recurse | Measure-Object | Out-File "C:\PS Output\Total32.txt"}

)

}


Viewing all articles
Browse latest Browse all 8583

Trending Articles