I've been trying to figure out a way to use Powershell to select only one file (doesn't matter which one) out of a folder so I can do a rename on it. After that I want it to just exit. Please be patient with me, I'm new to PS, most of my coding experience is in other languages.
So I've been doing something like this so it just executes once and exits...
$a = 0
DO
{
$a
$a++
} While ($a -le 0)
Would I put a Get-ChildItem in there somehow, or how do I reference the file so I can rename it to something like "newfile.txt"? Plus the file location is not local on my machine, it's on a UNC path so not sure how to point it to another location.
Thanks in advance.
Get-ChildItem filesystem::\\UNC\path\ -File | Select-Object -First 1 | Rename-Item -NewName newfile.txtGet-Help Get-ChildItem -fulland similar for all the new cmdlets you want to use. Most come with examples...