PSFSTools

PSFSTools is:

Simple file server tools for complex task.

A powershell module

PSFSTools is a powershell module. Download and copying it under %Windir%\System32\WindowsPowerShell\v1.0\Modules for all users or under %UserProfile%\Documents\WindowsPowerShell\Modules for the current user or install through PowershellGallery.

ATTENTION: This module is not signed. Before import or execute cmdlet on this module, see about_signing session. Verify execution of scripts is allowed with Get-ExecutionPolicy (should be RemoteSigned or Unrestricted). If scripts are not enabled, run PowerShell as Administrator and call Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm.

You can also install it via git:

git clone https://github.com/MatteoGuadrini/PSFSTools.git
cd PSFSTools
copy /Y PSFSTools %Windir%\System32\WindowsPowerShell\v1.0\Modules

A collection of tool

Various task on a file server, require execution complexity; how and when to archive, create folders assigned to certain groups or delete files older than one month or delete folders that are no longer used.

This module, with

Tools:

For more module info, run:

Get-Help about_psfstools

New-ProjectFolder

Creates a project folder and assign ACL with three Active Directory groups: Owner, Writer, Reader. For example:

New-ProjectFolder -Name Test -LitheralPath C:\Project -Permission Owner,Writer,Reader -OU "OU=Test,DC=Test,DC=local"

The name of directory is Test and your path is C:\Project\Test. This cmdlet, creates a three Active Directory security group:

And apply these on path with permission in brackets. For more info, run:

Get-Help New-ProjectFolder -Full

Remove-OlderThan

Removes files and folders older than days. In addition, also deletes empty folders. For example:

Remove-OlderThan -Path C:\Temp -Days 15 -Recurse

Delete file and empty folder in C:\Temp, if creation date is older than 15 days. For more info, run:

Get-Help Remove-OlderThan -Full

Backup-ArchiveFiles

Archive files older than a number of years. For example:

Backup-ArchivedFiles -Path C:\Temp -Years 2 -ArchivePath D:\Temp -Exclude C:\Temp\Docs,"C:\Temp\Docs two" -AllFiles

Looking for file with Access Date older than two years into path C:\Temp; the destination path is D:\Temp. With Exclude option you can skip file in specified paths. Flag AllFiles means than all files in a folder must be older than two years. This cmdlet performing a move. For more info, run:

Get-Help Backup-ArchiveFiles -Full

File server topology configuration

To create and maintain a file server topology, use the following commands.

New-TemplateFileServer

With this command you can create an example topology file of a file server.

New-TemplateFileServer -Path C:\Temp\fs1.xml

Change the topology according to your needs.

Write-FileServerFromTemplate

Applying topology means creating folders and assigning them permissions, specified in the topology template file. To apply it, run this command:

Write-FileServerFromTemplate -Template C:\Temp\fs1.xml -RootPath D:\FS

Applying the command a second time, the new folders in the topology will be created, while the existing ones will be ignored. All permissions will be overwritten, if -Force parameter is specified.

For more info, run:

Get-Help New-TemplateFileServer -Full
Get-Help Write-FileServerFromTemplate -Full

Report cmdlet

These cmdlets are used to run reports

Get-DedupFiles

To recover files that are duplicated in a certain path

Get-DedupFiles -Path C:\Temp

Or to traverse the path, just specify the -Recurse parameter:

Get-DedupFiles -Path C:\Temp -Recurse

For more info, run:

Get-Help Get-DedupFiles -Full

Show-LatestCreatedFile

Show the latest created files based on a date or size. The size of the files can be specified in bytes 1, 1MB, 1GB, 1TB, 1PB.

Show-LatestCreatedFile -Path C:\Temp -Recurse -Size 50MB -CreationTime '05/29/2016'

For more info, run:

Get-Help Show-LatestCreatedFile -Full

Show-LatestWritedFile

Show the latest modified files based on a date or size. The size of the files can be specified in bytes 1, 1MB, 1GB, 1TB, 1PB.

Show-LatestWritedFile -Path C:\Temp -Recurse -Size 50MB -CreationTime '05/29/2016'

For more info, run:

Get-Help Show-LatestWritedFile -Full

Show-LatestAccessedFile

Show the latest accessed files based on a date or size. The size of the files can be specified in bytes 1, 1MB, 1GB, 1TB, 1PB.

Show-LatestAccessedFile -Path C:\Temp -Recurse -Size 50MB -CreationTime '05/29/2016'

For more info, run:

Get-Help Show-LatestAccessedFile -Full

Show-FolderLength

Show to estimate file space usage. Track the directories which are consuming excessive amount of space on a drive.

Show-FolderLength -Path C:\Temp

For more info, run:

Get-Help Show-FolderLength -Full

Backup/Restore ACL cmdlet

These cmdlets are used to backup and restore ACL on folder structure

Backup-ACLFolders

Backup ACL traverse folders on specific path. The backup csv header is: “Path”,”FileSystemRights”,”AccessControlType”,”IdentityReference”,”IsInherited”,”InheritanceFlags”,”PropagationFlags”.

Backup-ACLFolders -Path C:\Temp -OutputCSV C:\Temp2\acl_temp.csv

For more info, run:

Get-Help Backup-ACLFolders -Full

Restore-ACLFolders

Restore ACL traverse folders on specific path. The backup csv header is: “Path”,”FileSystemRights”,”AccessControlType”,”IdentityReference”,”IsInherited”,”InheritanceFlags”,”PropagationFlags”.

ATTENTION: For this operation, need administrative permissions

Restore-ACLFolders -InputCSV C:\Temp2\acl_temp.csv

For more info, run:

Get-Help Restore-ACLFolders -Full

Share cmdlet

These cmdlets are used to manage file server share

Suspend-FSShare

Temporary suspension of a samba share. Permission will be maintained at the end of the suspension.

ATTENTION: For this operation, need administrative permissions

Suspend-FSShare -Share Temp

For more info, run:

Get-Help Suspend-FSShare -Full

A great thanks.

For donations, press this

For me

paypal

For Telethon

The Telethon Foundation is a non-profit organization recognized by the Ministry of University and Scientific and Technological Research. They were born in 1990 to respond to the appeal of patients suffering from rare diseases. Come today, we are organized to dare to listen to them and answers, every day of the year.

Telethon

Adopt the future