Where are you creating the key on a remote computer? Is this wrapped in an Invoke-Command script block or something? Looking at the code you posted, it would attempt to write the registry key to the local computer, which may very well be the cause of your access denied errors. My apologies if...
Something like this might get you heading in the right direction at least:
$myDirectory = "C:\Temp"
$myFiles = Get-ChildItem $myDirectory -Recurse -File
$myFiles | Group-Object Directory | foreach {
$_.Group | sort LastWriteTime | select -Last 1 Directory,Name,LastWriteTime
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.