Category Archives: File system

File times

There are three pairs of file times that are available on files on Windows PS> Get-ChildItem -Path C:\test\Newoutdata01.txt | select *time* CreationTime      : 14/04/2019 17:28:41 CreationTimeUtc   : 14/04/2019 16:28:41 LastAccessTime    : 14/04/2019 17:28:41 LastAccessTimeUtc : 14/04/2019 16:28:41 LastWriteTime     : 25/02/2019 … Continue reading

Posted in File system, Powershell | Leave a comment

Long file paths

Long file paths – greater than 260 characters – have been a pain to deal with in Windows. There is an argument that you should avoid file paths of that length but sometimes you don’t have any choice – when … Continue reading

Posted in File system, PowerShell v5 | 1 Comment

Splitting paths

PowerShell has the Split-Path cmdlet that provides the leaf and parent of a path. But what if you’re splitting paths and need one or paths at a higher level. Consider the path PS> $path = ‘C:\Scripts\HyperV\Admin\Optimize-VMDisks.ps1’ Its just an arbitrary … Continue reading

Posted in File system, Powershell | Leave a comment

Get Folder sizes

One problem that comes up quite often is how do you get folder sizes. One option is use Measure-Object but the problem with that approach is that its going to be a pretty slow process if you have a lot … Continue reading

Posted in File system, Powershell | 2 Comments

Blocksize missing?

I recently had a question asking why the Bloacksize property on Win32_LogicalDisk is empty but is populated on Win32_Volume. The thing is to remember the underlying thing that these 2 CIM classes represent. A logical disk is a subdivision of … Continue reading

Posted in CIM, File system | Leave a comment

Copy a file with WMI

A question came up on the forum about copying files with CIM (WMI). I normally use Copy-Item rather than CIM as its easier. The questioner was using CIM_LogicalFile when I’ve normally used CIM_DataFile so I decided to take a look … Continue reading

Posted in CIM, File system, PowerShell and WMI | Leave a comment

Awkward file and folder names

Spent some time today dealing with a situation where there were special characters – namely [ ] in folder a file names £> Get-ChildItem -Path C:\Test     Directory: C:\Test Mode                LastWriteTime     Length Name—-                ————-     —— —-d—-        21/01/2015     17:58            Awkward [One]d—-        … Continue reading

Posted in File system, Powershell Basics | Leave a comment

Finding a file version

Interesting question on the forum – how to find the file version of IE on remote machines? Get-CimInstance -ClassName CIM_DataFile -Filter “Name = ‘C:\\Program Files\\Internet Explorer\\iexplore.exe’”  | select -ExpandProperty Version Use the CIM_dataFile class.  Its one of the few CIM_ … Continue reading

Posted in File system, PowerShell and WMI | Leave a comment

File system ACLS – inheritance

  When you look at a FileSystemAccessRule it’llbe something like this: FileSystemRights  : Modify, SynchronizeAccessControlType : AllowIdentityReference : NT AUTHORITY\Authenticated UsersIsInherited       : TrueInheritanceFlags  : NonePropagationFlags  : None So far we haven’t dealt with the three inheritance flags. Isinherited indicates that … Continue reading

Posted in File system, Powershell | Leave a comment

File system ACLs–function to add ACL

I thought that today I’d start putting together a function to add an ACL to a file system object. The starting point is the code that stepped through the process in an earlier post: http://msmvps.com/blogs/richardsiddaway/archive/2014/05/26/file-system-acls-creating-an-acl.aspx function add-acl {[CmdletBinding()]param ( [Parameter(Mandatory=$true)] … Continue reading

Posted in File system, Powershell | Leave a comment