You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more
I asked for what I thought was a simple script.
Input = A directory name
Output = A file containing each filename in that directory with the Owner, size and date last used
Bonus points = If you can get it to do the full subdirectory structure as well
Apparently Owner is an ACL property so not as simple as the others.
Are my team missing something, surely this kind of script must exist somewhere or be relatively easy to write to run on a windows machine.
Suggestions please
$Path = "c:\test"
$LogPath = "c:\test"
$User = "Domain\user"
Get-ChildItem $Path -force -Recurse |
Select Name,Directory,Length,@{Name="Owner";Expression={(Get-ACL $_.Fullname).Owner}},@{Name="MB";Expression={$_.Length / 1MB}},CreationTime,LastAccessTime |
Where Owner -eq $User |
Export-Csv $LogPath\FileFolderOwner.csv -NoTypeInformation
Internet provided. May or may not work.
^^ that works with a couple of tweaks. The quote marks are busted (probably forum formatting) and you're filtering by a specific owner which isn't required.
Here. Obviously, you'll need to change the pathnames.
$Path = "C:\test"
$LogPath = "C:\test"
Get-ChildItem $Path -force -Recurse |
Select Name,Directory,Length,@{Name="Owner";Expression={(Get-ACL $_.Fullname).Owner}},@{Name="MB";Expression={$_.Length / 1MB}},CreationTime,LastAccessTime |
Export-Csv $LogPath\FileFolderOwner.csv -NoTypeInformation
dir /s /q /ta >output_file_name.log
Edit: stick it in a "x.bat" file, and pass %1 just after the dir as an argument:
dir %1 /s /q /ta >output_file_name.log
Oh yeah,
Are you comfortable running PowerShell scripts or do you need guidance here?
Are my team missing something, surely this kind of script must exist somewhere or be relatively easy to write to run on a windows machine.
I'm guessing your team are all under 30 and have never used the command line... I fire it up every now and then on video calls just to scare them 😀
Are you comfortable running PowerShell scripts or do you need guidance here?
My effort runs in a normal CMD (dos) shell.
dir /s /q /ta >output_file_name.log
That'll show you the Last Accessed user, not the file owner?
If you want to do it in CMD it's probably a job for wmic.
That’ll show you the Last Accessed user, not the file owner?
The q switch is the owner.
The q switch is the owner.
Well bugger me, I missed that. Nice.
We use TreeSize for this sort of thing - much better than a script
We use TreeSize for this sort of thing – much better than a script
Dunno, I'm a big fan of quick and dirty scripts. If I use them more than once I stick them in a directory that on my custom path, after a while I've built up a small library of simple utilities that I use all the time. But yeah, anything more complex and they do soon show their limits.
I've mean meaning to learn Powershell for ages, but as I don't have admin rights on my work machine there's not much point - all the interesting extra bits of funcionality aren't available.
Thanks all - team happy and now focussed on service account and security challenges. None of them thought about the command line options. Kids today huh?
I’ve mean meaning to learn Powershell for ages
As have I. I know the basics but (ironically here as I missed it completely) not to anything like the degree that I know command line.
doesn't format:C work any more ?
😉
doesn’t format:C work any more ?
Never did, it's format c: 🙂
Didn't want to type the real thing in case there was an accident of some global standing 😀