Is it possible to write a powershell script to create a folder structure I have in a text file like so:
D:\Dept\AD\16-17\Audit\FIR
D:\Dept\AD\16-17\Budget\Working
D:\Dept\AD\16-17\Budget\Final
D:\Dept\AD\16-17\Correspondence\MediaReleases
D:\Dept\AD\16-17\Correspondence\DL
D:\Dept\AD\16-17\Correspondence\HF
D:\Dept\AD\16-17\Correspondence\Tax
D:\Dept\CC\QualityAssurance\16-17\Audit\FIR
D:\Dept\CC\QualityAssurance\16-17\Budget\Working
D:\Dept\CC\QualityAssurance\16-17\Budget\Final
but to have the permissions and rights written from the already existing previous year? Folder structure where the year is the only difference?
D:\Dept\AD\15-16\Audit\FIR
D:\Dept\AD\15-16\Budget\Working
D:\Dept\AD\15-16\Budget\Final
D:\Dept\AD\15-16\Correspondence\MediaReleases
D:\Dept\AD\15-16\Correspondence\DL
D:\Dept\AD\15-16\Correspondence\HF
D:\Dept\AD\15-16\Correspondence\Tax
D:\Dept\CC\QualityAssurance\15-16\Audit\FIR
D:\Dept\CC\QualityAssurance\15-16\Budget\Working
D:\Dept\CC\QualityAssurance\15-16\Budget\Final
I am just wanting to create the new year but keep all rights and permissions the same from the previous year. There is other files in the previous year so I am trying to just have txt.file create the folders then somehow grab the previous years right and permissions to write to the new folder. Is this possible?
@sapl Receiving two errors:
Directory: D:\Dept\DC\16-17\OSA
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 9/27/2016 4:45 PM OperationalReports
Set-ACL : The security identifier is not allowed to be the owner of this object.
At line:19 char:56
+ Get-ACL $currentFolder.Replace("16-17", "15-16") | Set-ACL $currentFolder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (D:\Dept\DC\16-17\OSA\OperationalReports:String) [Set-Acl], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetAclCommand
Directory: D:\Dept\CC\NorthRiver\16-17\StaffAdministration
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 9/27/2016 4:45 PM CFCA
Set-ACL : The security identifier is not allowed to be the owner of this object.
At line:19 char:56
+ Get-ACL $currentFolder.Replace("16-17", "15-16") | Set-ACL $currentFolder
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (D:\Dept\CC\Nort...nistration\CFCA:String) [Set-Acl], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.SetAclCommand