PowerShell for Windows Admins:

File System


April 2, 2014  11:43 AM

CIM snippets–working with file system



Posted by: Richard Siddaway
CIM, File System, PowerShell 3, PowerShell v4, WMI

The latest instalment from the WMI team on using PowerShell and the CIM cmdlets is available -

Bookmark and Share     0 Comments     RSS Feed     Email a friend

February 28, 2014  2:33 PM

Automatically create folder for home drive



Posted by: Richard Siddaway
Active Directory, File System

In this post 

Bookmark and Share     0 Comments     RSS Feed     Email a friend


July 7, 2013  1:01 PM

Deleting a file with WMI



Posted by: Richard Siddaway
File System, PowerShell 3, WMI

Following on from the last post this is how you can delete a file. Use the same file structure as previously This time you need to use the CIM_DataFile class. It’s one of the few classes I’ve found that doesn’t have a Win32_ equivalent. The class has a Delete method. Assuming you...


July 7, 2013  12:41 PM

Deleting Folders with WMI



Posted by: Richard Siddaway
File System, PowerShell 3, WMI

I recently saw a question about deleting folders with WMI. Let’s create a file structure we’re happy to delete New-Item -Path c:\ -Name Expendable -ItemType Directory New-Item -Path c:\Expendable -Name Target1 -ItemType Directory New-Item -Path c:\Expendable -Name Target2 -ItemType...


June 24, 2013  12:04 PM

Touching files



Posted by: Richard Siddaway
File System, PowerShell

Unix has a command called touch that allows you to set the access time on a file. PowerShell doesn’t have a direct equivalent but it is very easy to perform the same task: $date = (Get-Date).AddMonths(-2) Get-ChildItem -Path C:\Teszzt2 -Filter f*.txt | Set-ItemProperty -Name LastWriteTime...


June 8, 2012  7:53 AM

Cleaning up the temp folder



Posted by: Richard Siddaway
File System, PowerShell 3

 

This post

Bookmark and Share     0 Comments     RSS Feed     Email a friend


March 21, 2012  3:14 PM

Folder sizes



Posted by: Richard Siddaway
File System

Question on the forums related to folder sizes and last write time

Get-ChildItem -Path "C:\PersonalData\MyBooks\PowerShell and WMI" 
				
								
				 

				Bookmark and Share

				   

				 0 Comments
				   

				  RSS Feed
				   

				  Email a friend

			
			
			


February 18, 2012  2:05 PM

Count of files in a folder



Posted by: Richard Siddaway
File System, PowerShell

I was recently left a comment of a post

Bookmark and Share     0 Comments     RSS Feed     Email a friend


February 11, 2012  5:53 AM

Changing folder creation date



Posted by: Richard Siddaway
File System, PowerShell

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 -Value...


September 12, 2010  5:52 AM

Deleting files older than a certain date



Posted by: Richard Siddaway
File System, PowerShell v2

A question on the ITKE forums asked how files older than a certain date (in this case two months) could be deleted without touching younger files.

  Bookmark and Share     0 Comments     RSS Feed     Email a friend


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: