Category Archives: File system

Unblocking Files with PowerShell v3

There are a number of new features in PowerShell v3 that while not huge like CIM or workflow are os significant help to the hard pressed administrator.  One of these is the Unblock-File cmdlet. If you haven’t updated your help … Continue reading

Posted in File system, PowerShell V3 | 1 Comment

Folder sizes

Question on the forums related to folder sizes and last write time Get-ChildItem -Path “C:\PersonalData\MyBooks\PowerShell and WMI” -Recurse | where { $_.PSIsContainer} | foreach { $size = Get-ChildItem -Path $_.FullName | measure -Sum Length | select -ExpandProperty Sum Add-Member -InputObject … Continue reading

Posted in File system | Leave a comment

Count of files in a folder

I was recently left a comment of a post http://richardspowershellblog.wordpress.com/2009/11/30/updating-access-data/ asking about the how to get the count of files in a folder There are a number of solutions including dropping back to the FileSystem object from VBscript If we … Continue reading

Posted in File system, Powershell Basics | Leave a comment

Changing folder creation date

A question on the forum asked about setting creation date on folders after they have been copied to match the source folder. I created a source folder with three folders and modified the creation dates Set-ItemProperty -Path c:\testsource\folder1 -Name CreationTime … Continue reading

Posted in File system, Powershell Basics | Leave a comment

Folder information on remote machines

A question in the forums wanted to get the date a folder was changed on their domain controllers. This is one way to do it $folder = “Common Files” [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() | select -ExpandProperty DomainControllers | foreach { $dc = $_.Name … Continue reading

Posted in File system, Powershell Basics | Leave a comment

Formatting file listings–the other way

Following on from the previous post I was asked if the bit where we set the case on the file names and extension could be done in a select statement. Simple answer is yes Get-ChildItem | where {-not $_.PSIsContainer} | … Continue reading

Posted in File system, Powershell Basics | Leave a comment

Formatting file listings

A question was left asking about displaying a file listing with the full name in upper case and the extension in lower case. Its one line of PowerShell Get-ChildItem | where {-not $_.PSIsContainer} | sort Fullname | Format-Table @{N=”FullName”; E={$($_.Fullname.ToUpper())}}, … Continue reading

Posted in File system, Powershell Basics | 2 Comments

Split-Path & UNC

split-path works with with UNC paths as well as normal paths   PS> $path = “\\UNCserver\TFSBuilds\componenet\v11.1\XS11.1\XS11.1_11.1.0.35“PS> Split-Path -Path $path -Parent\\UNCserver\TFSBuilds\componenet\v11.1\XS11.1   PS> Split-Path -Path (get-location) -ParentC:\scripts

Posted in File system | Leave a comment

Removing empty folders

Removing empty folders seems to be a question that crops up on a regular basis. The problem is determining if a folder is empty: it could have subfolders it could have zero length files Both of these cases would register … Continue reading

Posted in File system | 1 Comment

Folder and file names

Saw a question in the forums – running Get-ChildItem and wanted the folder containing the file.  Could split PSParent and pick the last element or can use a calculated field Get-ChildItem -Path c:\test -Recurse | select FullName, @{N=”Folder”; E={Split-Path -Path … Continue reading

Posted in File system | 1 Comment